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; |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 20 | import android.annotation.CheckResult; |
Tor Norbye | 3e4cda7 | 2015-06-10 08:14:31 -0700 | [diff] [blame] | 21 | import android.annotation.ColorInt; |
| 22 | import android.annotation.ColorRes; |
| 23 | import android.annotation.DrawableRes; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 24 | import android.annotation.IntDef; |
| 25 | import android.annotation.NonNull; |
| 26 | import android.annotation.Nullable; |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 27 | import android.annotation.RequiresPermission; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 28 | import android.annotation.StringDef; |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 29 | import android.annotation.StringRes; |
| 30 | import android.annotation.StyleRes; |
| 31 | import android.annotation.StyleableRes; |
Jinsuk Kim | 66d1eb2 | 2014-06-06 16:12:18 +0900 | [diff] [blame] | 32 | import android.annotation.SystemApi; |
Jeff Sharkey | a73b8fd | 2016-01-06 17:02:08 -0700 | [diff] [blame] | 33 | import android.annotation.TestApi; |
Jeff Sharkey | 8588bc1 | 2016-01-06 16:47:42 -0700 | [diff] [blame] | 34 | import android.annotation.UserIdInt; |
Tony Mak | 46aabe5 | 2016-11-14 12:53:06 +0000 | [diff] [blame] | 35 | import android.app.IApplicationThread; |
| 36 | import android.app.IServiceConnection; |
Zak Cohen | 56345f4 | 2017-01-26 13:54:28 -0800 | [diff] [blame] | 37 | import android.app.VrManager; |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 38 | import android.content.pm.ApplicationInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | import android.content.pm.PackageManager; |
| 40 | import android.content.res.AssetManager; |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 41 | import android.content.res.ColorStateList; |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 42 | import android.content.res.Configuration; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 43 | import android.content.res.Resources; |
| 44 | import android.content.res.TypedArray; |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 45 | import android.database.DatabaseErrorHandler; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 46 | import android.database.sqlite.SQLiteDatabase; |
| 47 | import android.database.sqlite.SQLiteDatabase.CursorFactory; |
| 48 | import android.graphics.Bitmap; |
| 49 | import android.graphics.drawable.Drawable; |
| 50 | import android.net.Uri; |
| 51 | import android.os.Bundle; |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 52 | import android.os.Environment; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | import android.os.Handler; |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 54 | import android.os.IBinder; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | import android.os.Looper; |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 56 | import android.os.StatFs; |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 57 | import android.os.UserHandle; |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 58 | import android.os.UserManager; |
Jeff Sharkey | 60a82cd | 2017-04-18 18:19:16 -0600 | [diff] [blame] | 59 | import android.os.storage.StorageManager; |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 60 | import android.provider.MediaStore; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 61 | import android.util.AttributeSet; |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 62 | import android.view.Display; |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 63 | import android.view.DisplayAdjustments; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 64 | import android.view.View; |
Jon Miranda | 836c0a8 | 2014-08-11 12:32:26 -0700 | [diff] [blame] | 65 | import android.view.ViewDebug; |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 66 | import android.view.WindowManager; |
Felipe Leme | bb567ae | 2017-10-04 09:56:21 -0700 | [diff] [blame] | 67 | import android.view.autofill.AutofillManager.AutofillClient; |
Abodunrinwa Toki | f001fef | 2017-01-04 23:51:42 +0000 | [diff] [blame] | 68 | import android.view.textclassifier.TextClassificationManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 69 | |
| 70 | import java.io.File; |
| 71 | import java.io.FileInputStream; |
| 72 | import java.io.FileNotFoundException; |
| 73 | import java.io.FileOutputStream; |
| 74 | import java.io.IOException; |
| 75 | import java.io.InputStream; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 76 | import java.lang.annotation.Retention; |
| 77 | import java.lang.annotation.RetentionPolicy; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 78 | |
| 79 | /** |
| 80 | * Interface to global information about an application environment. This is |
| 81 | * an abstract class whose implementation is provided by |
| 82 | * the Android system. It |
| 83 | * allows access to application-specific resources and classes, as well as |
| 84 | * up-calls for application-level operations such as launching activities, |
| 85 | * broadcasting and receiving intents, etc. |
| 86 | */ |
| 87 | public abstract class Context { |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 88 | /** @hide */ |
| 89 | @IntDef(flag = true, prefix = { "MODE_" }, value = { |
| 90 | MODE_PRIVATE, |
| 91 | MODE_WORLD_READABLE, |
| 92 | MODE_WORLD_WRITEABLE, |
| 93 | MODE_APPEND, |
| 94 | }) |
| 95 | @Retention(RetentionPolicy.SOURCE) |
| 96 | public @interface FileMode {} |
| 97 | |
| 98 | /** @hide */ |
| 99 | @IntDef(flag = true, prefix = { "MODE_" }, value = { |
| 100 | MODE_PRIVATE, |
| 101 | MODE_WORLD_READABLE, |
| 102 | MODE_WORLD_WRITEABLE, |
| 103 | MODE_MULTI_PROCESS, |
| 104 | }) |
| 105 | @Retention(RetentionPolicy.SOURCE) |
| 106 | public @interface PreferencesMode {} |
| 107 | |
| 108 | /** @hide */ |
| 109 | @IntDef(flag = true, prefix = { "MODE_" }, value = { |
| 110 | MODE_PRIVATE, |
| 111 | MODE_WORLD_READABLE, |
| 112 | MODE_WORLD_WRITEABLE, |
| 113 | MODE_ENABLE_WRITE_AHEAD_LOGGING, |
| 114 | MODE_NO_LOCALIZED_COLLATORS, |
| 115 | }) |
| 116 | @Retention(RetentionPolicy.SOURCE) |
| 117 | public @interface DatabaseMode {} |
| 118 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 119 | /** |
| 120 | * File creation mode: the default mode, where the created file can only |
| 121 | * be accessed by the calling application (or all applications sharing the |
| 122 | * same user ID). |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 123 | */ |
| 124 | public static final int MODE_PRIVATE = 0x0000; |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 125 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 126 | /** |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 127 | * File creation mode: allow all other applications to have read access to |
| 128 | * the created file. |
| 129 | * <p> |
Dave Friedman | cfe5088 | 2017-07-05 00:40:07 -0700 | [diff] [blame] | 130 | * Starting from {@link android.os.Build.VERSION_CODES#N}, attempting to use this |
| 131 | * mode throws a {@link SecurityException}. |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 132 | * |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 133 | * @deprecated Creating world-readable files is very dangerous, and likely |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 134 | * to cause security holes in applications. It is strongly |
| 135 | * discouraged; instead, applications should use more formal |
| 136 | * mechanism for interactions such as {@link ContentProvider}, |
| 137 | * {@link BroadcastReceiver}, and {@link android.app.Service}. |
| 138 | * There are no guarantees that this access mode will remain on |
| 139 | * a file, such as when it goes through a backup and restore. |
| 140 | * @see android.support.v4.content.FileProvider |
| 141 | * @see Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 142 | */ |
Dianne Hackborn | 556b09e | 2012-09-23 17:46:53 -0700 | [diff] [blame] | 143 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 144 | public static final int MODE_WORLD_READABLE = 0x0001; |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 145 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 146 | /** |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 147 | * File creation mode: allow all other applications to have write access to |
| 148 | * the created file. |
| 149 | * <p> |
Dave Friedman | cfe5088 | 2017-07-05 00:40:07 -0700 | [diff] [blame] | 150 | * 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] | 151 | * mode will throw a {@link SecurityException}. |
| 152 | * |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 153 | * @deprecated Creating world-writable files is very dangerous, and likely |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 154 | * to cause security holes in applications. It is strongly |
| 155 | * discouraged; instead, applications should use more formal |
| 156 | * mechanism for interactions such as {@link ContentProvider}, |
| 157 | * {@link BroadcastReceiver}, and {@link android.app.Service}. |
| 158 | * There are no guarantees that this access mode will remain on |
| 159 | * a file, such as when it goes through a backup and restore. |
| 160 | * @see android.support.v4.content.FileProvider |
| 161 | * @see Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 162 | */ |
Dianne Hackborn | 556b09e | 2012-09-23 17:46:53 -0700 | [diff] [blame] | 163 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 164 | public static final int MODE_WORLD_WRITEABLE = 0x0002; |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 165 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 166 | /** |
| 167 | * File creation mode: for use with {@link #openFileOutput}, if the file |
| 168 | * already exists then write data to the end of the existing file |
| 169 | * instead of erasing it. |
| 170 | * @see #openFileOutput |
| 171 | */ |
| 172 | public static final int MODE_APPEND = 0x8000; |
| 173 | |
| 174 | /** |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 175 | * SharedPreference loading flag: when set, the file on disk will |
| 176 | * be checked for modification even if the shared preferences |
| 177 | * instance is already loaded in this process. This behavior is |
| 178 | * sometimes desired in cases where the application has multiple |
| 179 | * processes, all writing to the same SharedPreferences file. |
| 180 | * Generally there are better forms of communication between |
| 181 | * processes, though. |
| 182 | * |
| 183 | * <p>This was the legacy (but undocumented) behavior in and |
| 184 | * before Gingerbread (Android 2.3) and this flag is implied when |
| 185 | * targetting such releases. For applications targetting SDK |
| 186 | * versions <em>greater than</em> Android 2.3, this flag must be |
| 187 | * explicitly set if desired. |
| 188 | * |
| 189 | * @see #getSharedPreferences |
Christopher Tate | d5748b8 | 2015-05-08 18:14:01 -0700 | [diff] [blame] | 190 | * |
| 191 | * @deprecated MODE_MULTI_PROCESS does not work reliably in |
| 192 | * some versions of Android, and furthermore does not provide any |
| 193 | * mechanism for reconciling concurrent modifications across |
| 194 | * processes. Applications should not attempt to use it. Instead, |
| 195 | * they should use an explicit cross-process data management |
| 196 | * approach such as {@link android.content.ContentProvider ContentProvider}. |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 197 | */ |
Christopher Tate | d5748b8 | 2015-05-08 18:14:01 -0700 | [diff] [blame] | 198 | @Deprecated |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 199 | public static final int MODE_MULTI_PROCESS = 0x0004; |
| 200 | |
| 201 | /** |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 202 | * Database open flag: when set, the database is opened with write-ahead |
| 203 | * logging enabled by default. |
| 204 | * |
| 205 | * @see #openOrCreateDatabase(String, int, CursorFactory) |
| 206 | * @see #openOrCreateDatabase(String, int, CursorFactory, DatabaseErrorHandler) |
| 207 | * @see SQLiteDatabase#enableWriteAheadLogging |
| 208 | */ |
| 209 | public static final int MODE_ENABLE_WRITE_AHEAD_LOGGING = 0x0008; |
| 210 | |
Sunny Goyal | a21e6b2 | 2015-12-02 09:51:02 -0800 | [diff] [blame] | 211 | /** |
| 212 | * Database open flag: when set, the database is opened without support for |
| 213 | * localized collators. |
| 214 | * |
| 215 | * @see #openOrCreateDatabase(String, int, CursorFactory) |
| 216 | * @see #openOrCreateDatabase(String, int, CursorFactory, DatabaseErrorHandler) |
| 217 | * @see SQLiteDatabase#NO_LOCALIZED_COLLATORS |
| 218 | */ |
| 219 | public static final int MODE_NO_LOCALIZED_COLLATORS = 0x0010; |
| 220 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 221 | /** @hide */ |
| 222 | @IntDef(flag = true, |
| 223 | value = { |
| 224 | BIND_AUTO_CREATE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 225 | BIND_DEBUG_UNBIND, |
| 226 | BIND_NOT_FOREGROUND, |
| 227 | BIND_ABOVE_CLIENT, |
| 228 | BIND_ALLOW_OOM_MANAGEMENT, |
Tor Norbye | ce1c67c | 2014-12-02 13:59:17 -0800 | [diff] [blame] | 229 | BIND_WAIVE_PRIORITY, |
| 230 | BIND_IMPORTANT, |
| 231 | BIND_ADJUST_WITH_ACTIVITY |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 232 | }) |
| 233 | @Retention(RetentionPolicy.SOURCE) |
| 234 | public @interface BindServiceFlags {} |
| 235 | |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 236 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 237 | * Flag for {@link #bindService}: automatically create the service as long |
| 238 | * as the binding exists. Note that while this will create the service, |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 239 | * its {@link android.app.Service#onStartCommand} |
| 240 | * method will still only be called due to an |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 241 | * explicit call to {@link #startService}. Even without that, though, |
| 242 | * this still provides you with access to the service object while the |
| 243 | * service is created. |
| 244 | * |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 245 | * <p>Note that prior to {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, |
| 246 | * not supplying this flag would also impact how important the system |
| 247 | * consider's the target service's process to be. When set, the only way |
| 248 | * for it to be raised was by binding from a service in which case it will |
| 249 | * only be important when that activity is in the foreground. Now to |
| 250 | * achieve this behavior you must explicitly supply the new flag |
| 251 | * {@link #BIND_ADJUST_WITH_ACTIVITY}. For compatibility, old applications |
| 252 | * that don't specify {@link #BIND_AUTO_CREATE} will automatically have |
| 253 | * the flags {@link #BIND_WAIVE_PRIORITY} and |
| 254 | * {@link #BIND_ADJUST_WITH_ACTIVITY} set for them in order to achieve |
| 255 | * the same result. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 256 | */ |
| 257 | public static final int BIND_AUTO_CREATE = 0x0001; |
| 258 | |
| 259 | /** |
| 260 | * Flag for {@link #bindService}: include debugging help for mismatched |
| 261 | * calls to unbind. When this flag is set, the callstack of the following |
| 262 | * {@link #unbindService} call is retained, to be printed if a later |
| 263 | * incorrect unbind call is made. Note that doing this requires retaining |
| 264 | * information about the binding that was made for the lifetime of the app, |
| 265 | * resulting in a leak -- this should only be used for debugging. |
| 266 | */ |
| 267 | public static final int BIND_DEBUG_UNBIND = 0x0002; |
| 268 | |
Dianne Hackborn | 09c916b | 2009-12-08 14:50:51 -0800 | [diff] [blame] | 269 | /** |
| 270 | * Flag for {@link #bindService}: don't allow this binding to raise |
| 271 | * the target service's process to the foreground scheduling priority. |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 272 | * It will still be raised to at least the same memory priority |
Dianne Hackborn | 09c916b | 2009-12-08 14:50:51 -0800 | [diff] [blame] | 273 | * as the client (so that its process will not be killable in any |
| 274 | * situation where the client is not killable), but for CPU scheduling |
| 275 | * purposes it may be left in the background. This only has an impact |
| 276 | * in the situation where the binding client is a foreground process |
| 277 | * and the target service is in a background process. |
| 278 | */ |
| 279 | public static final int BIND_NOT_FOREGROUND = 0x0004; |
| 280 | |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 281 | /** |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 282 | * Flag for {@link #bindService}: indicates that the client application |
| 283 | * binding to this service considers the service to be more important than |
| 284 | * 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] | 285 | * 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] | 286 | * this is not guaranteed to be the case. |
| 287 | */ |
| 288 | public static final int BIND_ABOVE_CLIENT = 0x0008; |
| 289 | |
| 290 | /** |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 291 | * Flag for {@link #bindService}: allow the process hosting the bound |
| 292 | * service to go through its normal memory management. It will be |
| 293 | * treated more like a running service, allowing the system to |
| 294 | * (temporarily) expunge the process if low on memory or for some other |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 295 | * whim it may have, and being more aggressive about making it a candidate |
| 296 | * to be killed (and restarted) if running for a long time. |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 297 | */ |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 298 | public static final int BIND_ALLOW_OOM_MANAGEMENT = 0x0010; |
| 299 | |
| 300 | /** |
| 301 | * Flag for {@link #bindService}: don't impact the scheduling or |
| 302 | * memory management priority of the target service's hosting process. |
| 303 | * Allows the service's process to be managed on the background LRU list |
| 304 | * just like a regular application process in the background. |
| 305 | */ |
| 306 | public static final int BIND_WAIVE_PRIORITY = 0x0020; |
| 307 | |
| 308 | /** |
| 309 | * Flag for {@link #bindService}: this service is very important to |
| 310 | * the client, so should be brought to the foreground process level |
| 311 | * when the client is. Normally a process can only be raised to the |
| 312 | * visibility level by a client, even if that client is in the foreground. |
| 313 | */ |
| 314 | public static final int BIND_IMPORTANT = 0x0040; |
| 315 | |
| 316 | /** |
| 317 | * Flag for {@link #bindService}: If binding from an activity, allow the |
| 318 | * target service's process importance to be raised based on whether the |
| 319 | * activity is visible to the user, regardless whether another flag is |
| 320 | * used to reduce the amount that the client process's overall importance |
| 321 | * is used to impact it. |
| 322 | */ |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 323 | public static final int BIND_ADJUST_WITH_ACTIVITY = 0x0080; |
| 324 | |
| 325 | /** |
Dianne Hackborn | 83b40f6 | 2017-04-26 13:59:47 -0700 | [diff] [blame] | 326 | * @hide Flag for {@link #bindService}: like {@link #BIND_NOT_FOREGROUND}, but puts it |
| 327 | * up in to the important background state (instead of transient). |
| 328 | */ |
| 329 | public static final int BIND_IMPORTANT_BACKGROUND = 0x00800000; |
| 330 | |
| 331 | /** |
Felipe Leme | a1b79bf | 2016-05-24 13:06:54 -0700 | [diff] [blame] | 332 | * @hide Flag for {@link #bindService}: allows application hosting service to manage whitelists |
| 333 | * such as temporary allowing a {@code PendingIntent} to bypass Power Save mode. |
| 334 | */ |
| 335 | public static final int BIND_ALLOW_WHITELIST_MANAGEMENT = 0x01000000; |
| 336 | |
| 337 | /** |
Dianne Hackborn | d69e4c1 | 2015-04-24 09:54:54 -0700 | [diff] [blame] | 338 | * @hide Flag for {@link #bindService}: Like {@link #BIND_FOREGROUND_SERVICE}, |
| 339 | * but only applies while the device is awake. |
| 340 | */ |
| 341 | public static final int BIND_FOREGROUND_SERVICE_WHILE_AWAKE = 0x02000000; |
| 342 | |
| 343 | /** |
| 344 | * @hide Flag for {@link #bindService}: For only the case where the binding |
| 345 | * is coming from the system, set the process state to FOREGROUND_SERVICE |
| 346 | * instead of the normal maximum of IMPORTANT_FOREGROUND. That is, this is |
| 347 | * saying that the process shouldn't participate in the normal power reduction |
| 348 | * modes (removing network access etc). |
| 349 | */ |
| 350 | public static final int BIND_FOREGROUND_SERVICE = 0x04000000; |
| 351 | |
| 352 | /** |
Dianne Hackborn | f0f94d1 | 2014-03-17 16:04:21 -0700 | [diff] [blame] | 353 | * @hide Flag for {@link #bindService}: Treat the binding as hosting |
| 354 | * an activity, an unbinding as the activity going in the background. |
| 355 | * That is, when unbinding, the process when empty will go on the activity |
| 356 | * LRU list instead of the regular one, keeping it around more aggressively |
| 357 | * than it otherwise would be. This is intended for use with IMEs to try |
| 358 | * to keep IME processes around for faster keyboard switching. |
| 359 | */ |
| 360 | public static final int BIND_TREAT_LIKE_ACTIVITY = 0x08000000; |
| 361 | |
| 362 | /** |
Dianne Hackborn | b12e135 | 2012-09-26 11:39:20 -0700 | [diff] [blame] | 363 | * @hide An idea that is not yet implemented. |
| 364 | * Flag for {@link #bindService}: If binding from an activity, consider |
| 365 | * this service to be visible like the binding activity is. That is, |
| 366 | * it will be treated as something more important to keep around than |
| 367 | * invisible background activities. This will impact the number of |
| 368 | * recent activities the user can switch between without having them |
| 369 | * restart. There is no guarantee this will be respected, as the system |
| 370 | * tries to balance such requests from one app vs. the importantance of |
| 371 | * keeping other apps around. |
| 372 | */ |
Dianne Hackborn | c823051 | 2013-07-13 21:32:12 -0700 | [diff] [blame] | 373 | public static final int BIND_VISIBLE = 0x10000000; |
| 374 | |
| 375 | /** |
| 376 | * @hide |
| 377 | * Flag for {@link #bindService}: Consider this binding to be causing the target |
| 378 | * process to be showing UI, so it will be do a UI_HIDDEN memory trim when it goes |
| 379 | * away. |
| 380 | */ |
| 381 | public static final int BIND_SHOWING_UI = 0x20000000; |
Dianne Hackborn | b12e135 | 2012-09-26 11:39:20 -0700 | [diff] [blame] | 382 | |
| 383 | /** |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 384 | * Flag for {@link #bindService}: Don't consider the bound service to be |
| 385 | * visible, even if the caller is visible. |
| 386 | * @hide |
| 387 | */ |
| 388 | public static final int BIND_NOT_VISIBLE = 0x40000000; |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 389 | |
Alan Viverette | 713a5cd | 2015-12-16 15:46:32 -0500 | [diff] [blame] | 390 | /** |
Robert Sesek | b9a8666 | 2015-12-09 16:22:45 -0500 | [diff] [blame] | 391 | * Flag for {@link #bindService}: The service being bound is an |
| 392 | * {@link android.R.attr#isolatedProcess isolated}, |
| 393 | * {@link android.R.attr#externalService external} service. This binds the service into the |
| 394 | * 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] | 395 | * <p> |
| 396 | * When using this flag, the code for the service being bound will execute under the calling |
| 397 | * application's package name and user ID. Because the service must be an isolated process, |
| 398 | * it will not have direct access to the application's data, though. |
| 399 | * |
| 400 | * The purpose of this flag is to allow applications to provide services that are attributed |
| 401 | * to the app using the service, rather than the application providing the service. |
| 402 | * </p> |
Robert Sesek | b9a8666 | 2015-12-09 16:22:45 -0500 | [diff] [blame] | 403 | */ |
| 404 | public static final int BIND_EXTERNAL_SERVICE = 0x80000000; |
| 405 | |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 406 | /** @hide */ |
| 407 | @IntDef(flag = true, |
| 408 | value = { |
| 409 | RECEIVER_VISIBLE_TO_INSTANT_APPS |
| 410 | }) |
| 411 | @Retention(RetentionPolicy.SOURCE) |
| 412 | public @interface RegisterReceiverFlags {} |
| 413 | |
| 414 | /** |
| 415 | * Flag for {@link #registerReceiver}: The receiver can receive broadcasts from Instant Apps. |
| 416 | */ |
| 417 | public static final int RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x1; |
| 418 | |
Robert Sesek | b9a8666 | 2015-12-09 16:22:45 -0500 | [diff] [blame] | 419 | /** |
Alan Viverette | 713a5cd | 2015-12-16 15:46:32 -0500 | [diff] [blame] | 420 | * Returns an AssetManager instance for the application's package. |
| 421 | * <p> |
| 422 | * <strong>Note:</strong> Implementations of this method should return |
| 423 | * an AssetManager instance that is consistent with the Resources instance |
| 424 | * returned by {@link #getResources()}. For example, they should share the |
| 425 | * same {@link Configuration} object. |
| 426 | * |
| 427 | * @return an AssetManager instance for the application's package |
| 428 | * @see #getResources() |
| 429 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 430 | public abstract AssetManager getAssets(); |
| 431 | |
Alan Viverette | 713a5cd | 2015-12-16 15:46:32 -0500 | [diff] [blame] | 432 | /** |
| 433 | * Returns a Resources instance for the application's package. |
| 434 | * <p> |
| 435 | * <strong>Note:</strong> Implementations of this method should return |
| 436 | * a Resources instance that is consistent with the AssetManager instance |
| 437 | * returned by {@link #getAssets()}. For example, they should share the |
| 438 | * same {@link Configuration} object. |
| 439 | * |
| 440 | * @return a Resources instance for the application's package |
| 441 | * @see #getAssets() |
| 442 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 443 | public abstract Resources getResources(); |
| 444 | |
| 445 | /** Return PackageManager instance to find global package information. */ |
| 446 | public abstract PackageManager getPackageManager(); |
| 447 | |
| 448 | /** Return a ContentResolver instance for your application's package. */ |
| 449 | public abstract ContentResolver getContentResolver(); |
| 450 | |
| 451 | /** |
| 452 | * Return the Looper for the main thread of the current process. This is |
| 453 | * the thread used to dispatch calls to application components (activities, |
| 454 | * services, etc). |
Jeff Brown | f9e989d | 2013-04-04 23:04:03 -0700 | [diff] [blame] | 455 | * <p> |
| 456 | * By definition, this method returns the same result as would be obtained |
| 457 | * by calling {@link Looper#getMainLooper() Looper.getMainLooper()}. |
| 458 | * </p> |
| 459 | * |
| 460 | * @return The main looper. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 461 | */ |
| 462 | public abstract Looper getMainLooper(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 463 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 464 | /** |
| 465 | * Return the context of the single, global Application object of the |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 466 | * current process. This generally should only be used if you need a |
| 467 | * Context whose lifecycle is separate from the current context, that is |
| 468 | * tied to the lifetime of the process rather than the current component. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 469 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 470 | * <p>Consider for example how this interacts with |
Brad Fitzpatrick | 36af794 | 2010-12-08 11:31:07 -0800 | [diff] [blame] | 471 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter)}: |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 472 | * <ul> |
| 473 | * <li> <p>If used from an Activity context, the receiver is being registered |
| 474 | * within that activity. This means that you are expected to unregister |
| 475 | * before the activity is done being destroyed; in fact if you do not do |
| 476 | * so, the framework will clean up your leaked registration as it removes |
| 477 | * the activity and log an error. Thus, if you use the Activity context |
| 478 | * to register a receiver that is static (global to the process, not |
| 479 | * associated with an Activity instance) then that registration will be |
| 480 | * removed on you at whatever point the activity you used is destroyed. |
| 481 | * <li> <p>If used from the Context returned here, the receiver is being |
| 482 | * registered with the global state associated with your application. Thus |
| 483 | * it will never be unregistered for you. This is necessary if the receiver |
| 484 | * is associated with static data, not a particular component. However |
| 485 | * using the ApplicationContext elsewhere can easily lead to serious leaks |
| 486 | * if you forget to unregister, unbind, etc. |
| 487 | * </ul> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 488 | */ |
| 489 | public abstract Context getApplicationContext(); |
| 490 | |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 491 | /** Non-activity related autofill ids are unique in the app */ |
| 492 | private static int sLastAutofillId = View.NO_ID; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 493 | |
| 494 | /** |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 495 | * Gets the next autofill ID. |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 496 | * |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 497 | * <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] | 498 | * returned will be unique. |
| 499 | * |
| 500 | * @return A ID that is unique in the process |
| 501 | * |
| 502 | * {@hide} |
| 503 | */ |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 504 | public int getNextAutofillId() { |
| 505 | if (sLastAutofillId == View.LAST_APP_AUTOFILL_ID - 1) { |
| 506 | sLastAutofillId = View.NO_ID; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 507 | } |
| 508 | |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 509 | sLastAutofillId++; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 510 | |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 511 | return sLastAutofillId; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 512 | } |
| 513 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 514 | /** |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 515 | * Add a new {@link ComponentCallbacks} to the base application of the |
| 516 | * Context, which will be called at the same times as the ComponentCallbacks |
| 517 | * methods of activities and other components are called. Note that you |
| 518 | * <em>must</em> be sure to use {@link #unregisterComponentCallbacks} when |
| 519 | * appropriate in the future; this will not be removed for you. |
Dianne Hackborn | 905577f | 2011-09-07 18:31:28 -0700 | [diff] [blame] | 520 | * |
| 521 | * @param callback The interface to call. This can be either a |
| 522 | * {@link ComponentCallbacks} or {@link ComponentCallbacks2} interface. |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 523 | */ |
| 524 | public void registerComponentCallbacks(ComponentCallbacks callback) { |
| 525 | getApplicationContext().registerComponentCallbacks(callback); |
| 526 | } |
| 527 | |
| 528 | /** |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 529 | * Remove a {@link ComponentCallbacks} object that was previously registered |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 530 | * with {@link #registerComponentCallbacks(ComponentCallbacks)}. |
| 531 | */ |
| 532 | public void unregisterComponentCallbacks(ComponentCallbacks callback) { |
| 533 | getApplicationContext().unregisterComponentCallbacks(callback); |
| 534 | } |
| 535 | |
| 536 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 537 | * Return a localized, styled CharSequence from the application's package's |
| 538 | * default string table. |
| 539 | * |
| 540 | * @param resId Resource id for the CharSequence text |
| 541 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 542 | public final CharSequence getText(@StringRes int resId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 543 | return getResources().getText(resId); |
| 544 | } |
| 545 | |
| 546 | /** |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 547 | * 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] | 548 | * default string table. |
| 549 | * |
| 550 | * @param resId Resource id for the string |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 551 | * @return The string data associated with the resource, stripped of styled |
| 552 | * text information. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 553 | */ |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 554 | @NonNull |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 555 | public final String getString(@StringRes int resId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 556 | return getResources().getString(resId); |
| 557 | } |
| 558 | |
| 559 | /** |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 560 | * 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] | 561 | * default string table, substituting the format arguments as defined in |
| 562 | * {@link java.util.Formatter} and {@link java.lang.String#format}. |
| 563 | * |
| 564 | * @param resId Resource id for the format string |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 565 | * @param formatArgs The format arguments that will be used for |
| 566 | * substitution. |
| 567 | * @return The string data associated with the resource, formatted and |
| 568 | * stripped of styled text information. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 569 | */ |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 570 | @NonNull |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 571 | public final String getString(@StringRes int resId, Object... formatArgs) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 572 | return getResources().getString(resId, formatArgs); |
| 573 | } |
| 574 | |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 575 | /** |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 576 | * Returns a color associated with a particular resource ID and styled for |
| 577 | * the current theme. |
| 578 | * |
| 579 | * @param id The desired resource identifier, as generated by the aapt |
| 580 | * tool. This integer encodes the package, type, and resource |
| 581 | * entry. The value 0 is an invalid identifier. |
| 582 | * @return A single color value in the form 0xAARRGGBB. |
| 583 | * @throws android.content.res.Resources.NotFoundException if the given ID |
| 584 | * does not exist. |
| 585 | */ |
Tor Norbye | 3e4cda7 | 2015-06-10 08:14:31 -0700 | [diff] [blame] | 586 | @ColorInt |
| 587 | public final int getColor(@ColorRes int id) { |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 588 | return getResources().getColor(id, getTheme()); |
| 589 | } |
| 590 | |
| 591 | /** |
| 592 | * Returns a drawable object associated with a particular resource ID and |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 593 | * styled for the current theme. |
| 594 | * |
| 595 | * @param id The desired resource identifier, as generated by the aapt |
| 596 | * tool. This integer encodes the package, type, and resource |
| 597 | * entry. The value 0 is an invalid identifier. |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 598 | * @return An object that can be used to draw this resource, or |
| 599 | * {@code null} if the resource could not be resolved. |
| 600 | * @throws android.content.res.Resources.NotFoundException if the given ID |
| 601 | * does not exist. |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 602 | */ |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 603 | @Nullable |
Tor Norbye | 3e4cda7 | 2015-06-10 08:14:31 -0700 | [diff] [blame] | 604 | public final Drawable getDrawable(@DrawableRes int id) { |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 605 | return getResources().getDrawable(id, getTheme()); |
| 606 | } |
| 607 | |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 608 | /** |
| 609 | * Returns a color state list associated with a particular resource ID and |
| 610 | * styled for the current theme. |
| 611 | * |
| 612 | * @param id The desired resource identifier, as generated by the aapt |
| 613 | * tool. This integer encodes the package, type, and resource |
| 614 | * entry. The value 0 is an invalid identifier. |
| 615 | * @return A color state list, or {@code null} if the resource could not be |
| 616 | * resolved. |
| 617 | * @throws android.content.res.Resources.NotFoundException if the given ID |
| 618 | * does not exist. |
| 619 | */ |
| 620 | @Nullable |
Tor Norbye | 3e4cda7 | 2015-06-10 08:14:31 -0700 | [diff] [blame] | 621 | public final ColorStateList getColorStateList(@ColorRes int id) { |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 622 | return getResources().getColorStateList(id, getTheme()); |
| 623 | } |
| 624 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 625 | /** |
| 626 | * Set the base theme for this context. Note that this should be called |
| 627 | * before any views are instantiated in the Context (for example before |
| 628 | * calling {@link android.app.Activity#setContentView} or |
| 629 | * {@link android.view.LayoutInflater#inflate}). |
| 630 | * |
| 631 | * @param resid The style resource describing the theme. |
| 632 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 633 | public abstract void setTheme(@StyleRes int resid); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 634 | |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 635 | /** @hide Needed for some internal implementation... not public because |
| 636 | * you can't assume this actually means anything. */ |
| 637 | public int getThemeResId() { |
| 638 | return 0; |
| 639 | } |
| 640 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 641 | /** |
| 642 | * Return the Theme object associated with this Context. |
| 643 | */ |
Jon Miranda | 836c0a8 | 2014-08-11 12:32:26 -0700 | [diff] [blame] | 644 | @ViewDebug.ExportedProperty(deepExport = true) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 645 | public abstract Resources.Theme getTheme(); |
| 646 | |
| 647 | /** |
| 648 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 649 | * {@link android.content.res.Resources.Theme#obtainStyledAttributes(int[])} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 650 | * for more information. |
| 651 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 652 | * @see android.content.res.Resources.Theme#obtainStyledAttributes(int[]) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 653 | */ |
Tor Norbye | c91531a | 2015-04-01 17:41:55 -0700 | [diff] [blame] | 654 | public final TypedArray obtainStyledAttributes(@StyleableRes int[] attrs) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 655 | return getTheme().obtainStyledAttributes(attrs); |
| 656 | } |
| 657 | |
| 658 | /** |
| 659 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 660 | * {@link android.content.res.Resources.Theme#obtainStyledAttributes(int, int[])} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 661 | * for more information. |
| 662 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 663 | * @see android.content.res.Resources.Theme#obtainStyledAttributes(int, int[]) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 664 | */ |
| 665 | public final TypedArray obtainStyledAttributes( |
Tor Norbye | c91531a | 2015-04-01 17:41:55 -0700 | [diff] [blame] | 666 | @StyleRes int resid, @StyleableRes int[] attrs) throws Resources.NotFoundException { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 667 | return getTheme().obtainStyledAttributes(resid, attrs); |
| 668 | } |
| 669 | |
| 670 | /** |
| 671 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 672 | * {@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] | 673 | * for more information. |
| 674 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 675 | * @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] | 676 | */ |
| 677 | public final TypedArray obtainStyledAttributes( |
Tor Norbye | c91531a | 2015-04-01 17:41:55 -0700 | [diff] [blame] | 678 | AttributeSet set, @StyleableRes int[] attrs) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 679 | return getTheme().obtainStyledAttributes(set, attrs, 0, 0); |
| 680 | } |
| 681 | |
| 682 | /** |
| 683 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 684 | * {@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] | 685 | * for more information. |
| 686 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 687 | * @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] | 688 | */ |
| 689 | public final TypedArray obtainStyledAttributes( |
Tor Norbye | c91531a | 2015-04-01 17:41:55 -0700 | [diff] [blame] | 690 | AttributeSet set, @StyleableRes int[] attrs, @AttrRes int defStyleAttr, |
| 691 | @StyleRes int defStyleRes) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 692 | return getTheme().obtainStyledAttributes( |
| 693 | set, attrs, defStyleAttr, defStyleRes); |
| 694 | } |
| 695 | |
| 696 | /** |
| 697 | * Return a class loader you can use to retrieve classes in this package. |
| 698 | */ |
| 699 | public abstract ClassLoader getClassLoader(); |
| 700 | |
| 701 | /** Return the name of this application's package. */ |
| 702 | public abstract String getPackageName(); |
| 703 | |
Dianne Hackborn | d8e1dbb | 2013-01-17 17:47:37 -0800 | [diff] [blame] | 704 | /** @hide Return the name of the base context this context is derived from. */ |
| 705 | public abstract String getBasePackageName(); |
| 706 | |
Dianne Hackborn | 95d7853 | 2013-09-11 09:51:14 -0700 | [diff] [blame] | 707 | /** @hide Return the package name that should be used for app ops calls from |
| 708 | * this context. This is the same as {@link #getBasePackageName()} except in |
| 709 | * cases where system components are loaded into other app processes, in which |
| 710 | * case this will be the name of the primary package in that process (so that app |
| 711 | * ops uid verification will work with the name). */ |
| 712 | public abstract String getOpPackageName(); |
| 713 | |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 714 | /** Return the full application info for this context's package. */ |
| 715 | public abstract ApplicationInfo getApplicationInfo(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 716 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 717 | /** |
Kenny Root | 3214839 | 2010-01-21 15:40:47 -0800 | [diff] [blame] | 718 | * Return the full path to this context's primary Android package. |
| 719 | * The Android package is a ZIP file which contains the application's |
| 720 | * primary resources. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 721 | * |
| 722 | * <p>Note: this is not generally useful for applications, since they should |
| 723 | * not be directly accessing the file system. |
| 724 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 725 | * @return String Path to the resources. |
| 726 | */ |
| 727 | public abstract String getPackageResourcePath(); |
| 728 | |
| 729 | /** |
Kenny Root | 3214839 | 2010-01-21 15:40:47 -0800 | [diff] [blame] | 730 | * Return the full path to this context's primary Android package. |
| 731 | * The Android package is a ZIP file which contains application's |
| 732 | * primary code and assets. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 733 | * |
| 734 | * <p>Note: this is not generally useful for applications, since they should |
| 735 | * not be directly accessing the file system. |
| 736 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 737 | * @return String Path to the code and assets. |
| 738 | */ |
| 739 | public abstract String getPackageCodePath(); |
| 740 | |
| 741 | /** |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 742 | * @hide |
| 743 | * @deprecated use {@link #getSharedPreferencesPath(String)} |
Joe Onorato | 23ecae3 | 2009-06-10 17:07:15 -0700 | [diff] [blame] | 744 | */ |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 745 | @Deprecated |
| 746 | public File getSharedPrefsFile(String name) { |
| 747 | return getSharedPreferencesPath(name); |
| 748 | } |
Joe Onorato | 23ecae3 | 2009-06-10 17:07:15 -0700 | [diff] [blame] | 749 | |
| 750 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 751 | * Retrieve and hold the contents of the preferences file 'name', returning |
| 752 | * a SharedPreferences through which you can retrieve and modify its |
| 753 | * values. Only one instance of the SharedPreferences object is returned |
| 754 | * to any callers for the same name, meaning they will see each other's |
| 755 | * edits as soon as they are made. |
| 756 | * |
Jonathan Dormody | 1bca5db | 2017-11-16 11:25:20 -0700 | [diff] [blame] | 757 | * This method is thead-safe. |
| 758 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 759 | * @param name Desired preferences file. If a preferences file by this name |
| 760 | * does not exist, it will be created when you retrieve an |
| 761 | * editor (SharedPreferences.edit()) and then commit changes (Editor.commit()). |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 762 | * @param mode Operating mode. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 763 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 764 | * @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] | 765 | * to retrieve and modify the preference values. |
| 766 | * |
| 767 | * @see #MODE_PRIVATE |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 768 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 769 | public abstract SharedPreferences getSharedPreferences(String name, @PreferencesMode int mode); |
Jeff Sharkey | 8fc29cf | 2015-11-30 17:51:00 -0700 | [diff] [blame] | 770 | |
| 771 | /** |
| 772 | * Retrieve and hold the contents of the preferences file, returning |
| 773 | * a SharedPreferences through which you can retrieve and modify its |
| 774 | * values. Only one instance of the SharedPreferences object is returned |
| 775 | * to any callers for the same name, meaning they will see each other's |
| 776 | * edits as soon as they are made. |
| 777 | * |
| 778 | * @param file Desired preferences file. If a preferences file by this name |
| 779 | * does not exist, it will be created when you retrieve an |
| 780 | * editor (SharedPreferences.edit()) and then commit changes (Editor.commit()). |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 781 | * @param mode Operating mode. |
Jeff Sharkey | 8fc29cf | 2015-11-30 17:51:00 -0700 | [diff] [blame] | 782 | * |
| 783 | * @return The single {@link SharedPreferences} instance that can be used |
| 784 | * to retrieve and modify the preference values. |
| 785 | * |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 786 | * @see #getSharedPreferencesPath(String) |
Jeff Sharkey | 8fc29cf | 2015-11-30 17:51:00 -0700 | [diff] [blame] | 787 | * @see #MODE_PRIVATE |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 788 | * @removed |
Jeff Sharkey | 8fc29cf | 2015-11-30 17:51:00 -0700 | [diff] [blame] | 789 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 790 | public abstract SharedPreferences getSharedPreferences(File file, @PreferencesMode int mode); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 791 | |
| 792 | /** |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 793 | * Move an existing shared preferences file from the given source storage |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 794 | * context to this context. This is typically used to migrate data between |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 795 | * storage locations after an upgrade, such as moving to device protected |
| 796 | * storage. |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 797 | * |
| 798 | * @param sourceContext The source context which contains the existing |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 799 | * shared preferences to move. |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 800 | * @param name The name of the shared preferences file. |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 801 | * @return {@code true} if the move was successful or if the shared |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 802 | * preferences didn't exist in the source context, otherwise |
| 803 | * {@code false}. |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 804 | * @see #createDeviceProtectedStorageContext() |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 805 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 806 | public abstract boolean moveSharedPreferencesFrom(Context sourceContext, String name); |
| 807 | |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 808 | /** |
| 809 | * Delete an existing shared preferences file. |
| 810 | * |
| 811 | * @param name The name (unique in the application package) of the shared |
| 812 | * preferences file. |
| 813 | * @return {@code true} if the shared preferences file was successfully |
| 814 | * deleted; else {@code false}. |
| 815 | * @see #getSharedPreferences(String, int) |
| 816 | */ |
| 817 | public abstract boolean deleteSharedPreferences(String name); |
| 818 | |
Christopher Tate | fe2368c | 2017-05-17 15:42:35 -0700 | [diff] [blame] | 819 | /** @hide */ |
| 820 | public abstract void reloadSharedPreferences(); |
| 821 | |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 822 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 823 | * Open a private file associated with this Context's application package |
| 824 | * for reading. |
| 825 | * |
| 826 | * @param name The name of the file to open; can not contain path |
| 827 | * separators. |
| 828 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 829 | * @return The resulting {@link FileInputStream}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 830 | * |
| 831 | * @see #openFileOutput |
| 832 | * @see #fileList |
| 833 | * @see #deleteFile |
| 834 | * @see java.io.FileInputStream#FileInputStream(String) |
| 835 | */ |
| 836 | public abstract FileInputStream openFileInput(String name) |
| 837 | throws FileNotFoundException; |
| 838 | |
| 839 | /** |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 840 | * Open a private file associated with this Context's application package |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 841 | * for writing. Creates the file if it doesn't already exist. |
| 842 | * <p> |
| 843 | * No additional permissions are required for the calling app to read or |
| 844 | * write the returned file. |
Ricardo Cervera | 90a5f98 | 2014-04-04 10:26:05 -0700 | [diff] [blame] | 845 | * |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 846 | * @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] | 847 | * separators. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 848 | * @param mode Operating mode. |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 849 | * @return The resulting {@link FileOutputStream}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 850 | * @see #MODE_APPEND |
| 851 | * @see #MODE_PRIVATE |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 852 | * @see #openFileInput |
| 853 | * @see #fileList |
| 854 | * @see #deleteFile |
| 855 | * @see java.io.FileOutputStream#FileOutputStream(String) |
| 856 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 857 | public abstract FileOutputStream openFileOutput(String name, @FileMode int mode) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 858 | throws FileNotFoundException; |
| 859 | |
| 860 | /** |
| 861 | * Delete the given private file associated with this Context's |
| 862 | * application package. |
| 863 | * |
| 864 | * @param name The name of the file to delete; can not contain path |
| 865 | * separators. |
| 866 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 867 | * @return {@code true} if the file was successfully deleted; else |
| 868 | * {@code false}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 869 | * |
| 870 | * @see #openFileInput |
| 871 | * @see #openFileOutput |
| 872 | * @see #fileList |
| 873 | * @see java.io.File#delete() |
| 874 | */ |
| 875 | public abstract boolean deleteFile(String name); |
| 876 | |
| 877 | /** |
| 878 | * Returns the absolute path on the filesystem where a file created with |
| 879 | * {@link #openFileOutput} is stored. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 880 | * <p> |
| 881 | * The returned path may change over time if the calling app is moved to an |
| 882 | * 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] | 883 | * |
| 884 | * @param name The name of the file for which you would like to get |
| 885 | * its path. |
| 886 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 887 | * @return An absolute path to the given file. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 888 | * |
| 889 | * @see #openFileOutput |
| 890 | * @see #getFilesDir |
| 891 | * @see #getDir |
| 892 | */ |
| 893 | public abstract File getFileStreamPath(String name); |
| 894 | |
| 895 | /** |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 896 | * Returns the absolute path on the filesystem where a file created with |
| 897 | * {@link #getSharedPreferences(String, int)} is stored. |
| 898 | * <p> |
| 899 | * The returned path may change over time if the calling app is moved to an |
| 900 | * adopted storage device, so only relative paths should be persisted. |
| 901 | * |
| 902 | * @param name The name of the shared preferences for which you would like |
| 903 | * to get a path. |
| 904 | * @return An absolute path to the given file. |
| 905 | * @see #getSharedPreferences(String, int) |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 906 | * @removed |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 907 | */ |
| 908 | public abstract File getSharedPreferencesPath(String name); |
| 909 | |
| 910 | /** |
Jeff Sharkey | 2c1ba9a | 2016-02-17 15:29:38 -0700 | [diff] [blame] | 911 | * Returns the absolute path to the directory on the filesystem where all |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 912 | * private files belonging to this app are stored. Apps should not use this |
| 913 | * path directly; they should instead use {@link #getFilesDir()}, |
| 914 | * {@link #getCacheDir()}, {@link #getDir(String, int)}, or other storage |
| 915 | * APIs on this class. |
Jeff Sharkey | 2c1ba9a | 2016-02-17 15:29:38 -0700 | [diff] [blame] | 916 | * <p> |
| 917 | * The returned path may change over time if the calling app is moved to an |
| 918 | * adopted storage device, so only relative paths should be persisted. |
| 919 | * <p> |
| 920 | * No additional permissions are required for the calling app to read or |
| 921 | * write files under the returned path. |
| 922 | * |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 923 | * @see ApplicationInfo#dataDir |
Jeff Sharkey | 2c1ba9a | 2016-02-17 15:29:38 -0700 | [diff] [blame] | 924 | */ |
| 925 | public abstract File getDataDir(); |
| 926 | |
| 927 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 928 | * Returns the absolute path to the directory on the filesystem where files |
| 929 | * created with {@link #openFileOutput} are stored. |
| 930 | * <p> |
| 931 | * The returned path may change over time if the calling app is moved to an |
| 932 | * adopted storage device, so only relative paths should be persisted. |
| 933 | * <p> |
| 934 | * No additional permissions are required for the calling app to read or |
| 935 | * write files under the returned path. |
Ricardo Cervera | 90a5f98 | 2014-04-04 10:26:05 -0700 | [diff] [blame] | 936 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 937 | * @return The path of the directory holding application files. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 938 | * @see #openFileOutput |
| 939 | * @see #getFileStreamPath |
| 940 | * @see #getDir |
| 941 | */ |
| 942 | public abstract File getFilesDir(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 943 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 944 | /** |
Christopher Tate | a7835b6 | 2014-07-11 17:25:57 -0700 | [diff] [blame] | 945 | * Returns the absolute path to the directory on the filesystem similar to |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 946 | * {@link #getFilesDir()}. The difference is that files placed under this |
| 947 | * directory will be excluded from automatic backup to remote storage. See |
Christopher Tate | a7835b6 | 2014-07-11 17:25:57 -0700 | [diff] [blame] | 948 | * {@link android.app.backup.BackupAgent BackupAgent} for a full discussion |
| 949 | * of the automatic backup mechanism in Android. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 950 | * <p> |
| 951 | * The returned path may change over time if the calling app is moved to an |
| 952 | * adopted storage device, so only relative paths should be persisted. |
| 953 | * <p> |
| 954 | * No additional permissions are required for the calling app to read or |
| 955 | * write files under the returned path. |
Christopher Tate | a7835b6 | 2014-07-11 17:25:57 -0700 | [diff] [blame] | 956 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 957 | * @return The path of the directory holding application files that will not |
| 958 | * be automatically backed up to remote storage. |
Christopher Tate | a7835b6 | 2014-07-11 17:25:57 -0700 | [diff] [blame] | 959 | * @see #openFileOutput |
| 960 | * @see #getFileStreamPath |
| 961 | * @see #getDir |
| 962 | * @see android.app.backup.BackupAgent |
| 963 | */ |
| 964 | public abstract File getNoBackupFilesDir(); |
| 965 | |
| 966 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 967 | * Returns the absolute path to the directory on the primary shared/external |
| 968 | * storage device where the application can place persistent files it owns. |
| 969 | * These files are internal to the applications, and not typically visible |
| 970 | * to the user as media. |
| 971 | * <p> |
| 972 | * This is like {@link #getFilesDir()} in that these files will be deleted |
| 973 | * when the application is uninstalled, however there are some important |
| 974 | * differences: |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 975 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 976 | * <li>Shared storage may not always be available, since removable media can |
| 977 | * be ejected by the user. Media state can be checked using |
| 978 | * {@link Environment#getExternalStorageState(File)}. |
| 979 | * <li>There is no security enforced with these files. For example, any |
| 980 | * application holding |
| 981 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 982 | * these files. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 983 | * </ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 984 | * <p> |
| 985 | * If a shared storage device is emulated (as determined by |
| 986 | * {@link Environment#isExternalStorageEmulated(File)}), it's contents are |
| 987 | * backed by a private user data partition, which means there is little |
| 988 | * benefit to storing data here instead of the private directories returned |
| 989 | * by {@link #getFilesDir()}, etc. |
| 990 | * <p> |
| 991 | * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 992 | * 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] | 993 | * accessible to the calling app. This only applies to paths generated for |
| 994 | * package name of the calling application. To access paths belonging to |
| 995 | * other packages, |
| 996 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} and/or |
| 997 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} are required. |
| 998 | * <p> |
| 999 | * On devices with multiple users (as described by {@link UserManager}), |
| 1000 | * each user has their own isolated shared storage. Applications only have |
| 1001 | * access to the shared storage for the user they're running as. |
| 1002 | * <p> |
| 1003 | * The returned path may change over time if different shared storage media |
| 1004 | * is inserted, so only relative paths should be persisted. |
| 1005 | * <p> |
| 1006 | * Here is an example of typical code to manipulate a file in an |
| 1007 | * application's shared storage: |
| 1008 | * </p> |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1009 | * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java |
| 1010 | * private_file} |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1011 | * <p> |
| 1012 | * If you supply a non-null <var>type</var> to this function, the returned |
| 1013 | * file will be a path to a sub-directory of the given type. Though these |
| 1014 | * files are not automatically scanned by the media scanner, you can |
| 1015 | * explicitly add them to the media database with |
| 1016 | * {@link android.media.MediaScannerConnection#scanFile(Context, String[], String[], android.media.MediaScannerConnection.OnScanCompletedListener) |
| 1017 | * MediaScannerConnection.scanFile}. Note that this is not the same as |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1018 | * {@link android.os.Environment#getExternalStoragePublicDirectory |
| 1019 | * Environment.getExternalStoragePublicDirectory()}, which provides |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1020 | * directories of media shared by all applications. The directories returned |
| 1021 | * here are owned by the application, and their contents will be removed |
| 1022 | * when the application is uninstalled. Unlike |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1023 | * {@link android.os.Environment#getExternalStoragePublicDirectory |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1024 | * Environment.getExternalStoragePublicDirectory()}, the directory returned |
| 1025 | * here will be automatically created for you. |
| 1026 | * <p> |
| 1027 | * Here is an example of typical code to manipulate a picture in an |
| 1028 | * application's shared storage and add it to the media database: |
| 1029 | * </p> |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1030 | * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java |
| 1031 | * private_picture} |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 1032 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1033 | * @param type The type of files directory to return. May be {@code null} |
| 1034 | * for the root of the files directory or one of the following |
| 1035 | * constants for a subdirectory: |
| 1036 | * {@link android.os.Environment#DIRECTORY_MUSIC}, |
| 1037 | * {@link android.os.Environment#DIRECTORY_PODCASTS}, |
| 1038 | * {@link android.os.Environment#DIRECTORY_RINGTONES}, |
| 1039 | * {@link android.os.Environment#DIRECTORY_ALARMS}, |
| 1040 | * {@link android.os.Environment#DIRECTORY_NOTIFICATIONS}, |
| 1041 | * {@link android.os.Environment#DIRECTORY_PICTURES}, or |
| 1042 | * {@link android.os.Environment#DIRECTORY_MOVIES}. |
| 1043 | * @return the absolute path to application-specific directory. May return |
| 1044 | * {@code null} if shared storage is not currently available. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1045 | * @see #getFilesDir |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1046 | * @see #getExternalFilesDirs(String) |
| 1047 | * @see Environment#getExternalStorageState(File) |
| 1048 | * @see Environment#isExternalStorageEmulated(File) |
| 1049 | * @see Environment#isExternalStorageRemovable(File) |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1050 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1051 | @Nullable |
| 1052 | public abstract File getExternalFilesDir(@Nullable String type); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1053 | |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1054 | /** |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1055 | * Returns absolute paths to application-specific directories on all |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1056 | * shared/external storage devices where the application can place |
| 1057 | * persistent files it owns. These files are internal to the application, |
| 1058 | * and not typically visible to the user as media. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1059 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1060 | * This is like {@link #getFilesDir()} in that these files will be deleted |
| 1061 | * when the application is uninstalled, however there are some important |
| 1062 | * differences: |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1063 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1064 | * <li>Shared storage may not always be available, since removable media can |
| 1065 | * be ejected by the user. Media state can be checked using |
| 1066 | * {@link Environment#getExternalStorageState(File)}. |
| 1067 | * <li>There is no security enforced with these files. For example, any |
| 1068 | * application holding |
| 1069 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 1070 | * these files. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1071 | * </ul> |
| 1072 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1073 | * If a shared storage device is emulated (as determined by |
| 1074 | * {@link Environment#isExternalStorageEmulated(File)}), it's contents are |
| 1075 | * backed by a private user data partition, which means there is little |
| 1076 | * benefit to storing data here instead of the private directories returned |
| 1077 | * by {@link #getFilesDir()}, etc. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1078 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1079 | * Shared storage devices returned here are considered a stable part of the |
| 1080 | * device, including physical media slots under a protective cover. The |
| 1081 | * returned paths do not include transient devices, such as USB flash drives |
| 1082 | * connected to handheld devices. |
| 1083 | * <p> |
| 1084 | * 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] | 1085 | * example, an app may choose to store large files on the device with the |
| 1086 | * most available space, as measured by {@link StatFs}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1087 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1088 | * No additional permissions are required for the calling app to read or |
| 1089 | * write files under the returned path. Write access outside of these paths |
| 1090 | * on secondary external storage devices is not available. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1091 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1092 | * The returned path may change over time if different shared storage media |
| 1093 | * is inserted, so only relative paths should be persisted. |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 1094 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1095 | * @param type The type of files directory to return. May be {@code null} |
| 1096 | * for the root of the files directory or one of the following |
| 1097 | * constants for a subdirectory: |
| 1098 | * {@link android.os.Environment#DIRECTORY_MUSIC}, |
| 1099 | * {@link android.os.Environment#DIRECTORY_PODCASTS}, |
| 1100 | * {@link android.os.Environment#DIRECTORY_RINGTONES}, |
| 1101 | * {@link android.os.Environment#DIRECTORY_ALARMS}, |
| 1102 | * {@link android.os.Environment#DIRECTORY_NOTIFICATIONS}, |
| 1103 | * {@link android.os.Environment#DIRECTORY_PICTURES}, or |
| 1104 | * {@link android.os.Environment#DIRECTORY_MOVIES}. |
| 1105 | * @return the absolute paths to application-specific directories. Some |
| 1106 | * individual paths may be {@code null} if that shared storage is |
| 1107 | * not currently available. The first path returned is the same as |
| 1108 | * {@link #getExternalFilesDir(String)}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1109 | * @see #getExternalFilesDir(String) |
Jeff Sharkey | 4ca728c | 2014-01-10 16:27:19 -0800 | [diff] [blame] | 1110 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1111 | * @see Environment#isExternalStorageEmulated(File) |
| 1112 | * @see Environment#isExternalStorageRemovable(File) |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1113 | */ |
| 1114 | public abstract File[] getExternalFilesDirs(String type); |
| 1115 | |
| 1116 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1117 | * Return the primary shared/external storage directory where this |
| 1118 | * application's OBB files (if there are any) can be found. Note if the |
| 1119 | * application does not have any OBB files, this directory may not exist. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1120 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1121 | * This is like {@link #getFilesDir()} in that these files will be deleted |
| 1122 | * when the application is uninstalled, however there are some important |
| 1123 | * differences: |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1124 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1125 | * <li>Shared storage may not always be available, since removable media can |
| 1126 | * be ejected by the user. Media state can be checked using |
| 1127 | * {@link Environment#getExternalStorageState(File)}. |
| 1128 | * <li>There is no security enforced with these files. For example, any |
| 1129 | * application holding |
| 1130 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1131 | * these files. |
| 1132 | * </ul> |
| 1133 | * <p> |
| 1134 | * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions |
Dave Friedman | cfe5088 | 2017-07-05 00:40:07 -0700 | [diff] [blame] | 1135 | * are required to read or write to the path that this method returns. |
| 1136 | * However, starting from {@link android.os.Build.VERSION_CODES#M}, |
| 1137 | * to read the OBB expansion files, you must declare the |
| 1138 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} permission in the app manifest and ask for |
| 1139 | * permission at runtime as follows: |
| 1140 | * </p> |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1141 | * <p> |
Dave Friedman | cfe5088 | 2017-07-05 00:40:07 -0700 | [diff] [blame] | 1142 | * {@code <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" |
| 1143 | * android:maxSdkVersion="23" />} |
| 1144 | * </p> |
| 1145 | * <p> |
| 1146 | * Starting from {@link android.os.Build.VERSION_CODES#N}, |
| 1147 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} |
| 1148 | * permission is not required, so don’t ask for this |
| 1149 | * permission at runtime. To handle both cases, your app must first try to read the OBB file, |
| 1150 | * and if it fails, you must request |
| 1151 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} permission at runtime. |
| 1152 | * </p> |
| 1153 | * |
| 1154 | * <p> |
| 1155 | * The following code snippet shows how to do this: |
| 1156 | * </p> |
| 1157 | * |
| 1158 | * <pre> |
| 1159 | * File obb = new File(obb_filename); |
| 1160 | * boolean open_failed = false; |
| 1161 | * |
| 1162 | * try { |
| 1163 | * BufferedReader br = new BufferedReader(new FileReader(obb)); |
| 1164 | * open_failed = false; |
| 1165 | * ReadObbFile(br); |
| 1166 | * } catch (IOException e) { |
| 1167 | * open_failed = true; |
| 1168 | * } |
| 1169 | * |
| 1170 | * if (open_failed) { |
| 1171 | * // request READ_EXTERNAL_STORAGE permission before reading OBB file |
| 1172 | * ReadObbFileWithPermission(); |
| 1173 | * } |
| 1174 | * </pre> |
| 1175 | * |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1176 | * On devices with multiple users (as described by {@link UserManager}), |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 1177 | * multiple users may share the same OBB storage location. Applications |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1178 | * should ensure that multiple instances running under different users don't |
| 1179 | * interfere with each other. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1180 | * |
| 1181 | * @return the absolute path to application-specific directory. May return |
| 1182 | * {@code null} if shared storage is not currently available. |
| 1183 | * @see #getObbDirs() |
| 1184 | * @see Environment#getExternalStorageState(File) |
| 1185 | * @see Environment#isExternalStorageEmulated(File) |
| 1186 | * @see Environment#isExternalStorageRemovable(File) |
Dianne Hackborn | 805fd7e | 2011-01-16 18:30:29 -0800 | [diff] [blame] | 1187 | */ |
| 1188 | public abstract File getObbDir(); |
| 1189 | |
| 1190 | /** |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1191 | * Returns absolute paths to application-specific directories on all |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1192 | * shared/external storage devices where the application's OBB files (if |
| 1193 | * there are any) can be found. Note if the application does not have any |
| 1194 | * OBB files, these directories may not exist. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1195 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1196 | * This is like {@link #getFilesDir()} in that these files will be deleted |
| 1197 | * when the application is uninstalled, however there are some important |
| 1198 | * differences: |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1199 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1200 | * <li>Shared storage may not always be available, since removable media can |
| 1201 | * be ejected by the user. Media state can be checked using |
| 1202 | * {@link Environment#getExternalStorageState(File)}. |
| 1203 | * <li>There is no security enforced with these files. For example, any |
| 1204 | * application holding |
| 1205 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 1206 | * these files. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1207 | * </ul> |
| 1208 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1209 | * Shared storage devices returned here are considered a stable part of the |
| 1210 | * device, including physical media slots under a protective cover. The |
| 1211 | * returned paths do not include transient devices, such as USB flash drives |
| 1212 | * connected to handheld devices. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1213 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1214 | * 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] | 1215 | * example, an app may choose to store large files on the device with the |
| 1216 | * most available space, as measured by {@link StatFs}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1217 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1218 | * No additional permissions are required for the calling app to read or |
| 1219 | * write files under the returned path. Write access outside of these paths |
| 1220 | * on secondary external storage devices is not available. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1221 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1222 | * @return the absolute paths to application-specific directories. Some |
| 1223 | * individual paths may be {@code null} if that shared storage is |
| 1224 | * not currently available. The first path returned is the same as |
| 1225 | * {@link #getObbDir()} |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1226 | * @see #getObbDir() |
Jeff Sharkey | 4ca728c | 2014-01-10 16:27:19 -0800 | [diff] [blame] | 1227 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1228 | * @see Environment#isExternalStorageEmulated(File) |
| 1229 | * @see Environment#isExternalStorageRemovable(File) |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1230 | */ |
| 1231 | public abstract File[] getObbDirs(); |
| 1232 | |
| 1233 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1234 | * Returns the absolute path to the application specific cache directory on |
Jeff Sharkey | 60a82cd | 2017-04-18 18:19:16 -0600 | [diff] [blame] | 1235 | * the filesystem. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1236 | * <p> |
Jeff Sharkey | 60a82cd | 2017-04-18 18:19:16 -0600 | [diff] [blame] | 1237 | * The system will automatically delete files in this directory as disk |
| 1238 | * space is needed elsewhere on the device. The system will always delete |
| 1239 | * older files first, as reported by {@link File#lastModified()}. If |
| 1240 | * desired, you can exert more control over how files are deleted using |
| 1241 | * {@link StorageManager#setCacheBehaviorGroup(File, boolean)} and |
| 1242 | * {@link StorageManager#setCacheBehaviorTombstone(File, boolean)}. |
| 1243 | * <p> |
| 1244 | * Apps are strongly encouraged to keep their usage of cache space below the |
| 1245 | * quota returned by |
| 1246 | * {@link StorageManager#getCacheQuotaBytes(java.util.UUID)}. If your app |
| 1247 | * goes above this quota, your cached files will be some of the first to be |
| 1248 | * deleted when additional disk space is needed. Conversely, if your app |
| 1249 | * stays under this quota, your cached files will be some of the last to be |
| 1250 | * deleted when additional disk space is needed. |
| 1251 | * <p> |
| 1252 | * Note that your cache quota will change over time depending on how |
| 1253 | * frequently the user interacts with your app, and depending on how much |
| 1254 | * system-wide disk space is used. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1255 | * <p> |
| 1256 | * The returned path may change over time if the calling app is moved to an |
| 1257 | * adopted storage device, so only relative paths should be persisted. |
| 1258 | * <p> |
| 1259 | * Apps require no extra permissions to read or write to the returned path, |
| 1260 | * since this path lives in their private storage. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1261 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1262 | * @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] | 1263 | * @see #openFileOutput |
| 1264 | * @see #getFileStreamPath |
| 1265 | * @see #getDir |
Kevin Hufnagle | e9681e1 | 2016-09-23 16:44:03 -0700 | [diff] [blame] | 1266 | * @see #getExternalCacheDir |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1267 | */ |
| 1268 | public abstract File getCacheDir(); |
| 1269 | |
| 1270 | /** |
Jeff Sharkey | 4ed745d | 2014-07-15 20:39:15 -0700 | [diff] [blame] | 1271 | * Returns the absolute path to the application specific cache directory on |
Jeff Sharkey | 60a82cd | 2017-04-18 18:19:16 -0600 | [diff] [blame] | 1272 | * the filesystem designed for storing cached code. |
| 1273 | * <p> |
| 1274 | * The system will delete any files stored in this location both when your |
| 1275 | * specific application is upgraded, and when the entire platform is |
| 1276 | * upgraded. |
Jeff Sharkey | 4ed745d | 2014-07-15 20:39:15 -0700 | [diff] [blame] | 1277 | * <p> |
| 1278 | * This location is optimal for storing compiled or optimized code generated |
| 1279 | * by your application at runtime. |
| 1280 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1281 | * The returned path may change over time if the calling app is moved to an |
| 1282 | * adopted storage device, so only relative paths should be persisted. |
| 1283 | * <p> |
Jeff Sharkey | 4ed745d | 2014-07-15 20:39:15 -0700 | [diff] [blame] | 1284 | * Apps require no extra permissions to read or write to the returned path, |
| 1285 | * since this path lives in their private storage. |
| 1286 | * |
| 1287 | * @return The path of the directory holding application code cache files. |
| 1288 | */ |
| 1289 | public abstract File getCodeCacheDir(); |
| 1290 | |
| 1291 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1292 | * Returns absolute path to application-specific directory on the primary |
| 1293 | * shared/external storage device where the application can place cache |
| 1294 | * files it owns. These files are internal to the application, and not |
| 1295 | * typically visible to the user as media. |
| 1296 | * <p> |
| 1297 | * This is like {@link #getCacheDir()} in that these files will be deleted |
| 1298 | * when the application is uninstalled, however there are some important |
| 1299 | * differences: |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1300 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1301 | * <li>The platform does not always monitor the space available in shared |
| 1302 | * storage, and thus may not automatically delete these files. Apps should |
| 1303 | * always manage the maximum space used in this location. Currently the only |
| 1304 | * time files here will be deleted by the platform is when running on |
| 1305 | * {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} or later and |
| 1306 | * {@link Environment#isExternalStorageEmulated(File)} returns true. |
| 1307 | * <li>Shared storage may not always be available, since removable media can |
| 1308 | * be ejected by the user. Media state can be checked using |
| 1309 | * {@link Environment#getExternalStorageState(File)}. |
| 1310 | * <li>There is no security enforced with these files. For example, any |
| 1311 | * application holding |
| 1312 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1313 | * these files. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1314 | * </ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1315 | * <p> |
| 1316 | * If a shared storage device is emulated (as determined by |
Kevin Hufnagle | e9681e1 | 2016-09-23 16:44:03 -0700 | [diff] [blame] | 1317 | * {@link Environment#isExternalStorageEmulated(File)}), its contents are |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1318 | * backed by a private user data partition, which means there is little |
| 1319 | * benefit to storing data here instead of the private directory returned by |
| 1320 | * {@link #getCacheDir()}. |
| 1321 | * <p> |
| 1322 | * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1323 | * 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] | 1324 | * accessible to the calling app. This only applies to paths generated for |
| 1325 | * package name of the calling application. To access paths belonging to |
| 1326 | * other packages, |
| 1327 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} and/or |
| 1328 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} are required. |
| 1329 | * <p> |
| 1330 | * On devices with multiple users (as described by {@link UserManager}), |
| 1331 | * each user has their own isolated shared storage. Applications only have |
| 1332 | * access to the shared storage for the user they're running as. |
| 1333 | * <p> |
| 1334 | * The returned path may change over time if different shared storage media |
| 1335 | * is inserted, so only relative paths should be persisted. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1336 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1337 | * @return the absolute path to application-specific directory. May return |
| 1338 | * {@code null} if shared storage is not currently available. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1339 | * @see #getCacheDir |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1340 | * @see #getExternalCacheDirs() |
| 1341 | * @see Environment#getExternalStorageState(File) |
| 1342 | * @see Environment#isExternalStorageEmulated(File) |
| 1343 | * @see Environment#isExternalStorageRemovable(File) |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1344 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1345 | @Nullable |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1346 | public abstract File getExternalCacheDir(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1347 | |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1348 | /** |
Fyodor Kupolov | 6122129 | 2016-09-02 15:21:03 -0700 | [diff] [blame] | 1349 | * Returns absolute path to application-specific directory in the preloaded cache. |
| 1350 | * <p>Files stored in the cache directory can be deleted when the device runs low on storage. |
| 1351 | * There is no guarantee when these files will be deleted. |
| 1352 | * @hide |
| 1353 | */ |
| 1354 | @Nullable |
| 1355 | @SystemApi |
| 1356 | public abstract File getPreloadsFileCache(); |
| 1357 | |
| 1358 | /** |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1359 | * Returns absolute paths to application-specific directories on all |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1360 | * shared/external storage devices where the application can place cache |
| 1361 | * files it owns. These files are internal to the application, and not |
| 1362 | * typically visible to the user as media. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1363 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1364 | * This is like {@link #getCacheDir()} in that these files will be deleted |
| 1365 | * when the application is uninstalled, however there are some important |
| 1366 | * differences: |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1367 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1368 | * <li>The platform does not always monitor the space available in shared |
| 1369 | * storage, and thus may not automatically delete these files. Apps should |
| 1370 | * always manage the maximum space used in this location. Currently the only |
| 1371 | * time files here will be deleted by the platform is when running on |
| 1372 | * {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} or later and |
| 1373 | * {@link Environment#isExternalStorageEmulated(File)} returns true. |
| 1374 | * <li>Shared storage may not always be available, since removable media can |
| 1375 | * be ejected by the user. Media state can be checked using |
| 1376 | * {@link Environment#getExternalStorageState(File)}. |
| 1377 | * <li>There is no security enforced with these files. For example, any |
| 1378 | * application holding |
| 1379 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 1380 | * these files. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1381 | * </ul> |
| 1382 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1383 | * If a shared storage device is emulated (as determined by |
| 1384 | * {@link Environment#isExternalStorageEmulated(File)}), it's contents are |
| 1385 | * backed by a private user data partition, which means there is little |
| 1386 | * benefit to storing data here instead of the private directory returned by |
| 1387 | * {@link #getCacheDir()}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1388 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1389 | * Shared storage devices returned here are considered a stable part of the |
| 1390 | * device, including physical media slots under a protective cover. The |
| 1391 | * returned paths do not include transient devices, such as USB flash drives |
| 1392 | * connected to handheld devices. |
| 1393 | * <p> |
| 1394 | * 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] | 1395 | * example, an app may choose to store large files on the device with the |
| 1396 | * most available space, as measured by {@link StatFs}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1397 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1398 | * No additional permissions are required for the calling app to read or |
| 1399 | * write files under the returned path. Write access outside of these paths |
| 1400 | * on secondary external storage devices is not available. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1401 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1402 | * The returned paths may change over time if different shared storage media |
| 1403 | * is inserted, so only relative paths should be persisted. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1404 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1405 | * @return the absolute paths to application-specific directories. Some |
| 1406 | * individual paths may be {@code null} if that shared storage is |
| 1407 | * not currently available. The first path returned is the same as |
| 1408 | * {@link #getExternalCacheDir()}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1409 | * @see #getExternalCacheDir() |
Jeff Sharkey | 4ca728c | 2014-01-10 16:27:19 -0800 | [diff] [blame] | 1410 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1411 | * @see Environment#isExternalStorageEmulated(File) |
| 1412 | * @see Environment#isExternalStorageRemovable(File) |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1413 | */ |
| 1414 | public abstract File[] getExternalCacheDirs(); |
| 1415 | |
| 1416 | /** |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1417 | * Returns absolute paths to application-specific directories on all |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1418 | * shared/external storage devices where the application can place media |
| 1419 | * files. These files are scanned and made available to other apps through |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1420 | * {@link MediaStore}. |
| 1421 | * <p> |
| 1422 | * This is like {@link #getExternalFilesDirs} in that these files will be |
| 1423 | * deleted when the application is uninstalled, however there are some |
| 1424 | * important differences: |
| 1425 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1426 | * <li>Shared storage may not always be available, since removable media can |
| 1427 | * be ejected by the user. Media state can be checked using |
| 1428 | * {@link Environment#getExternalStorageState(File)}. |
| 1429 | * <li>There is no security enforced with these files. For example, any |
| 1430 | * application holding |
| 1431 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 1432 | * these files. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1433 | * </ul> |
| 1434 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1435 | * Shared storage devices returned here are considered a stable part of the |
| 1436 | * device, including physical media slots under a protective cover. The |
| 1437 | * returned paths do not include transient devices, such as USB flash drives |
| 1438 | * connected to handheld devices. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1439 | * <p> |
| 1440 | * An application may store data on any or all of the returned devices. For |
| 1441 | * example, an app may choose to store large files on the device with the |
| 1442 | * most available space, as measured by {@link StatFs}. |
| 1443 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1444 | * No additional permissions are required for the calling app to read or |
| 1445 | * write files under the returned path. Write access outside of these paths |
| 1446 | * on secondary external storage devices is not available. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1447 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1448 | * The returned paths may change over time if different shared storage media |
| 1449 | * is inserted, so only relative paths should be persisted. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1450 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1451 | * @return the absolute paths to application-specific directories. Some |
| 1452 | * individual paths may be {@code null} if that shared storage is |
| 1453 | * not currently available. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1454 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1455 | * @see Environment#isExternalStorageEmulated(File) |
| 1456 | * @see Environment#isExternalStorageRemovable(File) |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1457 | */ |
| 1458 | public abstract File[] getExternalMediaDirs(); |
| 1459 | |
| 1460 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1461 | * Returns an array of strings naming the private files associated with |
| 1462 | * this Context's application package. |
| 1463 | * |
| 1464 | * @return Array of strings naming the private files. |
| 1465 | * |
| 1466 | * @see #openFileInput |
| 1467 | * @see #openFileOutput |
| 1468 | * @see #deleteFile |
| 1469 | */ |
| 1470 | public abstract String[] fileList(); |
| 1471 | |
| 1472 | /** |
| 1473 | * Retrieve, creating if needed, a new directory in which the application |
| 1474 | * can place its own custom data files. You can use the returned File |
| 1475 | * object to create and access files in this directory. Note that files |
| 1476 | * created through a File object will only be accessible by your own |
| 1477 | * application; you can only set the mode of the entire directory, not |
| 1478 | * of individual files. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1479 | * <p> |
| 1480 | * The returned path may change over time if the calling app is moved to an |
| 1481 | * adopted storage device, so only relative paths should be persisted. |
| 1482 | * <p> |
| 1483 | * Apps require no extra permissions to read or write to the returned path, |
| 1484 | * since this path lives in their private storage. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1485 | * |
Nick Kralevich | 92091fa | 2012-12-12 16:24:31 -0800 | [diff] [blame] | 1486 | * @param name Name of the directory to retrieve. This is a directory |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1487 | * that is created as part of your application data. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1488 | * @param mode Operating mode. |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1489 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1490 | * @return A {@link File} object for the requested directory. The directory |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1491 | * 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] | 1492 | * |
| 1493 | * @see #openFileOutput(String, int) |
| 1494 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1495 | public abstract File getDir(String name, @FileMode int mode); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1496 | |
| 1497 | /** |
| 1498 | * Open a new private SQLiteDatabase associated with this Context's |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1499 | * 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] | 1500 | * |
| 1501 | * @param name The name (unique in the application package) of the database. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1502 | * @param mode Operating mode. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1503 | * @param factory An optional factory class that is called to instantiate a |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1504 | * cursor when query is called. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1505 | * @return The contents of a newly created database with the given name. |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1506 | * @throws android.database.sqlite.SQLiteException if the database file |
| 1507 | * could not be opened. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1508 | * @see #MODE_PRIVATE |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 1509 | * @see #MODE_ENABLE_WRITE_AHEAD_LOGGING |
Sunny Goyal | a21e6b2 | 2015-12-02 09:51:02 -0800 | [diff] [blame] | 1510 | * @see #MODE_NO_LOCALIZED_COLLATORS |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1511 | * @see #deleteDatabase |
| 1512 | */ |
| 1513 | public abstract SQLiteDatabase openOrCreateDatabase(String name, |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1514 | @DatabaseMode int mode, CursorFactory factory); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1515 | |
| 1516 | /** |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1517 | * Open a new private SQLiteDatabase associated with this Context's |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1518 | * application package. Creates the database file if it doesn't exist. |
| 1519 | * <p> |
| 1520 | * Accepts input param: a concrete instance of {@link DatabaseErrorHandler} |
| 1521 | * to be used to handle corruption when sqlite reports database corruption. |
| 1522 | * </p> |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1523 | * |
| 1524 | * @param name The name (unique in the application package) of the database. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1525 | * @param mode Operating mode. |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1526 | * @param factory An optional factory class that is called to instantiate a |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1527 | * cursor when query is called. |
| 1528 | * @param errorHandler the {@link DatabaseErrorHandler} to be used when |
| 1529 | * sqlite reports database corruption. if null, |
| 1530 | * {@link android.database.DefaultDatabaseErrorHandler} is |
| 1531 | * assumed. |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1532 | * @return The contents of a newly created database with the given name. |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1533 | * @throws android.database.sqlite.SQLiteException if the database file |
| 1534 | * could not be opened. |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1535 | * @see #MODE_PRIVATE |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 1536 | * @see #MODE_ENABLE_WRITE_AHEAD_LOGGING |
Sunny Goyal | a21e6b2 | 2015-12-02 09:51:02 -0800 | [diff] [blame] | 1537 | * @see #MODE_NO_LOCALIZED_COLLATORS |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1538 | * @see #deleteDatabase |
| 1539 | */ |
| 1540 | public abstract SQLiteDatabase openOrCreateDatabase(String name, |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1541 | @DatabaseMode int mode, CursorFactory factory, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1542 | @Nullable DatabaseErrorHandler errorHandler); |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1543 | |
| 1544 | /** |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 1545 | * Move an existing database file from the given source storage context to |
| 1546 | * this context. This is typically used to migrate data between storage |
| 1547 | * locations after an upgrade, such as migrating to device protected |
| 1548 | * storage. |
Jeff Sharkey | d21cad1 | 2016-05-20 11:30:07 -0600 | [diff] [blame] | 1549 | * <p> |
| 1550 | * The database must be closed before being moved. |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 1551 | * |
| 1552 | * @param sourceContext The source context which contains the existing |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 1553 | * database to move. |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 1554 | * @param name The name of the database file. |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 1555 | * @return {@code true} if the move was successful or if the database didn't |
| 1556 | * exist in the source context, otherwise {@code false}. |
| 1557 | * @see #createDeviceProtectedStorageContext() |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 1558 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 1559 | public abstract boolean moveDatabaseFrom(Context sourceContext, String name); |
| 1560 | |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 1561 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1562 | * Delete an existing private SQLiteDatabase associated with this Context's |
| 1563 | * application package. |
| 1564 | * |
| 1565 | * @param name The name (unique in the application package) of the |
| 1566 | * database. |
| 1567 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1568 | * @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] | 1569 | * |
| 1570 | * @see #openOrCreateDatabase |
| 1571 | */ |
| 1572 | public abstract boolean deleteDatabase(String name); |
| 1573 | |
| 1574 | /** |
| 1575 | * Returns the absolute path on the filesystem where a database created with |
| 1576 | * {@link #openOrCreateDatabase} is stored. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1577 | * <p> |
| 1578 | * The returned path may change over time if the calling app is moved to an |
| 1579 | * 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] | 1580 | * |
| 1581 | * @param name The name of the database for which you would like to get |
| 1582 | * its path. |
| 1583 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1584 | * @return An absolute path to the given database. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1585 | * |
| 1586 | * @see #openOrCreateDatabase |
| 1587 | */ |
| 1588 | public abstract File getDatabasePath(String name); |
| 1589 | |
| 1590 | /** |
| 1591 | * Returns an array of strings naming the private databases associated with |
| 1592 | * this Context's application package. |
| 1593 | * |
| 1594 | * @return Array of strings naming the private databases. |
| 1595 | * |
| 1596 | * @see #openOrCreateDatabase |
| 1597 | * @see #deleteDatabase |
| 1598 | */ |
| 1599 | public abstract String[] databaseList(); |
| 1600 | |
| 1601 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1602 | * @deprecated Use {@link android.app.WallpaperManager#getDrawable |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1603 | * WallpaperManager.get()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1604 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1605 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1606 | public abstract Drawable getWallpaper(); |
| 1607 | |
| 1608 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1609 | * @deprecated Use {@link android.app.WallpaperManager#peekDrawable |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1610 | * WallpaperManager.peek()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1611 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1612 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1613 | public abstract Drawable peekWallpaper(); |
| 1614 | |
| 1615 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1616 | * @deprecated Use {@link android.app.WallpaperManager#getDesiredMinimumWidth() |
| 1617 | * WallpaperManager.getDesiredMinimumWidth()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1618 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1619 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1620 | public abstract int getWallpaperDesiredMinimumWidth(); |
| 1621 | |
| 1622 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1623 | * @deprecated Use {@link android.app.WallpaperManager#getDesiredMinimumHeight() |
| 1624 | * WallpaperManager.getDesiredMinimumHeight()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1625 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1626 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1627 | public abstract int getWallpaperDesiredMinimumHeight(); |
| 1628 | |
| 1629 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1630 | * @deprecated Use {@link android.app.WallpaperManager#setBitmap(Bitmap) |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1631 | * WallpaperManager.set()} instead. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 1632 | * <p>This method requires the caller to hold the permission |
| 1633 | * {@link android.Manifest.permission#SET_WALLPAPER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1634 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1635 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1636 | public abstract void setWallpaper(Bitmap bitmap) throws IOException; |
| 1637 | |
| 1638 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1639 | * @deprecated Use {@link android.app.WallpaperManager#setStream(InputStream) |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1640 | * WallpaperManager.set()} instead. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 1641 | * <p>This method requires the caller to hold the permission |
| 1642 | * {@link android.Manifest.permission#SET_WALLPAPER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1643 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1644 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1645 | public abstract void setWallpaper(InputStream data) throws IOException; |
| 1646 | |
| 1647 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1648 | * @deprecated Use {@link android.app.WallpaperManager#clear |
| 1649 | * WallpaperManager.clear()} instead. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 1650 | * <p>This method requires the caller to hold the permission |
| 1651 | * {@link android.Manifest.permission#SET_WALLPAPER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1652 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1653 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1654 | public abstract void clearWallpaper() throws IOException; |
| 1655 | |
| 1656 | /** |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1657 | * Same as {@link #startActivity(Intent, Bundle)} with no options |
| 1658 | * specified. |
| 1659 | * |
| 1660 | * @param intent The description of the activity to start. |
| 1661 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1662 | * @throws ActivityNotFoundException |
Svet Ganov | 1ed0e55 | 2015-06-11 01:15:43 -0700 | [diff] [blame] | 1663 | *` |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1664 | * @see #startActivity(Intent, Bundle) |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1665 | * @see PackageManager#resolveActivity |
| 1666 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1667 | public abstract void startActivity(@RequiresPermission Intent intent); |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1668 | |
| 1669 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1670 | * Version of {@link #startActivity(Intent)} that allows you to specify the |
| 1671 | * 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] | 1672 | * that are not pre-installed on the system image. |
Amith Yamasani | 8264408 | 2012-08-03 13:09:11 -0700 | [diff] [blame] | 1673 | * @param intent The description of the activity to start. |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 1674 | * @param user The UserHandle of the user to start this activity for. |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1675 | * @throws ActivityNotFoundException |
Amith Yamasani | 8264408 | 2012-08-03 13:09:11 -0700 | [diff] [blame] | 1676 | * @hide |
| 1677 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 1678 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1679 | public void startActivityAsUser(@RequiresPermission Intent intent, UserHandle user) { |
Amith Yamasani | 8264408 | 2012-08-03 13:09:11 -0700 | [diff] [blame] | 1680 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 1681 | } |
| 1682 | |
| 1683 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1684 | * Launch a new activity. You will not receive any information about when |
| 1685 | * the activity exits. |
| 1686 | * |
| 1687 | * <p>Note that if this method is being called from outside of an |
| 1688 | * {@link android.app.Activity} Context, then the Intent must include |
| 1689 | * the {@link Intent#FLAG_ACTIVITY_NEW_TASK} launch flag. This is because, |
| 1690 | * without being started from an existing Activity, there is no existing |
| 1691 | * task in which to place the new activity and thus it needs to be placed |
| 1692 | * in its own separate task. |
| 1693 | * |
| 1694 | * <p>This method throws {@link ActivityNotFoundException} |
| 1695 | * if there was no Activity found to run the given Intent. |
| 1696 | * |
| 1697 | * @param intent The description of the activity to start. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1698 | * @param options Additional options for how the Activity should be started. |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 1699 | * May be null if there are no options. See {@link android.app.ActivityOptions} |
| 1700 | * for how to build the Bundle supplied here; there are no supported definitions |
| 1701 | * for building it manually. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1702 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1703 | * @throws ActivityNotFoundException |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1704 | * |
Scott Main | 60dd520 | 2012-06-23 00:01:22 -0700 | [diff] [blame] | 1705 | * @see #startActivity(Intent) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1706 | * @see PackageManager#resolveActivity |
| 1707 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1708 | public abstract void startActivity(@RequiresPermission Intent intent, |
| 1709 | @Nullable Bundle options); |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1710 | |
| 1711 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1712 | * Version of {@link #startActivity(Intent, Bundle)} that allows you to specify the |
| 1713 | * 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] | 1714 | * that are not pre-installed on the system image. |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 1715 | * @param intent The description of the activity to start. |
| 1716 | * @param options Additional options for how the Activity should be started. |
| 1717 | * May be null if there are no options. See {@link android.app.ActivityOptions} |
| 1718 | * for how to build the Bundle supplied here; there are no supported definitions |
| 1719 | * for building it manually. |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 1720 | * @param userId The UserHandle of the user to start this activity for. |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1721 | * @throws ActivityNotFoundException |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 1722 | * @hide |
| 1723 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 1724 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1725 | public void startActivityAsUser(@RequiresPermission Intent intent, @Nullable Bundle options, |
| 1726 | UserHandle userId) { |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 1727 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 1728 | } |
| 1729 | |
| 1730 | /** |
Clara Bayarri | d5bf3ed | 2015-03-27 17:32:45 +0000 | [diff] [blame] | 1731 | * Version of {@link #startActivity(Intent, Bundle)} that returns a result to the caller. This |
| 1732 | * is only supported for Views and Fragments. |
| 1733 | * @param who The identifier for the calling element that will receive the result. |
| 1734 | * @param intent The intent to start. |
| 1735 | * @param requestCode The code that will be returned with onActivityResult() identifying this |
| 1736 | * request. |
| 1737 | * @param options Additional options for how the Activity should be started. |
| 1738 | * May be null if there are no options. See {@link android.app.ActivityOptions} |
| 1739 | * for how to build the Bundle supplied here; there are no supported definitions |
| 1740 | * for building it manually. |
| 1741 | * @hide |
| 1742 | */ |
| 1743 | public void startActivityForResult( |
| 1744 | @NonNull String who, Intent intent, int requestCode, @Nullable Bundle options) { |
| 1745 | throw new RuntimeException("This method is only implemented for Activity-based Contexts. " |
| 1746 | + "Check canStartActivityForResult() before calling."); |
| 1747 | } |
| 1748 | |
| 1749 | /** |
| 1750 | * Identifies whether this Context instance will be able to process calls to |
| 1751 | * {@link #startActivityForResult(String, Intent, int, Bundle)}. |
| 1752 | * @hide |
| 1753 | */ |
| 1754 | public boolean canStartActivityForResult() { |
| 1755 | return false; |
| 1756 | } |
| 1757 | |
| 1758 | /** |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1759 | * Same as {@link #startActivities(Intent[], Bundle)} with no options |
| 1760 | * specified. |
| 1761 | * |
| 1762 | * @param intents An array of Intents to be started. |
| 1763 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1764 | * @throws ActivityNotFoundException |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1765 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1766 | * @see #startActivities(Intent[], Bundle) |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1767 | * @see PackageManager#resolveActivity |
| 1768 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1769 | public abstract void startActivities(@RequiresPermission Intent[] intents); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1770 | |
| 1771 | /** |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1772 | * Launch multiple new activities. This is generally the same as calling |
| 1773 | * {@link #startActivity(Intent)} for the first Intent in the array, |
| 1774 | * that activity during its creation calling {@link #startActivity(Intent)} |
| 1775 | * for the second entry, etc. Note that unlike that approach, generally |
| 1776 | * none of the activities except the last in the array will be created |
| 1777 | * at this point, but rather will be created when the user first visits |
| 1778 | * them (due to pressing back from the activity on top). |
| 1779 | * |
| 1780 | * <p>This method throws {@link ActivityNotFoundException} |
| 1781 | * if there was no Activity found for <em>any</em> given Intent. In this |
| 1782 | * case the state of the activity stack is undefined (some Intents in the |
| 1783 | * list may be on it, some not), so you probably want to avoid such situations. |
| 1784 | * |
| 1785 | * @param intents An array of Intents to be started. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1786 | * @param options Additional options for how the Activity should be started. |
Elliot Waite | 54de774 | 2017-01-11 15:30:35 -0800 | [diff] [blame] | 1787 | * See {@link android.content.Context#startActivity(Intent, Bundle)} |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 1788 | * Context.startActivity(Intent, Bundle)} for more details. |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1789 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1790 | * @throws ActivityNotFoundException |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1791 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1792 | * @see #startActivities(Intent[]) |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1793 | * @see PackageManager#resolveActivity |
| 1794 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1795 | public abstract void startActivities(@RequiresPermission Intent[] intents, Bundle options); |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1796 | |
| 1797 | /** |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1798 | * @hide |
| 1799 | * Launch multiple new activities. This is generally the same as calling |
| 1800 | * {@link #startActivity(Intent)} for the first Intent in the array, |
| 1801 | * that activity during its creation calling {@link #startActivity(Intent)} |
| 1802 | * for the second entry, etc. Note that unlike that approach, generally |
| 1803 | * none of the activities except the last in the array will be created |
| 1804 | * at this point, but rather will be created when the user first visits |
| 1805 | * them (due to pressing back from the activity on top). |
| 1806 | * |
| 1807 | * <p>This method throws {@link ActivityNotFoundException} |
| 1808 | * if there was no Activity found for <em>any</em> given Intent. In this |
| 1809 | * case the state of the activity stack is undefined (some Intents in the |
| 1810 | * list may be on it, some not), so you probably want to avoid such situations. |
| 1811 | * |
| 1812 | * @param intents An array of Intents to be started. |
| 1813 | * @param options Additional options for how the Activity should be started. |
| 1814 | * @param userHandle The user for whom to launch the activities |
Elliot Waite | 54de774 | 2017-01-11 15:30:35 -0800 | [diff] [blame] | 1815 | * See {@link android.content.Context#startActivity(Intent, Bundle)} |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1816 | * Context.startActivity(Intent, Bundle)} for more details. |
| 1817 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1818 | * @throws ActivityNotFoundException |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1819 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1820 | * @see #startActivities(Intent[]) |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1821 | * @see PackageManager#resolveActivity |
| 1822 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 1823 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1824 | public void startActivitiesAsUser(Intent[] intents, Bundle options, UserHandle userHandle) { |
| 1825 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 1826 | } |
| 1827 | |
| 1828 | /** |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1829 | * Same as {@link #startIntentSender(IntentSender, Intent, int, int, int, Bundle)} |
| 1830 | * with no options specified. |
| 1831 | * |
| 1832 | * @param intent The IntentSender to launch. |
| 1833 | * @param fillInIntent If non-null, this will be provided as the |
| 1834 | * intent parameter to {@link IntentSender#sendIntent}. |
| 1835 | * @param flagsMask Intent flags in the original IntentSender that you |
| 1836 | * would like to change. |
| 1837 | * @param flagsValues Desired values for any bits set in |
| 1838 | * <var>flagsMask</var> |
| 1839 | * @param extraFlags Always set to 0. |
| 1840 | * |
| 1841 | * @see #startActivity(Intent) |
| 1842 | * @see #startIntentSender(IntentSender, Intent, int, int, int, Bundle) |
| 1843 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1844 | public abstract void startIntentSender(IntentSender intent, @Nullable Intent fillInIntent, |
| 1845 | @Intent.MutableFlags int flagsMask, @Intent.MutableFlags int flagsValues, |
| 1846 | int extraFlags) throws IntentSender.SendIntentException; |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1847 | |
| 1848 | /** |
| 1849 | * Like {@link #startActivity(Intent, Bundle)}, but taking a IntentSender |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1850 | * 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] | 1851 | * as if you had called the regular {@link #startActivity(Intent)} |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1852 | * here; otherwise, its associated action will be executed (such as |
| 1853 | * sending a broadcast) as if you had called |
| 1854 | * {@link IntentSender#sendIntent IntentSender.sendIntent} on it. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1855 | * |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1856 | * @param intent The IntentSender to launch. |
| 1857 | * @param fillInIntent If non-null, this will be provided as the |
| 1858 | * intent parameter to {@link IntentSender#sendIntent}. |
| 1859 | * @param flagsMask Intent flags in the original IntentSender that you |
| 1860 | * would like to change. |
| 1861 | * @param flagsValues Desired values for any bits set in |
| 1862 | * <var>flagsMask</var> |
| 1863 | * @param extraFlags Always set to 0. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1864 | * @param options Additional options for how the Activity should be started. |
Elliot Waite | 54de774 | 2017-01-11 15:30:35 -0800 | [diff] [blame] | 1865 | * See {@link android.content.Context#startActivity(Intent, Bundle)} |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 1866 | * Context.startActivity(Intent, Bundle)} for more details. If options |
| 1867 | * have also been supplied by the IntentSender, options given here will |
| 1868 | * override any that conflict with those given by the IntentSender. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1869 | * |
| 1870 | * @see #startActivity(Intent, Bundle) |
| 1871 | * @see #startIntentSender(IntentSender, Intent, int, int, int) |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1872 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1873 | public abstract void startIntentSender(IntentSender intent, @Nullable Intent fillInIntent, |
| 1874 | @Intent.MutableFlags int flagsMask, @Intent.MutableFlags int flagsValues, |
| 1875 | int extraFlags, @Nullable Bundle options) throws IntentSender.SendIntentException; |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1876 | |
| 1877 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1878 | * Broadcast the given intent to all interested BroadcastReceivers. This |
| 1879 | * call is asynchronous; it returns immediately, and you will continue |
| 1880 | * executing while the receivers are run. No results are propagated from |
| 1881 | * receivers and receivers can not abort the broadcast. If you want |
| 1882 | * to allow receivers to propagate results or abort the broadcast, you must |
| 1883 | * send an ordered broadcast using |
| 1884 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 1885 | * |
| 1886 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1887 | * |
| 1888 | * @param intent The Intent to broadcast; all receivers matching this |
| 1889 | * Intent will receive the broadcast. |
| 1890 | * |
| 1891 | * @see android.content.BroadcastReceiver |
| 1892 | * @see #registerReceiver |
| 1893 | * @see #sendBroadcast(Intent, String) |
| 1894 | * @see #sendOrderedBroadcast(Intent, String) |
| 1895 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 1896 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1897 | public abstract void sendBroadcast(@RequiresPermission Intent intent); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1898 | |
| 1899 | /** |
| 1900 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
| 1901 | * an optional required permission to be enforced. This |
| 1902 | * call is asynchronous; it returns immediately, and you will continue |
| 1903 | * executing while the receivers are run. No results are propagated from |
| 1904 | * receivers and receivers can not abort the broadcast. If you want |
| 1905 | * to allow receivers to propagate results or abort the broadcast, you must |
| 1906 | * send an ordered broadcast using |
| 1907 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 1908 | * |
| 1909 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1910 | * |
| 1911 | * @param intent The Intent to broadcast; all receivers matching this |
| 1912 | * Intent will receive the broadcast. |
Brad Fitzpatrick | 26b71be | 2010-12-07 14:52:58 -0800 | [diff] [blame] | 1913 | * @param receiverPermission (optional) String naming a permission that |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1914 | * a receiver must hold in order to receive your broadcast. |
| 1915 | * If null, no permission is required. |
| 1916 | * |
| 1917 | * @see android.content.BroadcastReceiver |
| 1918 | * @see #registerReceiver |
| 1919 | * @see #sendBroadcast(Intent) |
| 1920 | * @see #sendOrderedBroadcast(Intent, String) |
| 1921 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 1922 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1923 | public abstract void sendBroadcast(@RequiresPermission Intent intent, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1924 | @Nullable String receiverPermission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1925 | |
Fyodor Kupolov | d4fd8c7 | 2015-07-13 19:19:25 -0700 | [diff] [blame] | 1926 | |
| 1927 | /** |
| 1928 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
| 1929 | * an array of required permissions to be enforced. This call is asynchronous; it returns |
| 1930 | * immediately, and you will continue executing while the receivers are run. No results are |
| 1931 | * propagated from receivers and receivers can not abort the broadcast. If you want to allow |
| 1932 | * receivers to propagate results or abort the broadcast, you must send an ordered broadcast |
| 1933 | * using {@link #sendOrderedBroadcast(Intent, String)}. |
| 1934 | * |
| 1935 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1936 | * |
| 1937 | * @param intent The Intent to broadcast; all receivers matching this |
| 1938 | * Intent will receive the broadcast. |
| 1939 | * @param receiverPermissions Array of names of permissions that a receiver must hold |
| 1940 | * in order to receive your broadcast. |
| 1941 | * If null or empty, no permissions are required. |
| 1942 | * |
| 1943 | * @see android.content.BroadcastReceiver |
| 1944 | * @see #registerReceiver |
| 1945 | * @see #sendBroadcast(Intent) |
| 1946 | * @see #sendOrderedBroadcast(Intent, String) |
| 1947 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 1948 | * @hide |
| 1949 | */ |
| 1950 | public abstract void sendBroadcastMultiplePermissions(Intent intent, |
| 1951 | String[] receiverPermissions); |
| 1952 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1953 | /** |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 1954 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
| 1955 | * an optional required permission to be enforced. This |
| 1956 | * call is asynchronous; it returns immediately, and you will continue |
| 1957 | * executing while the receivers are run. No results are propagated from |
| 1958 | * receivers and receivers can not abort the broadcast. If you want |
| 1959 | * to allow receivers to propagate results or abort the broadcast, you must |
| 1960 | * send an ordered broadcast using |
| 1961 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 1962 | * |
| 1963 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1964 | * |
| 1965 | * @param intent The Intent to broadcast; all receivers matching this |
| 1966 | * Intent will receive the broadcast. |
| 1967 | * @param receiverPermission (optional) String naming a permission that |
| 1968 | * a receiver must hold in order to receive your broadcast. |
| 1969 | * If null, no permission is required. |
| 1970 | * @param options (optional) Additional sending options, generated from a |
| 1971 | * {@link android.app.BroadcastOptions}. |
| 1972 | * |
| 1973 | * @see android.content.BroadcastReceiver |
| 1974 | * @see #registerReceiver |
| 1975 | * @see #sendBroadcast(Intent) |
| 1976 | * @see #sendOrderedBroadcast(Intent, String) |
| 1977 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 1978 | * @hide |
| 1979 | */ |
| 1980 | @SystemApi |
| 1981 | public abstract void sendBroadcast(Intent intent, |
| 1982 | @Nullable String receiverPermission, |
| 1983 | @Nullable Bundle options); |
| 1984 | |
| 1985 | /** |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 1986 | * Like {@link #sendBroadcast(Intent, String)}, but also allows specification |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1987 | * of an associated app op as per {@link android.app.AppOpsManager}. |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 1988 | * @hide |
| 1989 | */ |
| 1990 | public abstract void sendBroadcast(Intent intent, |
| 1991 | String receiverPermission, int appOp); |
| 1992 | |
| 1993 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1994 | * Broadcast the given intent to all interested BroadcastReceivers, delivering |
| 1995 | * them one at a time to allow more preferred receivers to consume the |
| 1996 | * broadcast before it is delivered to less preferred receivers. This |
| 1997 | * call is asynchronous; it returns immediately, and you will continue |
| 1998 | * executing while the receivers are run. |
| 1999 | * |
| 2000 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2001 | * |
| 2002 | * @param intent The Intent to broadcast; all receivers matching this |
| 2003 | * Intent will receive the broadcast. |
| 2004 | * @param receiverPermission (optional) String naming a permissions that |
| 2005 | * a receiver must hold in order to receive your broadcast. |
| 2006 | * If null, no permission is required. |
| 2007 | * |
| 2008 | * @see android.content.BroadcastReceiver |
| 2009 | * @see #registerReceiver |
| 2010 | * @see #sendBroadcast(Intent) |
| 2011 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2012 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2013 | public abstract void sendOrderedBroadcast(@RequiresPermission Intent intent, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2014 | @Nullable String receiverPermission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2015 | |
| 2016 | /** |
| 2017 | * Version of {@link #sendBroadcast(Intent)} that allows you to |
| 2018 | * receive data back from the broadcast. This is accomplished by |
| 2019 | * supplying your own BroadcastReceiver when calling, which will be |
| 2020 | * treated as a final receiver at the end of the broadcast -- its |
| 2021 | * {@link BroadcastReceiver#onReceive} method will be called with |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2022 | * 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] | 2023 | * be serialized in the same way as calling |
| 2024 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2025 | * |
| 2026 | * <p>Like {@link #sendBroadcast(Intent)}, this method is |
| 2027 | * asynchronous; it will return before |
| 2028 | * resultReceiver.onReceive() is called. |
| 2029 | * |
| 2030 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2031 | * |
| 2032 | * @param intent The Intent to broadcast; all receivers matching this |
| 2033 | * Intent will receive the broadcast. |
| 2034 | * @param receiverPermission String naming a permissions that |
| 2035 | * a receiver must hold in order to receive your broadcast. |
| 2036 | * If null, no permission is required. |
| 2037 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2038 | * receiver of the broadcast. |
| 2039 | * @param scheduler A custom Handler with which to schedule the |
| 2040 | * resultReceiver callback; if null it will be |
| 2041 | * scheduled in the Context's main thread. |
| 2042 | * @param initialCode An initial value for the result code. Often |
| 2043 | * Activity.RESULT_OK. |
| 2044 | * @param initialData An initial value for the result data. Often |
| 2045 | * null. |
| 2046 | * @param initialExtras An initial value for the result extras. Often |
| 2047 | * null. |
| 2048 | * |
| 2049 | * @see #sendBroadcast(Intent) |
| 2050 | * @see #sendBroadcast(Intent, String) |
| 2051 | * @see #sendOrderedBroadcast(Intent, String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2052 | * @see android.content.BroadcastReceiver |
| 2053 | * @see #registerReceiver |
| 2054 | * @see android.app.Activity#RESULT_OK |
| 2055 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2056 | public abstract void sendOrderedBroadcast(@RequiresPermission @NonNull Intent intent, |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 2057 | @Nullable String receiverPermission, @Nullable BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2058 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2059 | @Nullable Bundle initialExtras); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2060 | |
| 2061 | /** |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 2062 | * Version of {@link #sendBroadcast(Intent)} that allows you to |
| 2063 | * receive data back from the broadcast. This is accomplished by |
| 2064 | * supplying your own BroadcastReceiver when calling, which will be |
| 2065 | * treated as a final receiver at the end of the broadcast -- its |
| 2066 | * {@link BroadcastReceiver#onReceive} method will be called with |
| 2067 | * the result values collected from the other receivers. The broadcast will |
| 2068 | * be serialized in the same way as calling |
| 2069 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2070 | * |
| 2071 | * <p>Like {@link #sendBroadcast(Intent)}, this method is |
| 2072 | * asynchronous; it will return before |
| 2073 | * resultReceiver.onReceive() is called. |
| 2074 | * |
| 2075 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2076 | * |
| 2077 | * |
| 2078 | * @param intent The Intent to broadcast; all receivers matching this |
| 2079 | * Intent will receive the broadcast. |
| 2080 | * @param receiverPermission String naming a permissions that |
| 2081 | * a receiver must hold in order to receive your broadcast. |
| 2082 | * If null, no permission is required. |
| 2083 | * @param options (optional) Additional sending options, generated from a |
| 2084 | * {@link android.app.BroadcastOptions}. |
| 2085 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2086 | * receiver of the broadcast. |
| 2087 | * @param scheduler A custom Handler with which to schedule the |
| 2088 | * resultReceiver callback; if null it will be |
| 2089 | * scheduled in the Context's main thread. |
| 2090 | * @param initialCode An initial value for the result code. Often |
| 2091 | * Activity.RESULT_OK. |
| 2092 | * @param initialData An initial value for the result data. Often |
| 2093 | * null. |
| 2094 | * @param initialExtras An initial value for the result extras. Often |
| 2095 | * null. |
| 2096 | * @see #sendBroadcast(Intent) |
| 2097 | * @see #sendBroadcast(Intent, String) |
| 2098 | * @see #sendOrderedBroadcast(Intent, String) |
| 2099 | * @see android.content.BroadcastReceiver |
| 2100 | * @see #registerReceiver |
| 2101 | * @see android.app.Activity#RESULT_OK |
| 2102 | * @hide |
| 2103 | */ |
| 2104 | @SystemApi |
| 2105 | public abstract void sendOrderedBroadcast(@NonNull Intent intent, |
| 2106 | @Nullable String receiverPermission, @Nullable Bundle options, |
| 2107 | @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, |
| 2108 | int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras); |
| 2109 | |
| 2110 | /** |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2111 | * Like {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, android.os.Handler, |
| 2112 | * int, String, android.os.Bundle)}, but also allows specification |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2113 | * of an associated app op as per {@link android.app.AppOpsManager}. |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2114 | * @hide |
| 2115 | */ |
| 2116 | public abstract void sendOrderedBroadcast(Intent intent, |
| 2117 | String receiverPermission, int appOp, BroadcastReceiver resultReceiver, |
| 2118 | Handler scheduler, int initialCode, String initialData, |
| 2119 | Bundle initialExtras); |
| 2120 | |
| 2121 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2122 | * Version of {@link #sendBroadcast(Intent)} that allows you to specify the |
| 2123 | * 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] | 2124 | * that are not pre-installed on the system image. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2125 | * @param intent The intent to broadcast |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 2126 | * @param user UserHandle to send the intent to. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2127 | * @see #sendBroadcast(Intent) |
| 2128 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2129 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2130 | public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent, |
| 2131 | UserHandle user); |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2132 | |
| 2133 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2134 | * Version of {@link #sendBroadcast(Intent, String)} that allows you to specify the |
| 2135 | * 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] | 2136 | * that are not pre-installed on the system image. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2137 | * |
| 2138 | * @param intent The Intent to broadcast; all receivers matching this |
| 2139 | * Intent will receive the broadcast. |
| 2140 | * @param user UserHandle to send the intent to. |
| 2141 | * @param receiverPermission (optional) String naming a permission that |
| 2142 | * a receiver must hold in order to receive your broadcast. |
| 2143 | * If null, no permission is required. |
| 2144 | * |
| 2145 | * @see #sendBroadcast(Intent, String) |
| 2146 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2147 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2148 | public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent, |
| 2149 | UserHandle user, @Nullable String receiverPermission); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2150 | |
Chad Brubaker | 52c8edc | 2016-07-25 14:30:26 -0700 | [diff] [blame] | 2151 | /** |
| 2152 | * Version of {@link #sendBroadcast(Intent, String, Bundle)} that allows you to specify the |
| 2153 | * 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] | 2154 | * that are not pre-installed on the system image. |
Chad Brubaker | 52c8edc | 2016-07-25 14:30:26 -0700 | [diff] [blame] | 2155 | * |
| 2156 | * @param intent The Intent to broadcast; all receivers matching this |
| 2157 | * Intent will receive the broadcast. |
| 2158 | * @param user UserHandle to send the intent to. |
| 2159 | * @param receiverPermission (optional) String naming a permission that |
| 2160 | * a receiver must hold in order to receive your broadcast. |
| 2161 | * If null, no permission is required. |
| 2162 | * @param options (optional) Additional sending options, generated from a |
| 2163 | * {@link android.app.BroadcastOptions}. |
| 2164 | * |
| 2165 | * @see #sendBroadcast(Intent, String, Bundle) |
| 2166 | * @hide |
| 2167 | */ |
| 2168 | @SystemApi |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2169 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Chad Brubaker | 52c8edc | 2016-07-25 14:30:26 -0700 | [diff] [blame] | 2170 | public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent, |
| 2171 | UserHandle user, @Nullable String receiverPermission, @Nullable Bundle options); |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 2172 | |
| 2173 | /** |
| 2174 | * Version of {@link #sendBroadcast(Intent, String)} that allows you to specify the |
| 2175 | * 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] | 2176 | * that are not pre-installed on the system image. |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 2177 | * |
| 2178 | * @param intent The Intent to broadcast; all receivers matching this |
| 2179 | * Intent will receive the broadcast. |
| 2180 | * @param user UserHandle to send the intent to. |
| 2181 | * @param receiverPermission (optional) String naming a permission that |
| 2182 | * a receiver must hold in order to receive your broadcast. |
| 2183 | * If null, no permission is required. |
| 2184 | * @param appOp The app op associated with the broadcast. |
| 2185 | * |
| 2186 | * @see #sendBroadcast(Intent, String) |
| 2187 | * |
| 2188 | * @hide |
| 2189 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2190 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2191 | public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent, |
| 2192 | UserHandle user, @Nullable String receiverPermission, int appOp); |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 2193 | |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2194 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2195 | * Version of |
| 2196 | * {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)} |
| 2197 | * that allows you to specify the |
| 2198 | * 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] | 2199 | * that are not pre-installed on the system image. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2200 | * |
| 2201 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2202 | * |
| 2203 | * @param intent The Intent to broadcast; all receivers matching this |
| 2204 | * Intent will receive the broadcast. |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 2205 | * @param user UserHandle to send the intent to. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2206 | * @param receiverPermission String naming a permissions that |
| 2207 | * a receiver must hold in order to receive your broadcast. |
| 2208 | * If null, no permission is required. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2209 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2210 | * receiver of the broadcast. |
| 2211 | * @param scheduler A custom Handler with which to schedule the |
| 2212 | * resultReceiver callback; if null it will be |
| 2213 | * scheduled in the Context's main thread. |
| 2214 | * @param initialCode An initial value for the result code. Often |
| 2215 | * Activity.RESULT_OK. |
| 2216 | * @param initialData An initial value for the result data. Often |
| 2217 | * null. |
| 2218 | * @param initialExtras An initial value for the result extras. Often |
| 2219 | * null. |
| 2220 | * |
| 2221 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2222 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2223 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2224 | public abstract void sendOrderedBroadcastAsUser(@RequiresPermission Intent intent, |
| 2225 | UserHandle user, @Nullable String receiverPermission, BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2226 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2227 | @Nullable Bundle initialExtras); |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2228 | |
| 2229 | /** |
Amith Yamasani | 3cf7572 | 2014-05-16 12:37:29 -0700 | [diff] [blame] | 2230 | * Similar to above but takes an appOp as well, to enforce restrictions. |
| 2231 | * @see #sendOrderedBroadcastAsUser(Intent, UserHandle, String, |
| 2232 | * BroadcastReceiver, Handler, int, String, Bundle) |
| 2233 | * @hide |
| 2234 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2235 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Amith Yamasani | 3cf7572 | 2014-05-16 12:37:29 -0700 | [diff] [blame] | 2236 | public abstract void sendOrderedBroadcastAsUser(Intent intent, UserHandle user, |
| 2237 | @Nullable String receiverPermission, int appOp, BroadcastReceiver resultReceiver, |
| 2238 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2239 | @Nullable Bundle initialExtras); |
| 2240 | |
| 2241 | /** |
Dianne Hackborn | fd854ee | 2015-07-13 18:00:37 -0700 | [diff] [blame] | 2242 | * Similar to above but takes an appOp as well, to enforce restrictions, and an options Bundle. |
| 2243 | * @see #sendOrderedBroadcastAsUser(Intent, UserHandle, String, |
| 2244 | * BroadcastReceiver, Handler, int, String, Bundle) |
| 2245 | * @hide |
| 2246 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2247 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Dianne Hackborn | fd854ee | 2015-07-13 18:00:37 -0700 | [diff] [blame] | 2248 | public abstract void sendOrderedBroadcastAsUser(Intent intent, UserHandle user, |
| 2249 | @Nullable String receiverPermission, int appOp, @Nullable Bundle options, |
| 2250 | BroadcastReceiver resultReceiver, @Nullable Handler scheduler, int initialCode, |
| 2251 | @Nullable String initialData, @Nullable Bundle initialExtras); |
| 2252 | |
| 2253 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2254 | * <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] | 2255 | * Intent you are sending stays around after the broadcast is complete, |
| 2256 | * so that others can quickly retrieve that data through the return |
| 2257 | * value of {@link #registerReceiver(BroadcastReceiver, IntentFilter)}. In |
| 2258 | * all other ways, this behaves the same as |
| 2259 | * {@link #sendBroadcast(Intent)}. |
| 2260 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2261 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2262 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2263 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2264 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2265 | * desired. |
| 2266 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2267 | * @param intent The Intent to broadcast; all receivers matching this |
| 2268 | * Intent will receive the broadcast, and the Intent will be held to |
| 2269 | * be re-broadcast to future receivers. |
| 2270 | * |
| 2271 | * @see #sendBroadcast(Intent) |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2272 | * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2273 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2274 | @Deprecated |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 2275 | @RequiresPermission(android.Manifest.permission.BROADCAST_STICKY) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2276 | public abstract void sendStickyBroadcast(@RequiresPermission Intent intent); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2277 | |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2278 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2279 | * <p>Version of {@link #sendStickyBroadcast} that allows you to |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2280 | * receive data back from the broadcast. This is accomplished by |
| 2281 | * supplying your own BroadcastReceiver when calling, which will be |
| 2282 | * treated as a final receiver at the end of the broadcast -- its |
| 2283 | * {@link BroadcastReceiver#onReceive} method will be called with |
| 2284 | * the result values collected from the other receivers. The broadcast will |
| 2285 | * be serialized in the same way as calling |
| 2286 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2287 | * |
| 2288 | * <p>Like {@link #sendBroadcast(Intent)}, this method is |
| 2289 | * asynchronous; it will return before |
| 2290 | * resultReceiver.onReceive() is called. Note that the sticky data |
| 2291 | * stored is only the data you initially supply to the broadcast, not |
| 2292 | * the result of any changes made by the receivers. |
| 2293 | * |
| 2294 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2295 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2296 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2297 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2298 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2299 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2300 | * desired. |
| 2301 | * |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2302 | * @param intent The Intent to broadcast; all receivers matching this |
| 2303 | * Intent will receive the broadcast. |
| 2304 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2305 | * receiver of the broadcast. |
| 2306 | * @param scheduler A custom Handler with which to schedule the |
| 2307 | * resultReceiver callback; if null it will be |
| 2308 | * scheduled in the Context's main thread. |
| 2309 | * @param initialCode An initial value for the result code. Often |
| 2310 | * Activity.RESULT_OK. |
| 2311 | * @param initialData An initial value for the result data. Often |
| 2312 | * null. |
| 2313 | * @param initialExtras An initial value for the result extras. Often |
| 2314 | * null. |
| 2315 | * |
| 2316 | * @see #sendBroadcast(Intent) |
| 2317 | * @see #sendBroadcast(Intent, String) |
| 2318 | * @see #sendOrderedBroadcast(Intent, String) |
| 2319 | * @see #sendStickyBroadcast(Intent) |
| 2320 | * @see android.content.BroadcastReceiver |
| 2321 | * @see #registerReceiver |
| 2322 | * @see android.app.Activity#RESULT_OK |
| 2323 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2324 | @Deprecated |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 2325 | @RequiresPermission(android.Manifest.permission.BROADCAST_STICKY) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2326 | public abstract void sendStickyOrderedBroadcast(@RequiresPermission Intent intent, |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2327 | BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2328 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2329 | @Nullable Bundle initialExtras); |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2330 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2331 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2332 | * <p>Remove the data previously sent with {@link #sendStickyBroadcast}, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2333 | * so that it is as if the sticky broadcast had never happened. |
| 2334 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2335 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2336 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2337 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2338 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2339 | * desired. |
| 2340 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2341 | * @param intent The Intent that was previously broadcast. |
| 2342 | * |
| 2343 | * @see #sendStickyBroadcast |
| 2344 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2345 | @Deprecated |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 2346 | @RequiresPermission(android.Manifest.permission.BROADCAST_STICKY) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2347 | public abstract void removeStickyBroadcast(@RequiresPermission Intent intent); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2348 | |
| 2349 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2350 | * <p>Version of {@link #sendStickyBroadcast(Intent)} that allows you to specify the |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2351 | * 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] | 2352 | * that are not pre-installed on the system image. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2353 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2354 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2355 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2356 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2357 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2358 | * desired. |
| 2359 | * |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2360 | * @param intent The Intent to broadcast; all receivers matching this |
| 2361 | * Intent will receive the broadcast, and the Intent will be held to |
| 2362 | * be re-broadcast to future receivers. |
| 2363 | * @param user UserHandle to send the intent to. |
| 2364 | * |
| 2365 | * @see #sendBroadcast(Intent) |
| 2366 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2367 | @Deprecated |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2368 | @RequiresPermission(allOf = { |
| 2369 | android.Manifest.permission.INTERACT_ACROSS_USERS, |
| 2370 | android.Manifest.permission.BROADCAST_STICKY |
| 2371 | }) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2372 | public abstract void sendStickyBroadcastAsUser(@RequiresPermission Intent intent, |
| 2373 | UserHandle user); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2374 | |
| 2375 | /** |
Dianne Hackborn | e0e413e | 2015-12-09 17:22:26 -0800 | [diff] [blame] | 2376 | * @hide |
| 2377 | * This is just here for sending CONNECTIVITY_ACTION. |
| 2378 | */ |
| 2379 | @Deprecated |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2380 | @RequiresPermission(allOf = { |
| 2381 | android.Manifest.permission.INTERACT_ACROSS_USERS, |
| 2382 | android.Manifest.permission.BROADCAST_STICKY |
| 2383 | }) |
Dianne Hackborn | e0e413e | 2015-12-09 17:22:26 -0800 | [diff] [blame] | 2384 | public abstract void sendStickyBroadcastAsUser(@RequiresPermission Intent intent, |
| 2385 | UserHandle user, Bundle options); |
| 2386 | |
| 2387 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2388 | * <p>Version of |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2389 | * {@link #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)} |
| 2390 | * that allows you to specify the |
| 2391 | * 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] | 2392 | * that are not pre-installed on the system image. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2393 | * |
| 2394 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2395 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2396 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2397 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2398 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2399 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2400 | * desired. |
| 2401 | * |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2402 | * @param intent The Intent to broadcast; all receivers matching this |
| 2403 | * Intent will receive the broadcast. |
| 2404 | * @param user UserHandle to send the intent to. |
| 2405 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2406 | * receiver of the broadcast. |
| 2407 | * @param scheduler A custom Handler with which to schedule the |
| 2408 | * resultReceiver callback; if null it will be |
| 2409 | * scheduled in the Context's main thread. |
| 2410 | * @param initialCode An initial value for the result code. Often |
| 2411 | * Activity.RESULT_OK. |
| 2412 | * @param initialData An initial value for the result data. Often |
| 2413 | * null. |
| 2414 | * @param initialExtras An initial value for the result extras. Often |
| 2415 | * null. |
| 2416 | * |
| 2417 | * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle) |
| 2418 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2419 | @Deprecated |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2420 | @RequiresPermission(allOf = { |
| 2421 | android.Manifest.permission.INTERACT_ACROSS_USERS, |
| 2422 | android.Manifest.permission.BROADCAST_STICKY |
| 2423 | }) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2424 | public abstract void sendStickyOrderedBroadcastAsUser(@RequiresPermission Intent intent, |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2425 | UserHandle user, BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2426 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2427 | @Nullable Bundle initialExtras); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2428 | |
| 2429 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2430 | * <p>Version of {@link #removeStickyBroadcast(Intent)} that allows you to specify the |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2431 | * 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] | 2432 | * that are not pre-installed on the system image. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2433 | * |
| 2434 | * <p>You must hold the {@link android.Manifest.permission#BROADCAST_STICKY} |
| 2435 | * permission in order to use this API. If you do not hold that |
| 2436 | * permission, {@link SecurityException} will be thrown. |
| 2437 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2438 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2439 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2440 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2441 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2442 | * desired. |
| 2443 | * |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2444 | * @param intent The Intent that was previously broadcast. |
| 2445 | * @param user UserHandle to remove the sticky broadcast from. |
| 2446 | * |
| 2447 | * @see #sendStickyBroadcastAsUser |
| 2448 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2449 | @Deprecated |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2450 | @RequiresPermission(allOf = { |
| 2451 | android.Manifest.permission.INTERACT_ACROSS_USERS, |
| 2452 | android.Manifest.permission.BROADCAST_STICKY |
| 2453 | }) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2454 | public abstract void removeStickyBroadcastAsUser(@RequiresPermission Intent intent, |
| 2455 | UserHandle user); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2456 | |
| 2457 | /** |
Chris Tate | a34df8a2 | 2009-04-02 23:15:58 -0700 | [diff] [blame] | 2458 | * 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] | 2459 | * <var>receiver</var> will be called with any broadcast Intent that |
| 2460 | * matches <var>filter</var>, in the main application thread. |
| 2461 | * |
| 2462 | * <p>The system may broadcast Intents that are "sticky" -- these stay |
Kweku Adams | 86f39a4 | 2016-11-16 12:50:38 -0800 | [diff] [blame] | 2463 | * 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] | 2464 | * registrations. If your IntentFilter matches one of these sticky |
| 2465 | * Intents, that Intent will be returned by this function |
| 2466 | * <strong>and</strong> sent to your <var>receiver</var> as if it had just |
| 2467 | * been broadcast. |
| 2468 | * |
| 2469 | * <p>There may be multiple sticky Intents that match <var>filter</var>, |
| 2470 | * in which case each of these will be sent to <var>receiver</var>. In |
| 2471 | * this case, only one of these can be returned directly by the function; |
| 2472 | * which of these that is returned is arbitrarily decided by the system. |
| 2473 | * |
| 2474 | * <p>If you know the Intent your are registering for is sticky, you can |
| 2475 | * supply null for your <var>receiver</var>. In this case, no receiver is |
| 2476 | * registered -- the function simply returns the sticky Intent that |
| 2477 | * matches <var>filter</var>. In the case of multiple matches, the same |
| 2478 | * rules as described above apply. |
| 2479 | * |
| 2480 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2481 | * |
Dianne Hackborn | 6c418d5 | 2011-06-29 14:05:33 -0700 | [diff] [blame] | 2482 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 2483 | * registered with this method will correctly respect the |
| 2484 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 2485 | * Prior to that, it would be ignored and delivered to all matching registered |
| 2486 | * receivers. Be careful if using this for security.</p> |
| 2487 | * |
Chris Tate | a34df8a2 | 2009-04-02 23:15:58 -0700 | [diff] [blame] | 2488 | * <p class="note">Note: this method <em>cannot be called from a |
| 2489 | * {@link BroadcastReceiver} component;</em> that is, from a BroadcastReceiver |
| 2490 | * that is declared in an application's manifest. It is okay, however, to call |
| 2491 | * this method from another BroadcastReceiver that has itself been registered |
| 2492 | * at run time with {@link #registerReceiver}, since the lifetime of such a |
| 2493 | * 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] | 2494 | * |
| 2495 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2496 | * @param filter Selects the Intent broadcasts to be received. |
| 2497 | * |
| 2498 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2499 | * or null if there are none. |
| 2500 | * |
| 2501 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
| 2502 | * @see #sendBroadcast |
| 2503 | * @see #unregisterReceiver |
| 2504 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2505 | @Nullable |
| 2506 | public abstract Intent registerReceiver(@Nullable BroadcastReceiver receiver, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2507 | IntentFilter filter); |
| 2508 | |
| 2509 | /** |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2510 | * Register to receive intent broadcasts, with the receiver optionally being |
| 2511 | * exposed to Instant Apps. See |
| 2512 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter)} for more |
| 2513 | * information. By default Instant Apps cannot interact with receivers in other |
| 2514 | * applications, this allows you to expose a receiver that Instant Apps can |
| 2515 | * interact with. |
| 2516 | * |
| 2517 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2518 | * |
| 2519 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 2520 | * registered with this method will correctly respect the |
| 2521 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 2522 | * Prior to that, it would be ignored and delivered to all matching registered |
| 2523 | * receivers. Be careful if using this for security.</p> |
| 2524 | * |
| 2525 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2526 | * @param filter Selects the Intent broadcasts to be received. |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2527 | * @param flags Additional options for the receiver. May be 0 or |
| 2528 | * {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2529 | * |
| 2530 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2531 | * or null if there are none. |
| 2532 | * |
| 2533 | * @see #registerReceiver(BroadcastReceiver, IntentFilter) |
| 2534 | * @see #sendBroadcast |
| 2535 | * @see #unregisterReceiver |
| 2536 | */ |
| 2537 | @Nullable |
| 2538 | public abstract Intent registerReceiver(@Nullable BroadcastReceiver receiver, |
| 2539 | IntentFilter filter, |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2540 | @RegisterReceiverFlags int flags); |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2541 | |
| 2542 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2543 | * Register to receive intent broadcasts, to run in the context of |
| 2544 | * <var>scheduler</var>. See |
| 2545 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter)} for more |
| 2546 | * information. This allows you to enforce permissions on who can |
| 2547 | * broadcast intents to your receiver, or have the receiver run in |
| 2548 | * a different thread than the main application thread. |
| 2549 | * |
| 2550 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2551 | * |
Dianne Hackborn | 6c418d5 | 2011-06-29 14:05:33 -0700 | [diff] [blame] | 2552 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 2553 | * registered with this method will correctly respect the |
| 2554 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 2555 | * Prior to that, it would be ignored and delivered to all matching registered |
| 2556 | * receivers. Be careful if using this for security.</p> |
| 2557 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2558 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2559 | * @param filter Selects the Intent broadcasts to be received. |
| 2560 | * @param broadcastPermission String naming a permissions that a |
| 2561 | * broadcaster must hold in order to send an Intent to you. If null, |
| 2562 | * no permission is required. |
| 2563 | * @param scheduler Handler identifying the thread that will receive |
| 2564 | * the Intent. If null, the main thread of the process will be used. |
| 2565 | * |
| 2566 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2567 | * or null if there are none. |
| 2568 | * |
| 2569 | * @see #registerReceiver(BroadcastReceiver, IntentFilter) |
| 2570 | * @see #sendBroadcast |
| 2571 | * @see #unregisterReceiver |
| 2572 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2573 | @Nullable |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2574 | public abstract Intent registerReceiver(BroadcastReceiver receiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2575 | IntentFilter filter, @Nullable String broadcastPermission, |
| 2576 | @Nullable Handler scheduler); |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2577 | |
| 2578 | /** |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2579 | * Register to receive intent broadcasts, to run in the context of |
| 2580 | * <var>scheduler</var>. See |
| 2581 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter, int)} and |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2582 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler)} |
| 2583 | * for more information. |
| 2584 | * |
| 2585 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2586 | * |
| 2587 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 2588 | * registered with this method will correctly respect the |
| 2589 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 2590 | * Prior to that, it would be ignored and delivered to all matching registered |
| 2591 | * receivers. Be careful if using this for security.</p> |
| 2592 | * |
| 2593 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2594 | * @param filter Selects the Intent broadcasts to be received. |
| 2595 | * @param broadcastPermission String naming a permissions that a |
| 2596 | * broadcaster must hold in order to send an Intent to you. If null, |
| 2597 | * no permission is required. |
| 2598 | * @param scheduler Handler identifying the thread that will receive |
| 2599 | * 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] | 2600 | * @param flags Additional options for the receiver. May be 0 or |
| 2601 | * {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2602 | * |
| 2603 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2604 | * or null if there are none. |
| 2605 | * |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2606 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, int) |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2607 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
| 2608 | * @see #sendBroadcast |
| 2609 | * @see #unregisterReceiver |
| 2610 | */ |
| 2611 | @Nullable |
| 2612 | public abstract Intent registerReceiver(BroadcastReceiver receiver, |
| 2613 | IntentFilter filter, @Nullable String broadcastPermission, |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2614 | @Nullable Handler scheduler, @RegisterReceiverFlags int flags); |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2615 | |
| 2616 | /** |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2617 | * @hide |
| 2618 | * Same as {@link #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
| 2619 | * but for a specific user. This receiver will receiver broadcasts that |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2620 | * are sent to the requested user. |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2621 | * |
| 2622 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2623 | * @param user UserHandle to send the intent to. |
| 2624 | * @param filter Selects the Intent broadcasts to be received. |
| 2625 | * @param broadcastPermission String naming a permissions that a |
| 2626 | * broadcaster must hold in order to send an Intent to you. If null, |
| 2627 | * no permission is required. |
| 2628 | * @param scheduler Handler identifying the thread that will receive |
| 2629 | * the Intent. If null, the main thread of the process will be used. |
| 2630 | * |
| 2631 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2632 | * or null if there are none. |
| 2633 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 2634 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2635 | * @see #sendBroadcast |
| 2636 | * @see #unregisterReceiver |
| 2637 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2638 | @Nullable |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2639 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2640 | public abstract Intent registerReceiverAsUser(BroadcastReceiver receiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2641 | UserHandle user, IntentFilter filter, @Nullable String broadcastPermission, |
| 2642 | @Nullable Handler scheduler); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2643 | |
| 2644 | /** |
| 2645 | * Unregister a previously registered BroadcastReceiver. <em>All</em> |
| 2646 | * filters that have been registered for this BroadcastReceiver will be |
| 2647 | * removed. |
| 2648 | * |
| 2649 | * @param receiver The BroadcastReceiver to unregister. |
| 2650 | * |
| 2651 | * @see #registerReceiver |
| 2652 | */ |
| 2653 | public abstract void unregisterReceiver(BroadcastReceiver receiver); |
| 2654 | |
| 2655 | /** |
| 2656 | * Request that a given application service be started. The Intent |
Hans Boehm | fb9f6ac | 2016-05-05 13:09:28 -0700 | [diff] [blame] | 2657 | * should either contain the complete class name of a specific service |
| 2658 | * implementation to start, or a specific package name to target. If the |
| 2659 | * Intent is less specified, it logs a warning about this. In this case any of the |
| 2660 | * multiple matching services may be used. If this service |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2661 | * is not already running, it will be instantiated and started (creating a |
| 2662 | * process for it if needed); if it is running then it remains running. |
| 2663 | * |
| 2664 | * <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] | 2665 | * 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] | 2666 | * with the <var>intent</var> given here. This provides a convenient way |
| 2667 | * to submit jobs to a service without having to bind and call on to its |
| 2668 | * interface. |
| 2669 | * |
| 2670 | * <p>Using startService() overrides the default service lifetime that is |
| 2671 | * managed by {@link #bindService}: it requires the service to remain |
| 2672 | * running until {@link #stopService} is called, regardless of whether |
| 2673 | * any clients are connected to it. Note that calls to startService() |
Hans Boehm | fb9f6ac | 2016-05-05 13:09:28 -0700 | [diff] [blame] | 2674 | * 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] | 2675 | * a single call to {@link #stopService} will stop it. |
| 2676 | * |
| 2677 | * <p>The system attempts to keep running services around as much as |
| 2678 | * possible. The only time they should be stopped is if the current |
| 2679 | * foreground application is using so many resources that the service needs |
| 2680 | * to be killed. If any errors happen in the service's process, it will |
| 2681 | * automatically be restarted. |
| 2682 | * |
| 2683 | * <p>This function will throw {@link SecurityException} if you do not |
| 2684 | * have permission to start the given service. |
| 2685 | * |
Chris Craik | 1e35352 | 2016-04-18 10:20:50 -0700 | [diff] [blame] | 2686 | * <p class="note"><strong>Note:</strong> Each call to startService() |
| 2687 | * results in significant work done by the system to manage service |
| 2688 | * lifecycle surrounding the processing of the intent, which can take |
| 2689 | * multiple milliseconds of CPU time. Due to this cost, startService() |
| 2690 | * should not be used for frequent intent delivery to a service, and only |
| 2691 | * for scheduling significant work. Use {@link #bindService bound services} |
| 2692 | * for high frequency calls. |
| 2693 | * </p> |
| 2694 | * |
Mark Lu | 94ebbe0 | 2016-12-13 16:29:51 -0800 | [diff] [blame] | 2695 | * @param service Identifies the service to be started. The Intent must be |
| 2696 | * fully explicit (supplying a component name). Additional values |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2697 | * may be included in the Intent extras to supply arguments along with |
| 2698 | * this specific start call. |
| 2699 | * |
| 2700 | * @return If the service is being started or is already running, the |
| 2701 | * {@link ComponentName} of the actual service that was started is |
| 2702 | * returned; else if the service does not exist null is returned. |
| 2703 | * |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2704 | * @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] | 2705 | * or the service can not be found. |
| 2706 | * @throws IllegalStateException If the application is in a state where the service |
| 2707 | * 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] | 2708 | * |
| 2709 | * @see #stopService |
| 2710 | * @see #bindService |
| 2711 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2712 | @Nullable |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2713 | public abstract ComponentName startService(Intent service); |
| 2714 | |
| 2715 | /** |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2716 | * Similar to {@link #startService(Intent)}, but with an implicit promise that the |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 2717 | * Service will call {@link android.app.Service#startForeground(int, android.app.Notification) |
| 2718 | * 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] | 2719 | * an amount of time comparable to the ANR interval to do this, otherwise the system |
| 2720 | * will automatically stop the service and declare the app ANR. |
| 2721 | * |
| 2722 | * <p>Unlike the ordinary {@link #startService(Intent)}, this method can be used |
| 2723 | * at any time, regardless of whether the app hosting the service is in a foreground |
| 2724 | * state. |
| 2725 | * |
| 2726 | * @param service Identifies the service to be started. The Intent must be |
| 2727 | * fully explicit (supplying a component name). Additional values |
| 2728 | * may be included in the Intent extras to supply arguments along with |
| 2729 | * this specific start call. |
| 2730 | * |
| 2731 | * @return If the service is being started or is already running, the |
| 2732 | * {@link ComponentName} of the actual service that was started is |
| 2733 | * returned; else if the service does not exist null is returned. |
| 2734 | * |
| 2735 | * @throws SecurityException If the caller does not have permission to access the service |
| 2736 | * or the service can not be found. |
| 2737 | * |
| 2738 | * @see #stopService |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 2739 | * @see android.app.Service#startForeground(int, android.app.Notification) |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2740 | */ |
| 2741 | @Nullable |
| 2742 | public abstract ComponentName startForegroundService(Intent service); |
| 2743 | |
| 2744 | /** |
| 2745 | * @hide like {@link #startForegroundService(Intent)} but for a specific user. |
| 2746 | */ |
| 2747 | @Nullable |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2748 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2749 | public abstract ComponentName startForegroundServiceAsUser(Intent service, UserHandle user); |
| 2750 | |
| 2751 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2752 | * Request that a given application service be stopped. If the service is |
| 2753 | * not running, nothing happens. Otherwise it is stopped. Note that calls |
| 2754 | * to startService() are not counted -- this stops the service no matter |
| 2755 | * how many times it was started. |
| 2756 | * |
| 2757 | * <p>Note that if a stopped service still has {@link ServiceConnection} |
| 2758 | * objects bound to it with the {@link #BIND_AUTO_CREATE} set, it will |
| 2759 | * not be destroyed until all of these bindings are removed. See |
| 2760 | * the {@link android.app.Service} documentation for more details on a |
| 2761 | * service's lifecycle. |
| 2762 | * |
| 2763 | * <p>This function will throw {@link SecurityException} if you do not |
| 2764 | * have permission to stop the given service. |
| 2765 | * |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 2766 | * @param service Description of the service to be stopped. The Intent must be either |
| 2767 | * fully explicit (supplying a component name) or specify a specific package |
| 2768 | * name it is targetted to. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2769 | * |
| 2770 | * @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] | 2771 | * 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] | 2772 | * |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2773 | * @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] | 2774 | * or the service can not be found. |
| 2775 | * @throws IllegalStateException If the application is in a state where the service |
| 2776 | * 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] | 2777 | * |
| 2778 | * @see #startService |
| 2779 | */ |
| 2780 | public abstract boolean stopService(Intent service); |
| 2781 | |
| 2782 | /** |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 2783 | * @hide like {@link #startService(Intent)} but for a specific user. |
| 2784 | */ |
Christopher Tate | 42a386b | 2016-11-07 12:21:21 -0800 | [diff] [blame] | 2785 | @Nullable |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2786 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 2787 | public abstract ComponentName startServiceAsUser(Intent service, UserHandle user); |
| 2788 | |
| 2789 | /** |
| 2790 | * @hide like {@link #stopService(Intent)} but for a specific user. |
| 2791 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2792 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 2793 | public abstract boolean stopServiceAsUser(Intent service, UserHandle user); |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 2794 | |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 2795 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2796 | * Connect to an application service, creating it if needed. This defines |
| 2797 | * a dependency between your application and the service. The given |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 2798 | * <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] | 2799 | * told if it dies and restarts. The service will be considered required |
| 2800 | * by the system only for as long as the calling context exists. For |
| 2801 | * example, if this Context is an Activity that is stopped, the service will |
| 2802 | * not be required to continue running until the Activity is resumed. |
| 2803 | * |
| 2804 | * <p>This function will throw {@link SecurityException} if you do not |
| 2805 | * have permission to bind to the given service. |
| 2806 | * |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 2807 | * <p class="note">Note: this method <em>can not be called from a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2808 | * {@link BroadcastReceiver} component</em>. A pattern you can use to |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 2809 | * 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] | 2810 | * {@link #startService} with the arguments containing the command to be |
| 2811 | * sent, with the service calling its |
| 2812 | * {@link android.app.Service#stopSelf(int)} method when done executing |
| 2813 | * that command. See the API demo App/Service/Service Start Arguments |
| 2814 | * Controller for an illustration of this. It is okay, however, to use |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 2815 | * 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] | 2816 | * {@link #registerReceiver}, since the lifetime of this BroadcastReceiver |
| 2817 | * is tied to another object (the one that registered it).</p> |
| 2818 | * |
Mark Lu | 94ebbe0 | 2016-12-13 16:29:51 -0800 | [diff] [blame] | 2819 | * @param service Identifies the service to connect to. The Intent must |
| 2820 | * specify an explicit component name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2821 | * @param conn Receives information as the service is started and stopped. |
Christopher Tate | 79b3317 | 2012-06-18 14:54:21 -0700 | [diff] [blame] | 2822 | * This must be a valid ServiceConnection object; it must not be null. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2823 | * @param flags Operation options for the binding. May be 0, |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 2824 | * {@link #BIND_AUTO_CREATE}, {@link #BIND_DEBUG_UNBIND}, |
| 2825 | * {@link #BIND_NOT_FOREGROUND}, {@link #BIND_ABOVE_CLIENT}, |
| 2826 | * {@link #BIND_ALLOW_OOM_MANAGEMENT}, or |
| 2827 | * {@link #BIND_WAIVE_PRIORITY}. |
Kevin Hufnagle | d195a99 | 2017-06-29 15:58:48 -0700 | [diff] [blame] | 2828 | * @return {@code true} if the system is in the process of bringing up a |
| 2829 | * service that your client has permission to bind to; {@code false} |
| 2830 | * if the system couldn't find the service or if your client doesn't |
| 2831 | * have permission to bind to it. If this value is {@code true}, you |
| 2832 | * should later call {@link #unbindService} to release the |
| 2833 | * connection. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2834 | * |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2835 | * @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] | 2836 | * or the service can not be found. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2837 | * |
| 2838 | * @see #unbindService |
| 2839 | * @see #startService |
| 2840 | * @see #BIND_AUTO_CREATE |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2841 | * @see #BIND_DEBUG_UNBIND |
| 2842 | * @see #BIND_NOT_FOREGROUND |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2843 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2844 | public abstract boolean bindService(@RequiresPermission Intent service, |
| 2845 | @NonNull ServiceConnection conn, @BindServiceFlags int flags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2846 | |
| 2847 | /** |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2848 | * Same as {@link #bindService(Intent, ServiceConnection, int)}, but with an explicit userHandle |
Amith Yamasani | 37ce3a8 | 2012-02-06 12:04:42 -0800 | [diff] [blame] | 2849 | * argument for use by system server and other multi-user aware code. |
| 2850 | * @hide |
| 2851 | */ |
Amith Yamasani | c85029f | 2014-09-11 16:47:17 -0700 | [diff] [blame] | 2852 | @SystemApi |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 2853 | @SuppressWarnings("unused") |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2854 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2855 | public boolean bindServiceAsUser(@RequiresPermission Intent service, ServiceConnection conn, |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 2856 | int flags, UserHandle user) { |
Amith Yamasani | 37ce3a8 | 2012-02-06 12:04:42 -0800 | [diff] [blame] | 2857 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 2858 | } |
| 2859 | |
| 2860 | /** |
Adrian Roos | 691546e | 2016-02-09 10:13:41 -0800 | [diff] [blame] | 2861 | * Same as {@link #bindService(Intent, ServiceConnection, int, UserHandle)}, but with an |
| 2862 | * explicit non-null Handler to run the ServiceConnection callbacks on. |
| 2863 | * |
| 2864 | * @hide |
| 2865 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2866 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Adrian Roos | 691546e | 2016-02-09 10:13:41 -0800 | [diff] [blame] | 2867 | public boolean bindServiceAsUser(Intent service, ServiceConnection conn, int flags, |
| 2868 | Handler handler, UserHandle user) { |
| 2869 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 2870 | } |
| 2871 | |
| 2872 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2873 | * Disconnect from an application service. You will no longer receive |
| 2874 | * calls as the service is restarted, and the service is now allowed to |
| 2875 | * stop at any time. |
| 2876 | * |
| 2877 | * @param conn The connection interface previously supplied to |
Christopher Tate | 79b3317 | 2012-06-18 14:54:21 -0700 | [diff] [blame] | 2878 | * bindService(). This parameter must not be null. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2879 | * |
| 2880 | * @see #bindService |
| 2881 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2882 | public abstract void unbindService(@NonNull ServiceConnection conn); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2883 | |
| 2884 | /** |
| 2885 | * Start executing an {@link android.app.Instrumentation} class. The given |
| 2886 | * Instrumentation component will be run by killing its target application |
| 2887 | * (if currently running), starting the target process, instantiating the |
| 2888 | * instrumentation component, and then letting it drive the application. |
| 2889 | * |
| 2890 | * <p>This function is not synchronous -- it returns as soon as the |
| 2891 | * instrumentation has started and while it is running. |
| 2892 | * |
| 2893 | * <p>Instrumentation is normally only allowed to run against a package |
| 2894 | * that is either unsigned or signed with a signature that the |
| 2895 | * the instrumentation package is also signed with (ensuring the target |
| 2896 | * trusts the instrumentation). |
| 2897 | * |
| 2898 | * @param className Name of the Instrumentation component to be run. |
| 2899 | * @param profileFile Optional path to write profiling data as the |
| 2900 | * instrumentation runs, or null for no profiling. |
| 2901 | * @param arguments Additional optional arguments to pass to the |
| 2902 | * instrumentation, or null. |
| 2903 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 2904 | * @return {@code true} if the instrumentation was successfully started, |
| 2905 | * else {@code false} if it could not be found. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2906 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2907 | public abstract boolean startInstrumentation(@NonNull ComponentName className, |
| 2908 | @Nullable String profileFile, @Nullable Bundle arguments); |
| 2909 | |
| 2910 | /** @hide */ |
| 2911 | @StringDef({ |
| 2912 | POWER_SERVICE, |
| 2913 | WINDOW_SERVICE, |
| 2914 | LAYOUT_INFLATER_SERVICE, |
| 2915 | ACCOUNT_SERVICE, |
| 2916 | ACTIVITY_SERVICE, |
| 2917 | ALARM_SERVICE, |
| 2918 | NOTIFICATION_SERVICE, |
| 2919 | ACCESSIBILITY_SERVICE, |
| 2920 | CAPTIONING_SERVICE, |
| 2921 | KEYGUARD_SERVICE, |
| 2922 | LOCATION_SERVICE, |
| 2923 | //@hide: COUNTRY_DETECTOR, |
| 2924 | SEARCH_SERVICE, |
| 2925 | SENSOR_SERVICE, |
| 2926 | STORAGE_SERVICE, |
Jeff Sharkey | e8cece9 | 2017-01-04 11:33:33 -0700 | [diff] [blame] | 2927 | STORAGE_STATS_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2928 | WALLPAPER_SERVICE, |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 2929 | TIME_ZONE_RULES_MANAGER_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2930 | VIBRATOR_SERVICE, |
| 2931 | //@hide: STATUS_BAR_SERVICE, |
| 2932 | CONNECTIVITY_SERVICE, |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 2933 | IPSEC_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2934 | //@hide: UPDATE_LOCK_SERVICE, |
| 2935 | //@hide: NETWORKMANAGEMENT_SERVICE, |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 2936 | NETWORK_STATS_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2937 | //@hide: NETWORK_POLICY_SERVICE, |
| 2938 | WIFI_SERVICE, |
Etan Cohen | 0413327 | 2016-10-26 11:22:06 -0700 | [diff] [blame] | 2939 | WIFI_AWARE_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2940 | WIFI_P2P_SERVICE, |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 2941 | WIFI_SCANNING_SERVICE, |
Robert Quattlebaum | 87a7104 | 2017-05-15 15:45:20 -0700 | [diff] [blame] | 2942 | //@hide: LOWPAN_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 2943 | //@hide: WIFI_RTT_SERVICE, |
Lorenzo Colitti | bd8a374 | 2014-05-22 11:51:27 -0700 | [diff] [blame] | 2944 | //@hide: ETHERNET_SERVICE, |
Vinit Deshpande | 7686c06 | 2014-06-30 15:25:01 -0700 | [diff] [blame] | 2945 | WIFI_RTT_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2946 | NSD_SERVICE, |
| 2947 | AUDIO_SERVICE, |
Jim Miller | ce7eb6d | 2015-04-03 19:29:13 -0700 | [diff] [blame] | 2948 | FINGERPRINT_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2949 | MEDIA_ROUTER_SERVICE, |
| 2950 | TELEPHONY_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 2951 | TELEPHONY_SUBSCRIPTION_SERVICE, |
Jonathan Basseri | 9a1c9b6 | 2015-02-25 13:01:52 -0800 | [diff] [blame] | 2952 | CARRIER_CONFIG_SERVICE, |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2953 | TELECOM_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2954 | CLIPBOARD_SERVICE, |
| 2955 | INPUT_METHOD_SERVICE, |
| 2956 | TEXT_SERVICES_MANAGER_SERVICE, |
Abodunrinwa Toki | 3de110b | 2017-05-04 16:29:04 +0100 | [diff] [blame] | 2957 | TEXT_CLASSIFICATION_SERVICE, |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 2958 | APPWIDGET_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 2959 | //@hide: VOICE_INTERACTION_MANAGER_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2960 | //@hide: BACKUP_SERVICE, |
| 2961 | DROPBOX_SERVICE, |
Dianne Hackborn | 1958e5e | 2015-06-12 18:11:41 -0700 | [diff] [blame] | 2962 | //@hide: DEVICE_IDLE_CONTROLLER, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2963 | DEVICE_POLICY_SERVICE, |
| 2964 | UI_MODE_SERVICE, |
| 2965 | DOWNLOAD_SERVICE, |
| 2966 | NFC_SERVICE, |
| 2967 | BLUETOOTH_SERVICE, |
| 2968 | //@hide: SIP_SERVICE, |
| 2969 | USB_SERVICE, |
Amith Yamasani | 4f58263 | 2014-02-19 14:31:52 -0800 | [diff] [blame] | 2970 | LAUNCHER_APPS_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2971 | //@hide: SERIAL_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 2972 | //@hide: HDMI_CONTROL_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2973 | INPUT_SERVICE, |
| 2974 | DISPLAY_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2975 | USER_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 2976 | RESTRICTIONS_SERVICE, |
| 2977 | APP_OPS_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2978 | CAMERA_SERVICE, |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 2979 | PRINT_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 2980 | CONSUMER_IR_SERVICE, |
| 2981 | //@hide: TRUST_SERVICE, |
| 2982 | TV_INPUT_SERVICE, |
| 2983 | //@hide: NETWORK_SCORE_SERVICE, |
| 2984 | USAGE_STATS_SERVICE, |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 2985 | MEDIA_SESSION_SERVICE, |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 2986 | BATTERY_SERVICE, |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 2987 | JOB_SCHEDULER_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 2988 | //@hide: PERSISTENT_DATA_BLOCK_SERVICE, |
Andrew Scull | 3b8b46f | 2017-02-13 18:12:15 +0000 | [diff] [blame] | 2989 | //@hide: OEM_LOCK_SERVICE, |
Michael Wright | 446e019 | 2014-12-22 09:38:43 -0800 | [diff] [blame] | 2990 | MEDIA_PROJECTION_SERVICE, |
Mike Lockwood | 67f8e8b | 2014-12-01 13:54:59 -0800 | [diff] [blame] | 2991 | MIDI_SERVICE, |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 2992 | RADIO_SERVICE, |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 2993 | HARDWARE_PROPERTIES_SERVICE, |
Arunesh Mishra | a772e5f | 2016-01-25 10:33:11 -0800 | [diff] [blame] | 2994 | //@hide: SOUND_TRIGGER_SERVICE, |
Makoto Onuki | 6f7362d9 | 2016-03-04 13:39:41 -0800 | [diff] [blame] | 2995 | SHORTCUT_SERVICE, |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 2996 | //@hide: CONTEXTHUB_SERVICE, |
Joe Onorato | 1754d74 | 2016-11-21 17:51:35 -0800 | [diff] [blame] | 2997 | SYSTEM_HEALTH_SERVICE, |
Tor Norbye | 8246c07 | 2017-07-07 10:21:09 -0700 | [diff] [blame] | 2998 | //@hide: INCIDENT_SERVICE, |
| 2999 | COMPANION_DEVICE_SERVICE |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3000 | }) |
| 3001 | @Retention(RetentionPolicy.SOURCE) |
| 3002 | public @interface ServiceName {} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3003 | |
| 3004 | /** |
| 3005 | * Return the handle to a system-level service by name. The class of the |
| 3006 | * returned object varies by the requested name. Currently available names |
| 3007 | * are: |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3008 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3009 | * <dl> |
| 3010 | * <dt> {@link #WINDOW_SERVICE} ("window") |
| 3011 | * <dd> The top-level window manager in which you can place custom |
| 3012 | * windows. The returned object is a {@link android.view.WindowManager}. |
| 3013 | * <dt> {@link #LAYOUT_INFLATER_SERVICE} ("layout_inflater") |
| 3014 | * <dd> A {@link android.view.LayoutInflater} for inflating layout resources |
| 3015 | * in this context. |
| 3016 | * <dt> {@link #ACTIVITY_SERVICE} ("activity") |
| 3017 | * <dd> A {@link android.app.ActivityManager} for interacting with the |
| 3018 | * global activity state of the system. |
| 3019 | * <dt> {@link #POWER_SERVICE} ("power") |
| 3020 | * <dd> A {@link android.os.PowerManager} for controlling power |
| 3021 | * management. |
| 3022 | * <dt> {@link #ALARM_SERVICE} ("alarm") |
| 3023 | * <dd> A {@link android.app.AlarmManager} for receiving intents at the |
| 3024 | * time of your choosing. |
| 3025 | * <dt> {@link #NOTIFICATION_SERVICE} ("notification") |
| 3026 | * <dd> A {@link android.app.NotificationManager} for informing the user |
| 3027 | * of background events. |
| 3028 | * <dt> {@link #KEYGUARD_SERVICE} ("keyguard") |
| 3029 | * <dd> A {@link android.app.KeyguardManager} for controlling keyguard. |
| 3030 | * <dt> {@link #LOCATION_SERVICE} ("location") |
| 3031 | * <dd> A {@link android.location.LocationManager} for controlling location |
| 3032 | * (e.g., GPS) updates. |
| 3033 | * <dt> {@link #SEARCH_SERVICE} ("search") |
| 3034 | * <dd> A {@link android.app.SearchManager} for handling search. |
| 3035 | * <dt> {@link #VIBRATOR_SERVICE} ("vibrator") |
| 3036 | * <dd> A {@link android.os.Vibrator} for interacting with the vibrator |
| 3037 | * hardware. |
| 3038 | * <dt> {@link #CONNECTIVITY_SERVICE} ("connection") |
| 3039 | * <dd> A {@link android.net.ConnectivityManager ConnectivityManager} for |
| 3040 | * handling management of network connections. |
Nathan Harold | d999d22 | 2017-09-11 19:53:33 -0700 | [diff] [blame] | 3041 | * <dt> {@link #IPSEC_SERVICE} ("ipsec") |
| 3042 | * <dd> A {@link android.net.IpSecManager IpSecManager} for managing IPSec on |
| 3043 | * sockets and networks. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3044 | * <dt> {@link #WIFI_SERVICE} ("wifi") |
Paul Stewart | 0e164b1 | 2016-08-08 10:20:13 -0700 | [diff] [blame] | 3045 | * <dd> A {@link android.net.wifi.WifiManager WifiManager} for management of Wi-Fi |
| 3046 | * connectivity. On releases before NYC, it should only be obtained from an application |
| 3047 | * context, and not from any other derived context to avoid memory leaks within the calling |
| 3048 | * process. |
Etan Cohen | 6a4b323 | 2017-01-09 21:47:32 -0800 | [diff] [blame] | 3049 | * <dt> {@link #WIFI_AWARE_SERVICE} ("wifiaware") |
| 3050 | * <dd> A {@link android.net.wifi.aware.WifiAwareManager WifiAwareManager} for management of |
| 3051 | * Wi-Fi Aware discovery and connectivity. |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 3052 | * <dt> {@link #WIFI_P2P_SERVICE} ("wifip2p") |
| 3053 | * <dd> A {@link android.net.wifi.p2p.WifiP2pManager WifiP2pManager} for management of |
| 3054 | * Wi-Fi Direct connectivity. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3055 | * <dt> {@link #INPUT_METHOD_SERVICE} ("input_method") |
| 3056 | * <dd> An {@link android.view.inputmethod.InputMethodManager InputMethodManager} |
| 3057 | * for management of input methods. |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 3058 | * <dt> {@link #UI_MODE_SERVICE} ("uimode") |
| 3059 | * <dd> An {@link android.app.UiModeManager} for controlling UI modes. |
Steve Howard | 7083c42 | 2010-07-28 16:01:23 -0700 | [diff] [blame] | 3060 | * <dt> {@link #DOWNLOAD_SERVICE} ("download") |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 3061 | * <dd> A {@link android.app.DownloadManager} for requesting HTTP downloads |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 3062 | * <dt> {@link #BATTERY_SERVICE} ("batterymanager") |
Todd Poynor | 99f7e12 | 2014-04-15 16:03:42 -0700 | [diff] [blame] | 3063 | * <dd> A {@link android.os.BatteryManager} for managing battery state |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 3064 | * <dt> {@link #JOB_SCHEDULER_SERVICE} ("taskmanager") |
| 3065 | * <dd> A {@link android.app.job.JobScheduler} for managing scheduled tasks |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3066 | * <dt> {@link #NETWORK_STATS_SERVICE} ("netstats") |
| 3067 | * <dd> A {@link android.app.usage.NetworkStatsManager NetworkStatsManager} for querying network |
| 3068 | * usage statistics. |
Polina Bondarenko | 8333c73 | 2016-03-09 18:08:42 +0100 | [diff] [blame] | 3069 | * <dt> {@link #HARDWARE_PROPERTIES_SERVICE} ("hardware_properties") |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 3070 | * <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] | 3071 | * </dl> |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3072 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3073 | * <p>Note: System services obtained via this API may be closely associated with |
| 3074 | * the Context in which they are obtained from. In general, do not share the |
| 3075 | * service objects between various different contexts (Activities, Applications, |
| 3076 | * Services, Providers, etc.) |
| 3077 | * |
| 3078 | * @param name The name of the desired service. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3079 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3080 | * @return The service or null if the name does not exist. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3081 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3082 | * @see #WINDOW_SERVICE |
| 3083 | * @see android.view.WindowManager |
| 3084 | * @see #LAYOUT_INFLATER_SERVICE |
| 3085 | * @see android.view.LayoutInflater |
| 3086 | * @see #ACTIVITY_SERVICE |
| 3087 | * @see android.app.ActivityManager |
| 3088 | * @see #POWER_SERVICE |
| 3089 | * @see android.os.PowerManager |
| 3090 | * @see #ALARM_SERVICE |
| 3091 | * @see android.app.AlarmManager |
| 3092 | * @see #NOTIFICATION_SERVICE |
| 3093 | * @see android.app.NotificationManager |
| 3094 | * @see #KEYGUARD_SERVICE |
| 3095 | * @see android.app.KeyguardManager |
| 3096 | * @see #LOCATION_SERVICE |
| 3097 | * @see android.location.LocationManager |
| 3098 | * @see #SEARCH_SERVICE |
| 3099 | * @see android.app.SearchManager |
| 3100 | * @see #SENSOR_SERVICE |
| 3101 | * @see android.hardware.SensorManager |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 3102 | * @see #STORAGE_SERVICE |
San Mehat | b104340 | 2010-02-05 08:26:50 -0800 | [diff] [blame] | 3103 | * @see android.os.storage.StorageManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3104 | * @see #VIBRATOR_SERVICE |
| 3105 | * @see android.os.Vibrator |
| 3106 | * @see #CONNECTIVITY_SERVICE |
| 3107 | * @see android.net.ConnectivityManager |
| 3108 | * @see #WIFI_SERVICE |
| 3109 | * @see android.net.wifi.WifiManager |
| 3110 | * @see #AUDIO_SERVICE |
| 3111 | * @see android.media.AudioManager |
Dianne Hackborn | b58b8f8 | 2012-06-11 15:08:39 -0700 | [diff] [blame] | 3112 | * @see #MEDIA_ROUTER_SERVICE |
| 3113 | * @see android.media.MediaRouter |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3114 | * @see #TELEPHONY_SERVICE |
| 3115 | * @see android.telephony.TelephonyManager |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 3116 | * @see #TELEPHONY_SUBSCRIPTION_SERVICE |
| 3117 | * @see android.telephony.SubscriptionManager |
Jonathan Basseri | 9a1c9b6 | 2015-02-25 13:01:52 -0800 | [diff] [blame] | 3118 | * @see #CARRIER_CONFIG_SERVICE |
| 3119 | * @see android.telephony.CarrierConfigManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3120 | * @see #INPUT_METHOD_SERVICE |
| 3121 | * @see android.view.inputmethod.InputMethodManager |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 3122 | * @see #UI_MODE_SERVICE |
| 3123 | * @see android.app.UiModeManager |
Steve Howard | 7083c42 | 2010-07-28 16:01:23 -0700 | [diff] [blame] | 3124 | * @see #DOWNLOAD_SERVICE |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 3125 | * @see android.app.DownloadManager |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 3126 | * @see #BATTERY_SERVICE |
| 3127 | * @see android.os.BatteryManager |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 3128 | * @see #JOB_SCHEDULER_SERVICE |
| 3129 | * @see android.app.job.JobScheduler |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3130 | * @see #NETWORK_STATS_SERVICE |
| 3131 | * @see android.app.usage.NetworkStatsManager |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 3132 | * @see android.os.HardwarePropertiesManager |
| 3133 | * @see #HARDWARE_PROPERTIES_SERVICE |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3134 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 3135 | public abstract @Nullable Object getSystemService(@ServiceName @NonNull String name); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3136 | |
| 3137 | /** |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3138 | * Return the handle to a system-level service by class. |
| 3139 | * <p> |
| 3140 | * Currently available classes are: |
| 3141 | * {@link android.view.WindowManager}, {@link android.view.LayoutInflater}, |
| 3142 | * {@link android.app.ActivityManager}, {@link android.os.PowerManager}, |
| 3143 | * {@link android.app.AlarmManager}, {@link android.app.NotificationManager}, |
| 3144 | * {@link android.app.KeyguardManager}, {@link android.location.LocationManager}, |
| 3145 | * {@link android.app.SearchManager}, {@link android.os.Vibrator}, |
| 3146 | * {@link android.net.ConnectivityManager}, |
| 3147 | * {@link android.net.wifi.WifiManager}, |
| 3148 | * {@link android.media.AudioManager}, {@link android.media.MediaRouter}, |
| 3149 | * {@link android.telephony.TelephonyManager}, {@link android.telephony.SubscriptionManager}, |
| 3150 | * {@link android.view.inputmethod.InputMethodManager}, |
| 3151 | * {@link android.app.UiModeManager}, {@link android.app.DownloadManager}, |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3152 | * {@link android.os.BatteryManager}, {@link android.app.job.JobScheduler}, |
| 3153 | * {@link android.app.usage.NetworkStatsManager}. |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3154 | * </p><p> |
| 3155 | * Note: System services obtained via this API may be closely associated with |
| 3156 | * the Context in which they are obtained from. In general, do not share the |
| 3157 | * service objects between various different contexts (Activities, Applications, |
| 3158 | * Services, Providers, etc.) |
| 3159 | * </p> |
| 3160 | * |
| 3161 | * @param serviceClass The class of the desired service. |
| 3162 | * @return The service or null if the class is not a supported system service. |
| 3163 | */ |
| 3164 | @SuppressWarnings("unchecked") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 3165 | public final @Nullable <T> T getSystemService(@NonNull Class<T> serviceClass) { |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3166 | // Because subclasses may override getSystemService(String) we cannot |
| 3167 | // perform a lookup by class alone. We must first map the class to its |
| 3168 | // service name then invoke the string-based method. |
| 3169 | String serviceName = getSystemServiceName(serviceClass); |
| 3170 | return serviceName != null ? (T)getSystemService(serviceName) : null; |
| 3171 | } |
| 3172 | |
| 3173 | /** |
| 3174 | * Gets the name of the system-level service that is represented by the specified class. |
| 3175 | * |
| 3176 | * @param serviceClass The class of the desired service. |
| 3177 | * @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] | 3178 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 3179 | public abstract @Nullable String getSystemServiceName(@NonNull Class<?> serviceClass); |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3180 | |
| 3181 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3182 | * Use with {@link #getSystemService} to retrieve a |
| 3183 | * {@link android.os.PowerManager} for controlling power management, |
| 3184 | * including "wake locks," which let you keep the device on while |
| 3185 | * you're running long tasks. |
| 3186 | */ |
| 3187 | public static final String POWER_SERVICE = "power"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3188 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3189 | /** |
| 3190 | * Use with {@link #getSystemService} to retrieve a |
Tao Bao | e8a403d | 2015-12-31 07:44:55 -0800 | [diff] [blame] | 3191 | * {@link android.os.RecoverySystem} for accessing the recovery system |
| 3192 | * service. |
| 3193 | * |
| 3194 | * @see #getSystemService |
| 3195 | * @hide |
| 3196 | */ |
| 3197 | public static final String RECOVERY_SERVICE = "recovery"; |
| 3198 | |
| 3199 | /** |
| 3200 | * Use with {@link #getSystemService} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3201 | * {@link android.view.WindowManager} for accessing the system's window |
| 3202 | * manager. |
| 3203 | * |
| 3204 | * @see #getSystemService |
| 3205 | * @see android.view.WindowManager |
| 3206 | */ |
| 3207 | public static final String WINDOW_SERVICE = "window"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3208 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3209 | /** |
| 3210 | * Use with {@link #getSystemService} to retrieve a |
| 3211 | * {@link android.view.LayoutInflater} for inflating layout resources in this |
| 3212 | * context. |
| 3213 | * |
| 3214 | * @see #getSystemService |
| 3215 | * @see android.view.LayoutInflater |
| 3216 | */ |
| 3217 | public static final String LAYOUT_INFLATER_SERVICE = "layout_inflater"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3218 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3219 | /** |
| 3220 | * Use with {@link #getSystemService} to retrieve a |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 3221 | * {@link android.accounts.AccountManager} for receiving intents at a |
| 3222 | * time of your choosing. |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 3223 | * |
| 3224 | * @see #getSystemService |
| 3225 | * @see android.accounts.AccountManager |
| 3226 | */ |
| 3227 | public static final String ACCOUNT_SERVICE = "account"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3228 | |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 3229 | /** |
| 3230 | * Use with {@link #getSystemService} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3231 | * {@link android.app.ActivityManager} for interacting with the global |
| 3232 | * system state. |
| 3233 | * |
| 3234 | * @see #getSystemService |
| 3235 | * @see android.app.ActivityManager |
| 3236 | */ |
| 3237 | public static final String ACTIVITY_SERVICE = "activity"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3238 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3239 | /** |
| 3240 | * Use with {@link #getSystemService} to retrieve a |
| 3241 | * {@link android.app.AlarmManager} for receiving intents at a |
| 3242 | * time of your choosing. |
| 3243 | * |
| 3244 | * @see #getSystemService |
| 3245 | * @see android.app.AlarmManager |
| 3246 | */ |
| 3247 | public static final String ALARM_SERVICE = "alarm"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3248 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3249 | /** |
| 3250 | * Use with {@link #getSystemService} to retrieve a |
| 3251 | * {@link android.app.NotificationManager} for informing the user of |
| 3252 | * background events. |
| 3253 | * |
| 3254 | * @see #getSystemService |
| 3255 | * @see android.app.NotificationManager |
| 3256 | */ |
| 3257 | public static final String NOTIFICATION_SERVICE = "notification"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3258 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3259 | /** |
| 3260 | * Use with {@link #getSystemService} to retrieve a |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 3261 | * {@link android.view.accessibility.AccessibilityManager} for giving the user |
| 3262 | * feedback for UI events through the registered event listeners. |
| 3263 | * |
| 3264 | * @see #getSystemService |
| 3265 | * @see android.view.accessibility.AccessibilityManager |
| 3266 | */ |
| 3267 | public static final String ACCESSIBILITY_SERVICE = "accessibility"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3268 | |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 3269 | /** |
| 3270 | * Use with {@link #getSystemService} to retrieve a |
Alan Viverette | 69ce69b | 2013-08-29 12:23:48 -0700 | [diff] [blame] | 3271 | * {@link android.view.accessibility.CaptioningManager} for obtaining |
| 3272 | * captioning properties and listening for changes in captioning |
| 3273 | * preferences. |
| 3274 | * |
| 3275 | * @see #getSystemService |
| 3276 | * @see android.view.accessibility.CaptioningManager |
| 3277 | */ |
| 3278 | public static final String CAPTIONING_SERVICE = "captioning"; |
| 3279 | |
| 3280 | /** |
| 3281 | * Use with {@link #getSystemService} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3282 | * {@link android.app.NotificationManager} for controlling keyguard. |
| 3283 | * |
| 3284 | * @see #getSystemService |
| 3285 | * @see android.app.KeyguardManager |
| 3286 | */ |
| 3287 | public static final String KEYGUARD_SERVICE = "keyguard"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3288 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3289 | /** |
| 3290 | * Use with {@link #getSystemService} to retrieve a {@link |
| 3291 | * android.location.LocationManager} for controlling location |
| 3292 | * updates. |
| 3293 | * |
| 3294 | * @see #getSystemService |
| 3295 | * @see android.location.LocationManager |
| 3296 | */ |
| 3297 | public static final String LOCATION_SERVICE = "location"; |
Bai Tao | a58a875 | 2010-07-13 15:32:16 +0800 | [diff] [blame] | 3298 | |
| 3299 | /** |
| 3300 | * Use with {@link #getSystemService} to retrieve a |
| 3301 | * {@link android.location.CountryDetector} for detecting the country that |
| 3302 | * the user is in. |
| 3303 | * |
| 3304 | * @hide |
| 3305 | */ |
| 3306 | public static final String COUNTRY_DETECTOR = "country_detector"; |
| 3307 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3308 | /** |
| 3309 | * Use with {@link #getSystemService} to retrieve a {@link |
| 3310 | * android.app.SearchManager} for handling searches. |
| 3311 | * |
| 3312 | * @see #getSystemService |
| 3313 | * @see android.app.SearchManager |
| 3314 | */ |
| 3315 | public static final String SEARCH_SERVICE = "search"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3316 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3317 | /** |
| 3318 | * Use with {@link #getSystemService} to retrieve a {@link |
| 3319 | * android.hardware.SensorManager} for accessing sensors. |
| 3320 | * |
| 3321 | * @see #getSystemService |
| 3322 | * @see android.hardware.SensorManager |
| 3323 | */ |
| 3324 | public static final String SENSOR_SERVICE = "sensor"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3325 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3326 | /** |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 3327 | * Use with {@link #getSystemService} to retrieve a {@link |
Kenny Root | 02c8730 | 2010-07-01 08:10:18 -0700 | [diff] [blame] | 3328 | * android.os.storage.StorageManager} for accessing system storage |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 3329 | * functions. |
| 3330 | * |
| 3331 | * @see #getSystemService |
San Mehat | b104340 | 2010-02-05 08:26:50 -0800 | [diff] [blame] | 3332 | * @see android.os.storage.StorageManager |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 3333 | */ |
| 3334 | public static final String STORAGE_SERVICE = "storage"; |
| 3335 | |
| 3336 | /** |
Jeff Sharkey | e8cece9 | 2017-01-04 11:33:33 -0700 | [diff] [blame] | 3337 | * Use with {@link #getSystemService} to retrieve a {@link |
| 3338 | * android.app.usage.StorageStatsManager} for accessing system storage |
| 3339 | * statistics. |
| 3340 | * |
| 3341 | * @see #getSystemService |
| 3342 | * @see android.app.usage.StorageStatsManager |
| 3343 | */ |
| 3344 | public static final String STORAGE_STATS_SERVICE = "storagestats"; |
| 3345 | |
| 3346 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3347 | * Use with {@link #getSystemService} to retrieve a |
| 3348 | * com.android.server.WallpaperService for accessing wallpapers. |
| 3349 | * |
| 3350 | * @see #getSystemService |
| 3351 | */ |
| 3352 | public static final String WALLPAPER_SERVICE = "wallpaper"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3353 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3354 | /** |
| 3355 | * Use with {@link #getSystemService} to retrieve a {@link |
| 3356 | * android.os.Vibrator} for interacting with the vibration hardware. |
| 3357 | * |
| 3358 | * @see #getSystemService |
| 3359 | * @see android.os.Vibrator |
| 3360 | */ |
| 3361 | public static final String VIBRATOR_SERVICE = "vibrator"; |
Robert Greenwalt | 9e696c2 | 2010-04-01 14:45:18 -0700 | [diff] [blame] | 3362 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3363 | /** |
| 3364 | * Use with {@link #getSystemService} to retrieve a {@link |
| 3365 | * android.app.StatusBarManager} for interacting with the status bar. |
| 3366 | * |
| 3367 | * @see #getSystemService |
| 3368 | * @see android.app.StatusBarManager |
| 3369 | * @hide |
| 3370 | */ |
| 3371 | public static final String STATUS_BAR_SERVICE = "statusbar"; |
| 3372 | |
| 3373 | /** |
| 3374 | * Use with {@link #getSystemService} to retrieve a {@link |
| 3375 | * android.net.ConnectivityManager} for handling management of |
| 3376 | * network connections. |
| 3377 | * |
| 3378 | * @see #getSystemService |
| 3379 | * @see android.net.ConnectivityManager |
| 3380 | */ |
| 3381 | public static final String CONNECTIVITY_SERVICE = "connectivity"; |
| 3382 | |
| 3383 | /** |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 3384 | * Use with {@link #getSystemService} to retrieve a |
| 3385 | * {@link android.net.IpSecManager} for encrypting Sockets or Networks with |
| 3386 | * IPSec. |
| 3387 | * |
| 3388 | * @see #getSystemService |
| 3389 | */ |
| 3390 | public static final String IPSEC_SERVICE = "ipsec"; |
| 3391 | |
| 3392 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3393 | * Use with {@link #getSystemService} to retrieve a {@link |
Christopher Tate | 8662cab5 | 2012-02-23 14:59:36 -0800 | [diff] [blame] | 3394 | * android.os.IUpdateLock} for managing runtime sequences that |
| 3395 | * must not be interrupted by headless OTA application or similar. |
| 3396 | * |
| 3397 | * @hide |
| 3398 | * @see #getSystemService |
| 3399 | * @see android.os.UpdateLock |
| 3400 | */ |
| 3401 | public static final String UPDATE_LOCK_SERVICE = "updatelock"; |
| 3402 | |
| 3403 | /** |
Dianne Hackborn | 35f72be | 2013-09-16 10:57:39 -0700 | [diff] [blame] | 3404 | * Constant for the internal network management service, not really a Context service. |
Dianne Hackborn | 0a6a80f | 2013-09-16 15:20:27 -0700 | [diff] [blame] | 3405 | * @hide |
San Mehat | d1df8ac | 2010-01-26 06:17:26 -0800 | [diff] [blame] | 3406 | */ |
| 3407 | public static final String NETWORKMANAGEMENT_SERVICE = "network_management"; |
| 3408 | |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3409 | /** |
| 3410 | * Use with {@link #getSystemService} to retrieve a {@link |
| 3411 | * android.app.usage.NetworkStatsManager} for querying network usage stats. |
| 3412 | * |
| 3413 | * @see #getSystemService |
| 3414 | * @see android.app.usage.NetworkStatsManager |
| 3415 | */ |
Jeff Sharkey | 7527990 | 2011-05-24 18:39:45 -0700 | [diff] [blame] | 3416 | public static final String NETWORK_STATS_SERVICE = "netstats"; |
| 3417 | /** {@hide} */ |
Jeff Sharkey | eedcb95 | 2011-05-17 14:55:15 -0700 | [diff] [blame] | 3418 | public static final String NETWORK_POLICY_SERVICE = "netpolicy"; |
| 3419 | |
San Mehat | d1df8ac | 2010-01-26 06:17:26 -0800 | [diff] [blame] | 3420 | /** |
| 3421 | * Use with {@link #getSystemService} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3422 | * android.net.wifi.WifiManager} for handling management of |
| 3423 | * Wi-Fi access. |
| 3424 | * |
| 3425 | * @see #getSystemService |
| 3426 | * @see android.net.wifi.WifiManager |
| 3427 | */ |
| 3428 | public static final String WIFI_SERVICE = "wifi"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3429 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3430 | /** |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 3431 | * Use with {@link #getSystemService} to retrieve a {@link |
| 3432 | * android.net.wifi.p2p.WifiP2pManager} for handling management of |
Irfan Sheriff | 651cdfc | 2011-09-07 00:31:20 -0700 | [diff] [blame] | 3433 | * Wi-Fi peer-to-peer connections. |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 3434 | * |
| 3435 | * @see #getSystemService |
| 3436 | * @see android.net.wifi.p2p.WifiP2pManager |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 3437 | */ |
| 3438 | public static final String WIFI_P2P_SERVICE = "wifip2p"; |
| 3439 | |
| 3440 | /** |
Etan Cohen | 20d329b | 2015-09-29 13:49:02 -0700 | [diff] [blame] | 3441 | * Use with {@link #getSystemService} to retrieve a |
Etan Cohen | 0413327 | 2016-10-26 11:22:06 -0700 | [diff] [blame] | 3442 | * {@link android.net.wifi.aware.WifiAwareManager} for handling management of |
| 3443 | * Wi-Fi Aware. |
Etan Cohen | 20d329b | 2015-09-29 13:49:02 -0700 | [diff] [blame] | 3444 | * |
| 3445 | * @see #getSystemService |
Etan Cohen | 0413327 | 2016-10-26 11:22:06 -0700 | [diff] [blame] | 3446 | * @see android.net.wifi.aware.WifiAwareManager |
Etan Cohen | 20d329b | 2015-09-29 13:49:02 -0700 | [diff] [blame] | 3447 | */ |
Etan Cohen | 0413327 | 2016-10-26 11:22:06 -0700 | [diff] [blame] | 3448 | public static final String WIFI_AWARE_SERVICE = "wifiaware"; |
Etan Cohen | 20d329b | 2015-09-29 13:49:02 -0700 | [diff] [blame] | 3449 | |
| 3450 | /** |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 3451 | * Use with {@link #getSystemService} to retrieve a {@link |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 3452 | * android.net.wifi.WifiScanner} for scanning the wifi universe |
| 3453 | * |
| 3454 | * @see #getSystemService |
| 3455 | * @see android.net.wifi.WifiScanner |
| 3456 | * @hide |
| 3457 | */ |
Wei Wang | 35d552f | 2014-07-08 21:37:01 -0700 | [diff] [blame] | 3458 | @SystemApi |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 3459 | public static final String WIFI_SCANNING_SERVICE = "wifiscanner"; |
| 3460 | |
| 3461 | /** |
| 3462 | * Use with {@link #getSystemService} to retrieve a {@link |
Vinit Deshpande | 7686c06 | 2014-06-30 15:25:01 -0700 | [diff] [blame] | 3463 | * android.net.wifi.RttManager} for ranging devices with wifi |
| 3464 | * |
| 3465 | * @see #getSystemService |
| 3466 | * @see android.net.wifi.RttManager |
| 3467 | * @hide |
| 3468 | */ |
| 3469 | @SystemApi |
| 3470 | public static final String WIFI_RTT_SERVICE = "rttmanager"; |
| 3471 | |
| 3472 | /** |
| 3473 | * Use with {@link #getSystemService} to retrieve a {@link |
Robert Quattlebaum | 87a7104 | 2017-05-15 15:45:20 -0700 | [diff] [blame] | 3474 | * android.net.lowpan.LowpanManager} for handling management of |
| 3475 | * LoWPAN access. |
| 3476 | * |
| 3477 | * @see #getSystemService |
| 3478 | * @see android.net.lowpan.LowpanManager |
| 3479 | * |
| 3480 | * @hide |
| 3481 | */ |
| 3482 | public static final String LOWPAN_SERVICE = "lowpan"; |
| 3483 | |
| 3484 | /** |
| 3485 | * Use with {@link #getSystemService} to retrieve a {@link |
Dianne Hackborn | fee756f | 2014-07-16 17:31:10 -0700 | [diff] [blame] | 3486 | * android.net.EthernetManager} for handling management of |
Lorenzo Colitti | f9ff2c9 | 2014-05-21 16:32:11 -0700 | [diff] [blame] | 3487 | * Ethernet access. |
| 3488 | * |
| 3489 | * @see #getSystemService |
Dianne Hackborn | fee756f | 2014-07-16 17:31:10 -0700 | [diff] [blame] | 3490 | * @see android.net.EthernetManager |
Lorenzo Colitti | f9ff2c9 | 2014-05-21 16:32:11 -0700 | [diff] [blame] | 3491 | * |
| 3492 | * @hide |
| 3493 | */ |
| 3494 | public static final String ETHERNET_SERVICE = "ethernet"; |
| 3495 | |
| 3496 | /** |
| 3497 | * Use with {@link #getSystemService} to retrieve a {@link |
Irfan Sheriff | 60309fc | 2012-04-24 14:52:37 -0700 | [diff] [blame] | 3498 | * android.net.nsd.NsdManager} for handling management of network service |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 3499 | * discovery |
| 3500 | * |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 3501 | * @see #getSystemService |
Irfan Sheriff | 60309fc | 2012-04-24 14:52:37 -0700 | [diff] [blame] | 3502 | * @see android.net.nsd.NsdManager |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 3503 | */ |
| 3504 | public static final String NSD_SERVICE = "servicediscovery"; |
| 3505 | |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 3506 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3507 | * Use with {@link #getSystemService} to retrieve a |
| 3508 | * {@link android.media.AudioManager} for handling management of volume, |
| 3509 | * ringer modes and audio routing. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3510 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3511 | * @see #getSystemService |
| 3512 | * @see android.media.AudioManager |
| 3513 | */ |
| 3514 | public static final String AUDIO_SERVICE = "audio"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3515 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3516 | /** |
| 3517 | * Use with {@link #getSystemService} to retrieve a |
Jim Miller | ce7eb6d | 2015-04-03 19:29:13 -0700 | [diff] [blame] | 3518 | * {@link android.hardware.fingerprint.FingerprintManager} for handling management |
Jim Miller | 08fa40c | 2014-04-29 18:18:47 -0700 | [diff] [blame] | 3519 | * of fingerprints. |
| 3520 | * |
| 3521 | * @see #getSystemService |
Jim Miller | ce7eb6d | 2015-04-03 19:29:13 -0700 | [diff] [blame] | 3522 | * @see android.hardware.fingerprint.FingerprintManager |
Jim Miller | 08fa40c | 2014-04-29 18:18:47 -0700 | [diff] [blame] | 3523 | */ |
| 3524 | public static final String FINGERPRINT_SERVICE = "fingerprint"; |
| 3525 | |
| 3526 | /** |
| 3527 | * Use with {@link #getSystemService} to retrieve a |
Dianne Hackborn | b58b8f8 | 2012-06-11 15:08:39 -0700 | [diff] [blame] | 3528 | * {@link android.media.MediaRouter} for controlling and managing |
| 3529 | * routing of media. |
| 3530 | * |
| 3531 | * @see #getSystemService |
| 3532 | * @see android.media.MediaRouter |
| 3533 | */ |
| 3534 | public static final String MEDIA_ROUTER_SERVICE = "media_router"; |
| 3535 | |
| 3536 | /** |
| 3537 | * Use with {@link #getSystemService} to retrieve a |
RoboErik | 42ea7ee | 2014-05-16 16:27:35 -0700 | [diff] [blame] | 3538 | * {@link android.media.session.MediaSessionManager} for managing media Sessions. |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 3539 | * |
| 3540 | * @see #getSystemService |
RoboErik | 42ea7ee | 2014-05-16 16:27:35 -0700 | [diff] [blame] | 3541 | * @see android.media.session.MediaSessionManager |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 3542 | */ |
| 3543 | public static final String MEDIA_SESSION_SERVICE = "media_session"; |
| 3544 | |
| 3545 | /** |
| 3546 | * Use with {@link #getSystemService} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3547 | * {@link android.telephony.TelephonyManager} for handling management the |
| 3548 | * telephony features of the device. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3549 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3550 | * @see #getSystemService |
| 3551 | * @see android.telephony.TelephonyManager |
| 3552 | */ |
| 3553 | public static final String TELEPHONY_SERVICE = "phone"; |
| 3554 | |
| 3555 | /** |
| 3556 | * Use with {@link #getSystemService} to retrieve a |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 3557 | * {@link android.telephony.SubscriptionManager} for handling management the |
| 3558 | * telephony subscriptions of the device. |
| 3559 | * |
| 3560 | * @see #getSystemService |
| 3561 | * @see android.telephony.SubscriptionManager |
| 3562 | */ |
| 3563 | public static final String TELEPHONY_SUBSCRIPTION_SERVICE = "telephony_subscription_service"; |
| 3564 | |
| 3565 | /** |
| 3566 | * Use with {@link #getSystemService} to retrieve a |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 3567 | * {@link android.telecom.TelecomManager} to manage telecom-related features |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 3568 | * of the device. |
| 3569 | * |
| 3570 | * @see #getSystemService |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 3571 | * @see android.telecom.TelecomManager |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 3572 | */ |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 3573 | public static final String TELECOM_SERVICE = "telecom"; |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 3574 | |
| 3575 | /** |
| 3576 | * Use with {@link #getSystemService} to retrieve a |
Jonathan Basseri | 9a1c9b6 | 2015-02-25 13:01:52 -0800 | [diff] [blame] | 3577 | * {@link android.telephony.CarrierConfigManager} for reading carrier configuration values. |
| 3578 | * |
| 3579 | * @see #getSystemService |
| 3580 | * @see android.telephony.CarrierConfigManager |
| 3581 | */ |
| 3582 | public static final String CARRIER_CONFIG_SERVICE = "carrier_config"; |
| 3583 | |
| 3584 | /** |
| 3585 | * Use with {@link #getSystemService} to retrieve a |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 3586 | * {@link android.telephony.euicc.EuiccManager} to manage the device eUICC (embedded SIM). |
| 3587 | * |
| 3588 | * @see #getSystemService |
| 3589 | * @see android.telephony.euicc.EuiccManager |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 3590 | */ |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 3591 | public static final String EUICC_SERVICE = "euicc"; |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 3592 | |
| 3593 | /** |
Holly Jiuyu Sun | 3d6b53c | 2017-12-21 18:44:59 -0800 | [diff] [blame] | 3594 | * Use with {@link #getSystemService(String)} to retrieve a |
| 3595 | * {@link android.telephony.euicc.EuiccCardManager} to access the device eUICC (embedded SIM). |
| 3596 | * |
| 3597 | * @see #getSystemService(String) |
| 3598 | * @see android.telephony.euicc.EuiccCardManager |
Holly Jiuyu Sun | 3d6b53c | 2017-12-21 18:44:59 -0800 | [diff] [blame] | 3599 | * @hide |
| 3600 | */ |
Holly Jiuyu Sun | 052fbab | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 3601 | @SystemApi |
| 3602 | public static final String EUICC_CARD_SERVICE = "euicc_card"; |
Holly Jiuyu Sun | 3d6b53c | 2017-12-21 18:44:59 -0800 | [diff] [blame] | 3603 | |
| 3604 | /** |
| 3605 | * Use with {@link #getSystemService(String)} to retrieve a |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3606 | * {@link android.content.ClipboardManager} for accessing and modifying |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3607 | * the contents of the global clipboard. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3608 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3609 | * @see #getSystemService |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3610 | * @see android.content.ClipboardManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3611 | */ |
| 3612 | public static final String CLIPBOARD_SERVICE = "clipboard"; |
| 3613 | |
| 3614 | /** |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3615 | * Use with {@link #getSystemService} to retrieve a |
Abodunrinwa Toki | f001fef | 2017-01-04 23:51:42 +0000 | [diff] [blame] | 3616 | * {@link TextClassificationManager} for text classification services. |
Abodunrinwa Toki | 8158af5 | 2016-11-23 20:41:09 +0000 | [diff] [blame] | 3617 | * |
| 3618 | * @see #getSystemService |
Abodunrinwa Toki | f001fef | 2017-01-04 23:51:42 +0000 | [diff] [blame] | 3619 | * @see TextClassificationManager |
Abodunrinwa Toki | 8158af5 | 2016-11-23 20:41:09 +0000 | [diff] [blame] | 3620 | */ |
| 3621 | public static final String TEXT_CLASSIFICATION_SERVICE = "textclassification"; |
| 3622 | |
| 3623 | /** |
| 3624 | * Use with {@link #getSystemService} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3625 | * {@link android.view.inputmethod.InputMethodManager} for accessing input |
| 3626 | * methods. |
| 3627 | * |
| 3628 | * @see #getSystemService |
| 3629 | */ |
| 3630 | public static final String INPUT_METHOD_SERVICE = "input_method"; |
| 3631 | |
| 3632 | /** |
| 3633 | * Use with {@link #getSystemService} to retrieve a |
satok | 988323c | 2011-06-22 16:38:13 +0900 | [diff] [blame] | 3634 | * {@link android.view.textservice.TextServicesManager} for accessing |
| 3635 | * text services. |
| 3636 | * |
| 3637 | * @see #getSystemService |
| 3638 | */ |
| 3639 | public static final String TEXT_SERVICES_MANAGER_SERVICE = "textservices"; |
| 3640 | |
| 3641 | /** |
| 3642 | * Use with {@link #getSystemService} to retrieve a |
Dan Egnor | e38d58b | 2009-12-30 19:29:03 -0800 | [diff] [blame] | 3643 | * {@link android.appwidget.AppWidgetManager} for accessing AppWidgets. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3644 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3645 | * @see #getSystemService |
| 3646 | */ |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 3647 | public static final String APPWIDGET_SERVICE = "appwidget"; |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 3648 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3649 | /** |
Dianne Hackborn | 91097de | 2014-04-04 18:02:06 -0700 | [diff] [blame] | 3650 | * Official published name of the (internal) voice interaction manager service. |
| 3651 | * |
| 3652 | * @hide |
| 3653 | * @see #getSystemService |
| 3654 | */ |
| 3655 | public static final String VOICE_INTERACTION_MANAGER_SERVICE = "voiceinteraction"; |
| 3656 | |
| 3657 | /** |
Felipe Leme | 640f30a | 2017-03-06 15:44:06 -0800 | [diff] [blame] | 3658 | * Official published name of the (internal) autofill service. |
Felipe Leme | 5381aa4 | 2016-10-13 09:02:32 -0700 | [diff] [blame] | 3659 | * |
| 3660 | * @hide |
| 3661 | * @see #getSystemService |
| 3662 | */ |
Felipe Leme | 640f30a | 2017-03-06 15:44:06 -0800 | [diff] [blame] | 3663 | public static final String AUTOFILL_MANAGER_SERVICE = "autofill"; |
Felipe Leme | 5381aa4 | 2016-10-13 09:02:32 -0700 | [diff] [blame] | 3664 | |
| 3665 | /** |
Arunesh Mishra | a772e5f | 2016-01-25 10:33:11 -0800 | [diff] [blame] | 3666 | * Use with {@link #getSystemService} to access the |
| 3667 | * {@link com.android.server.voiceinteraction.SoundTriggerService}. |
| 3668 | * |
| 3669 | * @hide |
| 3670 | * @see #getSystemService |
| 3671 | */ |
| 3672 | public static final String SOUND_TRIGGER_SERVICE = "soundtrigger"; |
| 3673 | |
| 3674 | |
| 3675 | /** |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 3676 | * Use with {@link #getSystemService} to retrieve an |
Christopher Tate | 4528186 | 2010-03-05 15:46:30 -0800 | [diff] [blame] | 3677 | * {@link android.app.backup.IBackupManager IBackupManager} for communicating |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 3678 | * with the backup mechanism. |
Dianne Hackborn | 7f20543 | 2009-07-28 00:13:47 -0700 | [diff] [blame] | 3679 | * @hide |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3680 | * |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 3681 | * @see #getSystemService |
| 3682 | */ |
Christopher Tate | d5cf722 | 2014-07-29 16:53:09 -0700 | [diff] [blame] | 3683 | @SystemApi |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 3684 | public static final String BACKUP_SERVICE = "backup"; |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 3685 | |
| 3686 | /** |
| 3687 | * Use with {@link #getSystemService} to retrieve a |
Dan Egnor | 1337b01 | 2010-01-04 11:01:44 -0800 | [diff] [blame] | 3688 | * {@link android.os.DropBoxManager} instance for recording |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 3689 | * diagnostic logs. |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 3690 | * @see #getSystemService |
| 3691 | */ |
| 3692 | public static final String DROPBOX_SERVICE = "dropbox"; |
| 3693 | |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 3694 | /** |
Dianne Hackborn | 1958e5e | 2015-06-12 18:11:41 -0700 | [diff] [blame] | 3695 | * System service name for the DeviceIdleController. There is no Java API for this. |
| 3696 | * @see #getSystemService |
| 3697 | * @hide |
| 3698 | */ |
| 3699 | public static final String DEVICE_IDLE_CONTROLLER = "deviceidle"; |
| 3700 | |
| 3701 | /** |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3702 | * Use with {@link #getSystemService} to retrieve a |
Dianne Hackborn | 87bba1e | 2010-02-26 17:25:54 -0800 | [diff] [blame] | 3703 | * {@link android.app.admin.DevicePolicyManager} for working with global |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 3704 | * device policy management. |
| 3705 | * |
| 3706 | * @see #getSystemService |
| 3707 | */ |
| 3708 | public static final String DEVICE_POLICY_SERVICE = "device_policy"; |
| 3709 | |
| 3710 | /** |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 3711 | * Use with {@link #getSystemService} to retrieve a |
| 3712 | * {@link android.app.UiModeManager} for controlling UI modes. |
| 3713 | * |
| 3714 | * @see #getSystemService |
| 3715 | */ |
| 3716 | public static final String UI_MODE_SERVICE = "uimode"; |
| 3717 | |
| 3718 | /** |
Steve Howard | a270936 | 2010-07-02 17:12:48 -0700 | [diff] [blame] | 3719 | * Use with {@link #getSystemService} to retrieve a |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 3720 | * {@link android.app.DownloadManager} for requesting HTTP downloads. |
Steve Howard | a270936 | 2010-07-02 17:12:48 -0700 | [diff] [blame] | 3721 | * |
| 3722 | * @see #getSystemService |
Steve Howard | a270936 | 2010-07-02 17:12:48 -0700 | [diff] [blame] | 3723 | */ |
| 3724 | public static final String DOWNLOAD_SERVICE = "download"; |
| 3725 | |
| 3726 | /** |
Chung-yih Wang | 2d94231 | 2010-08-05 12:17:37 +0800 | [diff] [blame] | 3727 | * Use with {@link #getSystemService} to retrieve a |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 3728 | * {@link android.os.BatteryManager} for managing battery state. |
| 3729 | * |
| 3730 | * @see #getSystemService |
| 3731 | */ |
| 3732 | public static final String BATTERY_SERVICE = "batterymanager"; |
| 3733 | |
| 3734 | /** |
| 3735 | * Use with {@link #getSystemService} to retrieve a |
Nick Pelly | 50b4d8f | 2010-12-07 22:40:28 -0800 | [diff] [blame] | 3736 | * {@link android.nfc.NfcManager} for using NFC. |
| 3737 | * |
| 3738 | * @see #getSystemService |
| 3739 | */ |
| 3740 | public static final String NFC_SERVICE = "nfc"; |
| 3741 | |
| 3742 | /** |
| 3743 | * Use with {@link #getSystemService} to retrieve a |
Florian Salbrechter | 084da9b | 2015-03-25 11:00:55 +0000 | [diff] [blame] | 3744 | * {@link android.bluetooth.BluetoothManager} for using Bluetooth. |
Jaikumar Ganesh | 1abb1cb | 2012-01-25 16:14:50 -0800 | [diff] [blame] | 3745 | * |
| 3746 | * @see #getSystemService |
Jaikumar Ganesh | 1abb1cb | 2012-01-25 16:14:50 -0800 | [diff] [blame] | 3747 | */ |
| 3748 | public static final String BLUETOOTH_SERVICE = "bluetooth"; |
| 3749 | |
| 3750 | /** |
| 3751 | * Use with {@link #getSystemService} to retrieve a |
Chung-yih Wang | 2d94231 | 2010-08-05 12:17:37 +0800 | [diff] [blame] | 3752 | * {@link android.net.sip.SipManager} for accessing the SIP related service. |
| 3753 | * |
| 3754 | * @see #getSystemService |
| 3755 | */ |
| 3756 | /** @hide */ |
| 3757 | public static final String SIP_SERVICE = "sip"; |
| 3758 | |
| 3759 | /** |
Mike Lockwood | e7d511e | 2010-12-30 13:39:37 -0500 | [diff] [blame] | 3760 | * Use with {@link #getSystemService} to retrieve a {@link |
Mike Lockwood | c4308f0 | 2011-03-01 08:04:54 -0800 | [diff] [blame] | 3761 | * 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] | 3762 | * and for controlling this device's behavior as a USB device. |
| 3763 | * |
| 3764 | * @see #getSystemService |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3765 | * @see android.hardware.usb.UsbManager |
Mike Lockwood | e7d511e | 2010-12-30 13:39:37 -0500 | [diff] [blame] | 3766 | */ |
| 3767 | public static final String USB_SERVICE = "usb"; |
| 3768 | |
| 3769 | /** |
Mike Lockwood | b01e8bf | 2011-08-29 20:11:07 -0400 | [diff] [blame] | 3770 | * Use with {@link #getSystemService} to retrieve a {@link |
| 3771 | * android.hardware.SerialManager} for access to serial ports. |
| 3772 | * |
| 3773 | * @see #getSystemService |
Dianne Hackborn | 35f72be | 2013-09-16 10:57:39 -0700 | [diff] [blame] | 3774 | * @see android.hardware.SerialManager |
Mike Lockwood | b01e8bf | 2011-08-29 20:11:07 -0400 | [diff] [blame] | 3775 | * |
| 3776 | * @hide |
| 3777 | */ |
| 3778 | public static final String SERIAL_SERVICE = "serial"; |
| 3779 | |
| 3780 | /** |
Jeff Brown | 9df6e7a | 2012-04-05 11:49:26 -0700 | [diff] [blame] | 3781 | * Use with {@link #getSystemService} to retrieve a |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 3782 | * {@link android.hardware.hdmi.HdmiControlManager} for controlling and managing |
| 3783 | * HDMI-CEC protocol. |
| 3784 | * |
| 3785 | * @see #getSystemService |
| 3786 | * @see android.hardware.hdmi.HdmiControlManager |
Jinsuk Kim | 66d1eb2 | 2014-06-06 16:12:18 +0900 | [diff] [blame] | 3787 | * @hide |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 3788 | */ |
Jinsuk Kim | 66d1eb2 | 2014-06-06 16:12:18 +0900 | [diff] [blame] | 3789 | @SystemApi |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 3790 | public static final String HDMI_CONTROL_SERVICE = "hdmi_control"; |
Jinsuk Kim | fbcd503 | 2014-03-21 16:25:13 +0900 | [diff] [blame] | 3791 | |
| 3792 | /** |
| 3793 | * Use with {@link #getSystemService} to retrieve a |
Jeff Brown | 9df6e7a | 2012-04-05 11:49:26 -0700 | [diff] [blame] | 3794 | * {@link android.hardware.input.InputManager} for interacting with input devices. |
| 3795 | * |
| 3796 | * @see #getSystemService |
| 3797 | * @see android.hardware.input.InputManager |
| 3798 | */ |
| 3799 | public static final String INPUT_SERVICE = "input"; |
| 3800 | |
| 3801 | /** |
Glenn Kasten | 07b0465 | 2012-04-23 15:00:43 -0700 | [diff] [blame] | 3802 | * Use with {@link #getSystemService} to retrieve a |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 3803 | * {@link android.hardware.display.DisplayManager} for interacting with display devices. |
| 3804 | * |
| 3805 | * @see #getSystemService |
| 3806 | * @see android.hardware.display.DisplayManager |
| 3807 | */ |
| 3808 | public static final String DISPLAY_SERVICE = "display"; |
| 3809 | |
| 3810 | /** |
| 3811 | * Use with {@link #getSystemService} to retrieve a |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 3812 | * {@link android.os.UserManager} for managing users on devices that support multiple users. |
| 3813 | * |
| 3814 | * @see #getSystemService |
| 3815 | * @see android.os.UserManager |
| 3816 | */ |
| 3817 | public static final String USER_SERVICE = "user"; |
| 3818 | |
| 3819 | /** |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 3820 | * Use with {@link #getSystemService} to retrieve a |
Amith Yamasani | 4f58263 | 2014-02-19 14:31:52 -0800 | [diff] [blame] | 3821 | * {@link android.content.pm.LauncherApps} for querying and monitoring launchable apps across |
| 3822 | * profiles of a user. |
| 3823 | * |
| 3824 | * @see #getSystemService |
| 3825 | * @see android.content.pm.LauncherApps |
| 3826 | */ |
| 3827 | public static final String LAUNCHER_APPS_SERVICE = "launcherapps"; |
| 3828 | |
| 3829 | /** |
| 3830 | * Use with {@link #getSystemService} to retrieve a |
Amith Yamasani | f20d640 | 2014-05-24 15:34:37 -0700 | [diff] [blame] | 3831 | * {@link android.content.RestrictionsManager} for retrieving application restrictions |
| 3832 | * and requesting permissions for restricted operations. |
| 3833 | * @see #getSystemService |
| 3834 | * @see android.content.RestrictionsManager |
| 3835 | */ |
| 3836 | public static final String RESTRICTIONS_SERVICE = "restrictions"; |
| 3837 | |
| 3838 | /** |
| 3839 | * Use with {@link #getSystemService} to retrieve a |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 3840 | * {@link android.app.AppOpsManager} for tracking application operations |
| 3841 | * on the device. |
| 3842 | * |
| 3843 | * @see #getSystemService |
| 3844 | * @see android.app.AppOpsManager |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 3845 | */ |
| 3846 | public static final String APP_OPS_SERVICE = "appops"; |
| 3847 | |
| 3848 | /** |
Eino-Ville Talvala | b267554 | 2012-12-12 13:29:45 -0800 | [diff] [blame] | 3849 | * Use with {@link #getSystemService} to retrieve a |
Eino-Ville Talvala | 2f1a2e4 | 2013-07-25 17:12:05 -0700 | [diff] [blame] | 3850 | * {@link android.hardware.camera2.CameraManager} for interacting with |
Eino-Ville Talvala | b267554 | 2012-12-12 13:29:45 -0800 | [diff] [blame] | 3851 | * camera devices. |
| 3852 | * |
| 3853 | * @see #getSystemService |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 3854 | * @see android.hardware.camera2.CameraManager |
Eino-Ville Talvala | b267554 | 2012-12-12 13:29:45 -0800 | [diff] [blame] | 3855 | */ |
| 3856 | public static final String CAMERA_SERVICE = "camera"; |
| 3857 | |
| 3858 | /** |
Svetoslav Ganov | 4b9a4d1 | 2013-06-11 15:20:06 -0700 | [diff] [blame] | 3859 | * {@link android.print.PrintManager} for printing and managing |
Jeff Brown | 511cd35 | 2013-08-23 17:43:37 -0700 | [diff] [blame] | 3860 | * printers and print tasks. |
Svetoslav Ganov | 4b9a4d1 | 2013-06-11 15:20:06 -0700 | [diff] [blame] | 3861 | * |
| 3862 | * @see #getSystemService |
| 3863 | * @see android.print.PrintManager |
| 3864 | */ |
| 3865 | public static final String PRINT_SERVICE = "print"; |
| 3866 | |
| 3867 | /** |
Eugene Susla | 4160be1 | 2017-04-18 12:29:10 -0700 | [diff] [blame] | 3868 | * Use with {@link #getSystemService} to retrieve a |
Eugene Susla | 6ed45d8 | 2017-01-22 13:52:51 -0800 | [diff] [blame] | 3869 | * {@link android.companion.CompanionDeviceManager} for managing companion devices |
| 3870 | * |
| 3871 | * @see #getSystemService |
| 3872 | * @see android.companion.CompanionDeviceManager |
| 3873 | */ |
Eugene Susla | d7355cc | 2017-04-20 11:14:45 -0700 | [diff] [blame] | 3874 | public static final String COMPANION_DEVICE_SERVICE = "companiondevice"; |
Eugene Susla | 6ed45d8 | 2017-01-22 13:52:51 -0800 | [diff] [blame] | 3875 | |
| 3876 | /** |
Erik Gilling | 51e95df | 2013-06-26 11:06:51 -0700 | [diff] [blame] | 3877 | * Use with {@link #getSystemService} to retrieve a |
| 3878 | * {@link android.hardware.ConsumerIrManager} for transmitting infrared |
| 3879 | * signals from the device. |
| 3880 | * |
| 3881 | * @see #getSystemService |
| 3882 | * @see android.hardware.ConsumerIrManager |
| 3883 | */ |
| 3884 | public static final String CONSUMER_IR_SERVICE = "consumer_ir"; |
| 3885 | |
| 3886 | /** |
Adrian Roos | 82142c2 | 2014-03-27 14:56:59 +0100 | [diff] [blame] | 3887 | * {@link android.app.trust.TrustManager} for managing trust agents. |
| 3888 | * @see #getSystemService |
| 3889 | * @see android.app.trust.TrustManager |
| 3890 | * @hide |
| 3891 | */ |
| 3892 | public static final String TRUST_SERVICE = "trust"; |
| 3893 | |
| 3894 | /** |
Jae Seo | 3957091 | 2014-02-20 18:23:25 -0800 | [diff] [blame] | 3895 | * Use with {@link #getSystemService} to retrieve a |
Jae Seo | d5cc4a2 | 2014-05-30 16:57:43 -0700 | [diff] [blame] | 3896 | * {@link android.media.tv.TvInputManager} for interacting with TV inputs |
| 3897 | * on the device. |
Jae Seo | 3957091 | 2014-02-20 18:23:25 -0800 | [diff] [blame] | 3898 | * |
| 3899 | * @see #getSystemService |
Jae Seo | d5cc4a2 | 2014-05-30 16:57:43 -0700 | [diff] [blame] | 3900 | * @see android.media.tv.TvInputManager |
Jae Seo | 3957091 | 2014-02-20 18:23:25 -0800 | [diff] [blame] | 3901 | */ |
| 3902 | public static final String TV_INPUT_SERVICE = "tv_input"; |
| 3903 | |
| 3904 | /** |
Jeff Davidson | b51e0a6 | 2014-04-09 12:38:15 -0700 | [diff] [blame] | 3905 | * {@link android.net.NetworkScoreManager} for managing network scoring. |
| 3906 | * @see #getSystemService |
| 3907 | * @see android.net.NetworkScoreManager |
| 3908 | * @hide |
| 3909 | */ |
Jeff Davidson | 5ad2079 | 2014-07-21 13:55:42 -0700 | [diff] [blame] | 3910 | @SystemApi |
Jeff Davidson | b51e0a6 | 2014-04-09 12:38:15 -0700 | [diff] [blame] | 3911 | public static final String NETWORK_SCORE_SERVICE = "network_score"; |
| 3912 | |
| 3913 | /** |
Dianne Hackborn | e22b3b1 | 2014-05-07 18:06:44 -0700 | [diff] [blame] | 3914 | * Use with {@link #getSystemService} to retrieve a {@link |
Adam Lesinski | aa60767 | 2014-11-24 11:27:50 -0800 | [diff] [blame] | 3915 | * android.app.usage.UsageStatsManager} for querying device usage stats. |
Dianne Hackborn | e22b3b1 | 2014-05-07 18:06:44 -0700 | [diff] [blame] | 3916 | * |
| 3917 | * @see #getSystemService |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 3918 | * @see android.app.usage.UsageStatsManager |
Dianne Hackborn | e22b3b1 | 2014-05-07 18:06:44 -0700 | [diff] [blame] | 3919 | */ |
| 3920 | public static final String USAGE_STATS_SERVICE = "usagestats"; |
| 3921 | |
| 3922 | /** |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 3923 | * Use with {@link #getSystemService} to retrieve a {@link |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 3924 | * android.app.job.JobScheduler} instance for managing occasional |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 3925 | * background tasks. |
| 3926 | * @see #getSystemService |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 3927 | * @see android.app.job.JobScheduler |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 3928 | */ |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 3929 | public static final String JOB_SCHEDULER_SERVICE = "jobscheduler"; |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 3930 | |
| 3931 | /** |
Andres Morales | 68d4acd | 2014-07-01 19:40:41 -0700 | [diff] [blame] | 3932 | * Use with {@link #getSystemService} to retrieve a {@link |
Andres Morales | 33df937 | 2014-09-26 17:08:59 -0700 | [diff] [blame] | 3933 | * android.service.persistentdata.PersistentDataBlockManager} instance |
| 3934 | * for interacting with a storage device that lives across factory resets. |
| 3935 | * |
Andres Morales | 68d4acd | 2014-07-01 19:40:41 -0700 | [diff] [blame] | 3936 | * @see #getSystemService |
| 3937 | * @see android.service.persistentdata.PersistentDataBlockManager |
| 3938 | * @hide |
| 3939 | */ |
Andres Morales | 33df937 | 2014-09-26 17:08:59 -0700 | [diff] [blame] | 3940 | @SystemApi |
Andres Morales | 68d4acd | 2014-07-01 19:40:41 -0700 | [diff] [blame] | 3941 | public static final String PERSISTENT_DATA_BLOCK_SERVICE = "persistent_data_block"; |
| 3942 | |
| 3943 | /** |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 3944 | * Use with {@link #getSystemService} to retrieve a {@link |
Andrew Scull | 3b8b46f | 2017-02-13 18:12:15 +0000 | [diff] [blame] | 3945 | * android.service.oemlock.OemLockManager} instance for managing the OEM lock. |
| 3946 | * |
| 3947 | * @see #getSystemService |
| 3948 | * @see android.service.oemlock.OemLockManager |
| 3949 | * @hide |
| 3950 | */ |
| 3951 | @SystemApi |
| 3952 | public static final String OEM_LOCK_SERVICE = "oem_lock"; |
| 3953 | |
| 3954 | /** |
| 3955 | * Use with {@link #getSystemService} to retrieve a {@link |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 3956 | * android.media.projection.MediaProjectionManager} instance for managing |
| 3957 | * media projection sessions. |
| 3958 | * @see #getSystemService |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3959 | * @see android.media.projection.MediaProjectionManager |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 3960 | */ |
| 3961 | public static final String MEDIA_PROJECTION_SERVICE = "media_projection"; |
| 3962 | |
| 3963 | /** |
Mike Lockwood | 67f8e8b | 2014-12-01 13:54:59 -0800 | [diff] [blame] | 3964 | * Use with {@link #getSystemService} to retrieve a |
Mike Lockwood | b673770 | 2015-02-20 08:28:47 -0800 | [diff] [blame] | 3965 | * {@link android.media.midi.MidiManager} for accessing the MIDI service. |
Mike Lockwood | 67f8e8b | 2014-12-01 13:54:59 -0800 | [diff] [blame] | 3966 | * |
| 3967 | * @see #getSystemService |
Mike Lockwood | 67f8e8b | 2014-12-01 13:54:59 -0800 | [diff] [blame] | 3968 | */ |
| 3969 | public static final String MIDI_SERVICE = "midi"; |
| 3970 | |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 3971 | |
| 3972 | /** |
| 3973 | * Use with {@link #getSystemService} to retrieve a |
| 3974 | * {@link android.hardware.radio.RadioManager} for accessing the broadcast radio service. |
| 3975 | * |
| 3976 | * @see #getSystemService |
| 3977 | * @hide |
| 3978 | */ |
Tomasz Wasilczyk | 9110df7 | 2017-06-22 07:57:20 -0700 | [diff] [blame] | 3979 | public static final String RADIO_SERVICE = "broadcastradio"; |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 3980 | |
Paul McLean | a33be21 | 2015-02-20 07:52:45 -0800 | [diff] [blame] | 3981 | /** |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 3982 | * Use with {@link #getSystemService} to retrieve a |
| 3983 | * {@link android.os.HardwarePropertiesManager} for accessing the hardware properties service. |
| 3984 | * |
| 3985 | * @see #getSystemService |
| 3986 | */ |
Polina Bondarenko | 8333c73 | 2016-03-09 18:08:42 +0100 | [diff] [blame] | 3987 | public static final String HARDWARE_PROPERTIES_SERVICE = "hardware_properties"; |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 3988 | |
| 3989 | /** |
Makoto Onuki | b5a012f | 2016-06-21 11:13:53 -0700 | [diff] [blame] | 3990 | * Use with {@link #getSystemService} to retrieve a |
| 3991 | * {@link android.content.pm.ShortcutManager} for accessing the launcher shortcut service. |
Makoto Onuki | 6f7362d9 | 2016-03-04 13:39:41 -0800 | [diff] [blame] | 3992 | * |
| 3993 | * @see #getSystemService |
| 3994 | * @see android.content.pm.ShortcutManager |
| 3995 | */ |
| 3996 | public static final String SHORTCUT_SERVICE = "shortcut"; |
| 3997 | |
| 3998 | /** |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 3999 | * Use with {@link #getSystemService} to retrieve a {@link |
| 4000 | * android.hardware.location.ContextHubManager} for accessing context hubs. |
| 4001 | * |
| 4002 | * @see #getSystemService |
| 4003 | * @see android.hardware.location.ContextHubManager |
| 4004 | * |
| 4005 | * @hide |
| 4006 | */ |
| 4007 | @SystemApi |
| 4008 | public static final String CONTEXTHUB_SERVICE = "contexthub"; |
| 4009 | |
| 4010 | /** |
Joe Onorato | 713fec8 | 2016-03-04 10:34:02 -0800 | [diff] [blame] | 4011 | * Use with {@link #getSystemService} to retrieve a |
| 4012 | * {@link android.os.health.SystemHealthManager} for accessing system health (battery, power, |
| 4013 | * memory, etc) metrics. |
| 4014 | * |
| 4015 | * @see #getSystemService |
| 4016 | */ |
| 4017 | public static final String SYSTEM_HEALTH_SERVICE = "systemhealth"; |
| 4018 | |
| 4019 | /** |
Amith Yamasani | d04aaa3 | 2016-06-13 12:09:36 -0700 | [diff] [blame] | 4020 | * Gatekeeper Service. |
| 4021 | * @hide |
| 4022 | */ |
| 4023 | public static final String GATEKEEPER_SERVICE = "android.service.gatekeeper.IGateKeeperService"; |
| 4024 | |
| 4025 | /** |
Svet Ganov | 37e4327 | 2016-09-09 16:01:32 -0700 | [diff] [blame] | 4026 | * Service defining the policy for access to device identifiers. |
| 4027 | * @hide |
| 4028 | */ |
| 4029 | public static final String DEVICE_IDENTIFIERS_SERVICE = "device_identifiers"; |
| 4030 | |
| 4031 | /** |
Joe Onorato | 1754d74 | 2016-11-21 17:51:35 -0800 | [diff] [blame] | 4032 | * Service to report a system health "incident" |
| 4033 | * @hide |
| 4034 | */ |
| 4035 | public static final String INCIDENT_SERVICE = "incident"; |
| 4036 | |
| 4037 | /** |
MÃ¥rten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 4038 | * Use with {@link #getSystemService} to retrieve a {@link |
| 4039 | * android.content.om.OverlayManager} for managing overlay packages. |
| 4040 | * |
| 4041 | * @see #getSystemService |
| 4042 | * @see android.content.om.OverlayManager |
| 4043 | * @hide |
| 4044 | */ |
| 4045 | public static final String OVERLAY_SERVICE = "overlay"; |
| 4046 | |
| 4047 | /** |
Zak Cohen | 56345f4 | 2017-01-26 13:54:28 -0800 | [diff] [blame] | 4048 | * Use with {@link #getSystemService} to retrieve a |
| 4049 | * {@link VrManager} for accessing the VR service. |
| 4050 | * |
| 4051 | * @see #getSystemService |
| 4052 | * @hide |
| 4053 | */ |
| 4054 | @SystemApi |
| 4055 | public static final String VR_SERVICE = "vrmanager"; |
| 4056 | |
| 4057 | /** |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 4058 | * Use with {@link #getSystemService} to retrieve an |
| 4059 | * {@link android.app.timezone.ITimeZoneRulesManager}. |
| 4060 | * @hide |
| 4061 | * |
| 4062 | * @see #getSystemService |
| 4063 | */ |
| 4064 | public static final String TIME_ZONE_RULES_MANAGER_SERVICE = "timezone"; |
| 4065 | |
| 4066 | /** |
Ruchi Kandoi | dcf4c6d | 2018-01-03 16:14:57 -0800 | [diff] [blame] | 4067 | * Use with {@link #getSystemService} to retrieve a |
| 4068 | * {@link android.se.omapi.ISecureElementService} |
| 4069 | * for accessing the SecureElementService. |
| 4070 | * |
| 4071 | * @hide |
| 4072 | */ |
| 4073 | @SystemApi |
| 4074 | public static final String SECURE_ELEMENT_SERVICE = "secure_element"; |
| 4075 | |
| 4076 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4077 | * Determine whether the given permission is allowed for a particular |
| 4078 | * process and user ID running in the system. |
| 4079 | * |
| 4080 | * @param permission The name of the permission being checked. |
| 4081 | * @param pid The process ID being checked against. Must be > 0. |
| 4082 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 4083 | * user, which will pass every permission check. |
| 4084 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4085 | * @return {@link PackageManager#PERMISSION_GRANTED} if the given |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4086 | * pid/uid is allowed that permission, or |
| 4087 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4088 | * |
| 4089 | * @see PackageManager#checkPermission(String, String) |
| 4090 | * @see #checkCallingPermission |
| 4091 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4092 | @CheckResult(suggest="#enforcePermission(String,int,int,String)") |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4093 | @PackageManager.PermissionResult |
| 4094 | 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] | 4095 | |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 4096 | /** @hide */ |
| 4097 | @PackageManager.PermissionResult |
| 4098 | public abstract int checkPermission(@NonNull String permission, int pid, int uid, |
| 4099 | IBinder callerToken); |
| 4100 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4101 | /** |
| 4102 | * Determine whether the calling process of an IPC you are handling has been |
| 4103 | * granted a particular permission. This is basically the same as calling |
| 4104 | * {@link #checkPermission(String, int, int)} with the pid and uid returned |
| 4105 | * by {@link android.os.Binder#getCallingPid} and |
| 4106 | * {@link android.os.Binder#getCallingUid}. One important difference |
| 4107 | * is that if you are not currently processing an IPC, this function |
| 4108 | * will always fail. This is done to protect against accidentally |
| 4109 | * leaking permissions; you can use {@link #checkCallingOrSelfPermission} |
| 4110 | * to avoid this protection. |
| 4111 | * |
| 4112 | * @param permission The name of the permission being checked. |
| 4113 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4114 | * @return {@link PackageManager#PERMISSION_GRANTED} if the calling |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4115 | * pid/uid is allowed that permission, or |
| 4116 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4117 | * |
| 4118 | * @see PackageManager#checkPermission(String, String) |
| 4119 | * @see #checkPermission |
| 4120 | * @see #checkCallingOrSelfPermission |
| 4121 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4122 | @CheckResult(suggest="#enforceCallingPermission(String,String)") |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4123 | @PackageManager.PermissionResult |
| 4124 | public abstract int checkCallingPermission(@NonNull String permission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4125 | |
| 4126 | /** |
| 4127 | * Determine whether the calling process of an IPC <em>or you</em> have been |
| 4128 | * granted a particular permission. This is the same as |
| 4129 | * {@link #checkCallingPermission}, except it grants your own permissions |
| 4130 | * if you are not currently processing an IPC. Use with care! |
| 4131 | * |
| 4132 | * @param permission The name of the permission being checked. |
| 4133 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4134 | * @return {@link PackageManager#PERMISSION_GRANTED} if the calling |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4135 | * pid/uid is allowed that permission, or |
| 4136 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4137 | * |
| 4138 | * @see PackageManager#checkPermission(String, String) |
| 4139 | * @see #checkPermission |
| 4140 | * @see #checkCallingPermission |
| 4141 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4142 | @CheckResult(suggest="#enforceCallingOrSelfPermission(String,String)") |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4143 | @PackageManager.PermissionResult |
| 4144 | public abstract int checkCallingOrSelfPermission(@NonNull String permission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4145 | |
| 4146 | /** |
Svetoslav | c6d1c34 | 2015-02-26 14:44:43 -0800 | [diff] [blame] | 4147 | * Determine whether <em>you</em> have been granted a particular permission. |
| 4148 | * |
| 4149 | * @param permission The name of the permission being checked. |
| 4150 | * |
| 4151 | * @return {@link PackageManager#PERMISSION_GRANTED} if you have the |
| 4152 | * permission, or {@link PackageManager#PERMISSION_DENIED} if not. |
| 4153 | * |
| 4154 | * @see PackageManager#checkPermission(String, String) |
| 4155 | * @see #checkCallingPermission(String) |
| 4156 | */ |
| 4157 | @PackageManager.PermissionResult |
| 4158 | public abstract int checkSelfPermission(@NonNull String permission); |
| 4159 | |
| 4160 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4161 | * If the given permission is not allowed for a particular process |
| 4162 | * and user ID running in the system, throw a {@link SecurityException}. |
| 4163 | * |
| 4164 | * @param permission The name of the permission being checked. |
| 4165 | * @param pid The process ID being checked against. Must be > 0. |
| 4166 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 4167 | * user, which will pass every permission check. |
| 4168 | * @param message A message to include in the exception if it is thrown. |
| 4169 | * |
| 4170 | * @see #checkPermission(String, int, int) |
| 4171 | */ |
| 4172 | public abstract void enforcePermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4173 | @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] | 4174 | |
| 4175 | /** |
| 4176 | * If the calling process of an IPC you are handling has not been |
| 4177 | * granted a particular permission, throw a {@link |
| 4178 | * SecurityException}. This is basically the same as calling |
| 4179 | * {@link #enforcePermission(String, int, int, String)} with the |
| 4180 | * pid and uid returned by {@link android.os.Binder#getCallingPid} |
| 4181 | * and {@link android.os.Binder#getCallingUid}. One important |
| 4182 | * difference is that if you are not currently processing an IPC, |
| 4183 | * this function will always throw the SecurityException. This is |
| 4184 | * done to protect against accidentally leaking permissions; you |
| 4185 | * can use {@link #enforceCallingOrSelfPermission} to avoid this |
| 4186 | * protection. |
| 4187 | * |
| 4188 | * @param permission The name of the permission being checked. |
| 4189 | * @param message A message to include in the exception if it is thrown. |
| 4190 | * |
| 4191 | * @see #checkCallingPermission(String) |
| 4192 | */ |
| 4193 | public abstract void enforceCallingPermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4194 | @NonNull String permission, @Nullable String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4195 | |
| 4196 | /** |
| 4197 | * If neither you nor the calling process of an IPC you are |
| 4198 | * handling has been granted a particular permission, throw a |
| 4199 | * {@link SecurityException}. This is the same as {@link |
| 4200 | * #enforceCallingPermission}, except it grants your own |
| 4201 | * permissions if you are not currently processing an IPC. Use |
| 4202 | * with care! |
| 4203 | * |
| 4204 | * @param permission The name of the permission being checked. |
| 4205 | * @param message A message to include in the exception if it is thrown. |
| 4206 | * |
| 4207 | * @see #checkCallingOrSelfPermission(String) |
| 4208 | */ |
| 4209 | public abstract void enforceCallingOrSelfPermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4210 | @NonNull String permission, @Nullable String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4211 | |
| 4212 | /** |
| 4213 | * Grant permission to access a specific Uri to another package, regardless |
| 4214 | * of whether that package has general permission to access the Uri's |
| 4215 | * content provider. This can be used to grant specific, temporary |
| 4216 | * permissions, typically in response to user interaction (such as the |
| 4217 | * user opening an attachment that you would like someone else to |
| 4218 | * display). |
| 4219 | * |
| 4220 | * <p>Normally you should use {@link Intent#FLAG_GRANT_READ_URI_PERMISSION |
| 4221 | * Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 4222 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
| 4223 | * Intent.FLAG_GRANT_WRITE_URI_PERMISSION} with the Intent being used to |
| 4224 | * start an activity instead of this function directly. If you use this |
| 4225 | * function directly, you should be sure to call |
| 4226 | * {@link #revokeUriPermission} when the target should no longer be allowed |
| 4227 | * to access it. |
| 4228 | * |
| 4229 | * <p>To succeed, the content provider owning the Uri must have set the |
| 4230 | * {@link android.R.styleable#AndroidManifestProvider_grantUriPermissions |
| 4231 | * grantUriPermissions} attribute in its manifest or included the |
| 4232 | * {@link android.R.styleable#AndroidManifestGrantUriPermission |
| 4233 | * <grant-uri-permissions>} tag. |
| 4234 | * |
| 4235 | * @param toPackage The package you would like to allow to access the Uri. |
| 4236 | * @param uri The Uri you would like to grant access to. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4237 | * @param modeFlags The desired access modes. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4238 | * |
| 4239 | * @see #revokeUriPermission |
| 4240 | */ |
| 4241 | public abstract void grantUriPermission(String toPackage, Uri uri, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4242 | @Intent.GrantUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4243 | |
| 4244 | /** |
| 4245 | * Remove all permissions to access a particular content provider Uri |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 4246 | * that were previously added with {@link #grantUriPermission} or <em>any other</em> mechanism. |
| 4247 | * 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] | 4248 | * 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] | 4249 | * revoke both "content://foo/target" and "content://foo/target/sub", but not |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4250 | * "content://foo". It will not remove any prefix grants that exist at a |
| 4251 | * higher level. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4252 | * |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 4253 | * <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] | 4254 | * regular permission access to a Uri, but had received access to it through |
| 4255 | * a specific Uri permission grant, you could not revoke that grant with this |
| 4256 | * function and a {@link SecurityException} would be thrown. As of |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 4257 | * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this function will not throw a security |
| 4258 | * 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] | 4259 | * (or none).</p> |
| 4260 | * |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 4261 | * <p>Unlike {@link #revokeUriPermission(String, Uri, int)}, this method impacts all permission |
| 4262 | * grants matching the given Uri, for any package they had been granted to, through any |
| 4263 | * mechanism this had happened (such as indirectly through the clipboard, activity launch, |
| 4264 | * service start, etc). That means this can be potentially dangerous to use, as it can |
| 4265 | * revoke grants that another app could be strongly expecting to stick around.</p> |
| 4266 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4267 | * @param uri The Uri you would like to revoke access to. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4268 | * @param modeFlags The access modes to revoke. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4269 | * |
| 4270 | * @see #grantUriPermission |
| 4271 | */ |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4272 | 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] | 4273 | |
| 4274 | /** |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 4275 | * Remove permissions to access a particular content provider Uri |
| 4276 | * that were previously added with {@link #grantUriPermission} for a specific target |
| 4277 | * package. The given Uri will match all previously granted Uris that are the same or a |
| 4278 | * sub-path of the given Uri. That is, revoking "content://foo/target" will |
| 4279 | * revoke both "content://foo/target" and "content://foo/target/sub", but not |
| 4280 | * "content://foo". It will not remove any prefix grants that exist at a |
| 4281 | * higher level. |
| 4282 | * |
| 4283 | * <p>Unlike {@link #revokeUriPermission(Uri, int)}, this method will <em>only</em> |
| 4284 | * revoke permissions that had been explicitly granted through {@link #grantUriPermission} |
| 4285 | * and only for the package specified. Any matching grants that have happened through |
| 4286 | * other mechanisms (clipboard, activity launching, service starting, etc) will not be |
| 4287 | * removed.</p> |
| 4288 | * |
| 4289 | * @param toPackage The package you had previously granted access to. |
| 4290 | * @param uri The Uri you would like to revoke access to. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4291 | * @param modeFlags The access modes to revoke. |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 4292 | * |
| 4293 | * @see #grantUriPermission |
| 4294 | */ |
| 4295 | public abstract void revokeUriPermission(String toPackage, Uri uri, |
| 4296 | @Intent.AccessUriMode int modeFlags); |
| 4297 | |
| 4298 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4299 | * Determine whether a particular process and user ID has been granted |
| 4300 | * permission to access a specific URI. This only checks for permissions |
| 4301 | * that have been explicitly granted -- if the given process/uid has |
| 4302 | * more general access to the URI's content provider then this check will |
| 4303 | * always fail. |
| 4304 | * |
| 4305 | * @param uri The uri that is being checked. |
| 4306 | * @param pid The process ID being checked against. Must be > 0. |
| 4307 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 4308 | * user, which will pass every permission check. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4309 | * @param modeFlags The access modes to check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4310 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4311 | * @return {@link PackageManager#PERMISSION_GRANTED} if the given |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4312 | * pid/uid is allowed to access that uri, or |
| 4313 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4314 | * |
| 4315 | * @see #checkCallingUriPermission |
| 4316 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4317 | @CheckResult(suggest="#enforceUriPermission(Uri,int,int,String)") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 4318 | @PackageManager.PermissionResult |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4319 | public abstract int checkUriPermission(Uri uri, int pid, int uid, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4320 | @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4321 | |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 4322 | /** @hide */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 4323 | @PackageManager.PermissionResult |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 4324 | public abstract int checkUriPermission(Uri uri, int pid, int uid, |
| 4325 | @Intent.AccessUriMode int modeFlags, IBinder callerToken); |
| 4326 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4327 | /** |
| 4328 | * Determine whether the calling process and user ID has been |
| 4329 | * granted permission to access a specific URI. This is basically |
| 4330 | * the same as calling {@link #checkUriPermission(Uri, int, int, |
| 4331 | * int)} with the pid and uid returned by {@link |
| 4332 | * android.os.Binder#getCallingPid} and {@link |
| 4333 | * android.os.Binder#getCallingUid}. One important difference is |
| 4334 | * that if you are not currently processing an IPC, this function |
| 4335 | * will always fail. |
| 4336 | * |
| 4337 | * @param uri The uri that is being checked. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4338 | * @param modeFlags The access modes to check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4339 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4340 | * @return {@link PackageManager#PERMISSION_GRANTED} if the caller |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4341 | * is allowed to access that uri, or |
| 4342 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4343 | * |
| 4344 | * @see #checkUriPermission(Uri, int, int, int) |
| 4345 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4346 | @CheckResult(suggest="#enforceCallingUriPermission(Uri,int,String)") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 4347 | @PackageManager.PermissionResult |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4348 | 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] | 4349 | |
| 4350 | /** |
| 4351 | * Determine whether the calling process of an IPC <em>or you</em> has been granted |
| 4352 | * permission to access a specific URI. This is the same as |
| 4353 | * {@link #checkCallingUriPermission}, except it grants your own permissions |
| 4354 | * if you are not currently processing an IPC. Use with care! |
| 4355 | * |
| 4356 | * @param uri The uri that is being checked. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4357 | * @param modeFlags The access modes to check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4358 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4359 | * @return {@link PackageManager#PERMISSION_GRANTED} if the caller |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4360 | * is allowed to access that uri, or |
| 4361 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4362 | * |
| 4363 | * @see #checkCallingUriPermission |
| 4364 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4365 | @CheckResult(suggest="#enforceCallingOrSelfUriPermission(Uri,int,String)") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 4366 | @PackageManager.PermissionResult |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4367 | public abstract int checkCallingOrSelfUriPermission(Uri uri, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4368 | @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4369 | |
| 4370 | /** |
| 4371 | * Check both a Uri and normal permission. This allows you to perform |
| 4372 | * both {@link #checkPermission} and {@link #checkUriPermission} in one |
| 4373 | * call. |
| 4374 | * |
| 4375 | * @param uri The Uri whose permission is to be checked, or null to not |
| 4376 | * do this check. |
| 4377 | * @param readPermission The permission that provides overall read access, |
| 4378 | * or null to not do this check. |
| 4379 | * @param writePermission The permission that provides overall write |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4380 | * access, or null to not do this check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4381 | * @param pid The process ID being checked against. Must be > 0. |
| 4382 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 4383 | * user, which will pass every permission check. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4384 | * @param modeFlags The access modes to check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4385 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4386 | * @return {@link PackageManager#PERMISSION_GRANTED} if the caller |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4387 | * is allowed to access that uri or holds one of the given permissions, or |
| 4388 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4389 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4390 | @CheckResult(suggest="#enforceUriPermission(Uri,String,String,int,int,int,String)") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 4391 | @PackageManager.PermissionResult |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4392 | public abstract int checkUriPermission(@Nullable Uri uri, @Nullable String readPermission, |
| 4393 | @Nullable String writePermission, int pid, int uid, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4394 | @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4395 | |
| 4396 | /** |
| 4397 | * If a particular process and user ID has not been granted |
| 4398 | * permission to access a specific URI, throw {@link |
| 4399 | * SecurityException}. This only checks for permissions that have |
| 4400 | * been explicitly granted -- if the given process/uid has more |
| 4401 | * general access to the URI's content provider then this check |
| 4402 | * will always fail. |
| 4403 | * |
| 4404 | * @param uri The uri that is being checked. |
| 4405 | * @param pid The process ID being checked against. Must be > 0. |
| 4406 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 4407 | * user, which will pass every permission check. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4408 | * @param modeFlags The access modes to enforce. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4409 | * @param message A message to include in the exception if it is thrown. |
| 4410 | * |
| 4411 | * @see #checkUriPermission(Uri, int, int, int) |
| 4412 | */ |
| 4413 | public abstract void enforceUriPermission( |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4414 | 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] | 4415 | |
| 4416 | /** |
| 4417 | * If the calling process and user ID has not been granted |
| 4418 | * permission to access a specific URI, throw {@link |
| 4419 | * SecurityException}. This is basically the same as calling |
| 4420 | * {@link #enforceUriPermission(Uri, int, int, int, String)} with |
| 4421 | * the pid and uid returned by {@link |
| 4422 | * android.os.Binder#getCallingPid} and {@link |
| 4423 | * android.os.Binder#getCallingUid}. One important difference is |
| 4424 | * that if you are not currently processing an IPC, this function |
| 4425 | * will always throw a SecurityException. |
| 4426 | * |
| 4427 | * @param uri The uri that is being checked. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4428 | * @param modeFlags The access modes to enforce. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4429 | * @param message A message to include in the exception if it is thrown. |
| 4430 | * |
| 4431 | * @see #checkCallingUriPermission(Uri, int) |
| 4432 | */ |
| 4433 | public abstract void enforceCallingUriPermission( |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4434 | Uri uri, @Intent.AccessUriMode int modeFlags, String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4435 | |
| 4436 | /** |
| 4437 | * If the calling process of an IPC <em>or you</em> has not been |
| 4438 | * granted permission to access a specific URI, throw {@link |
| 4439 | * SecurityException}. This is the same as {@link |
| 4440 | * #enforceCallingUriPermission}, except it grants your own |
| 4441 | * permissions if you are not currently processing an IPC. Use |
| 4442 | * with care! |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4443 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4444 | * @param uri The uri that is being checked. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4445 | * @param modeFlags The access modes to enforce. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4446 | * @param message A message to include in the exception if it is thrown. |
| 4447 | * |
| 4448 | * @see #checkCallingOrSelfUriPermission(Uri, int) |
| 4449 | */ |
| 4450 | public abstract void enforceCallingOrSelfUriPermission( |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4451 | Uri uri, @Intent.AccessUriMode int modeFlags, String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4452 | |
| 4453 | /** |
| 4454 | * Enforce both a Uri and normal permission. This allows you to perform |
| 4455 | * both {@link #enforcePermission} and {@link #enforceUriPermission} in one |
| 4456 | * call. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4457 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4458 | * @param uri The Uri whose permission is to be checked, or null to not |
| 4459 | * do this check. |
| 4460 | * @param readPermission The permission that provides overall read access, |
| 4461 | * or null to not do this check. |
| 4462 | * @param writePermission The permission that provides overall write |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4463 | * access, or null to not do this check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4464 | * @param pid The process ID being checked against. Must be > 0. |
| 4465 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 4466 | * user, which will pass every permission check. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4467 | * @param modeFlags The access modes to enforce. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4468 | * @param message A message to include in the exception if it is thrown. |
| 4469 | * |
| 4470 | * @see #checkUriPermission(Uri, String, String, int, int, int) |
| 4471 | */ |
| 4472 | public abstract void enforceUriPermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4473 | @Nullable Uri uri, @Nullable String readPermission, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4474 | @Nullable String writePermission, int pid, int uid, @Intent.AccessUriMode int modeFlags, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4475 | @Nullable String message); |
| 4476 | |
| 4477 | /** @hide */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 4478 | @IntDef(flag = true, prefix = { "CONTEXT_" }, value = { |
| 4479 | CONTEXT_INCLUDE_CODE, |
| 4480 | CONTEXT_IGNORE_SECURITY, |
| 4481 | CONTEXT_RESTRICTED, |
| 4482 | CONTEXT_DEVICE_PROTECTED_STORAGE, |
| 4483 | CONTEXT_CREDENTIAL_PROTECTED_STORAGE, |
| 4484 | CONTEXT_REGISTER_PACKAGE, |
| 4485 | }) |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4486 | @Retention(RetentionPolicy.SOURCE) |
| 4487 | public @interface CreatePackageOptions {} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4488 | |
| 4489 | /** |
| 4490 | * Flag for use with {@link #createPackageContext}: include the application |
| 4491 | * code with the context. This means loading code into the caller's |
| 4492 | * process, so that {@link #getClassLoader()} can be used to instantiate |
| 4493 | * the application's classes. Setting this flags imposes security |
| 4494 | * restrictions on what application context you can access; if the |
| 4495 | * requested application can not be safely loaded into your process, |
| 4496 | * java.lang.SecurityException will be thrown. If this flag is not set, |
| 4497 | * there will be no restrictions on the packages that can be loaded, |
| 4498 | * but {@link #getClassLoader} will always return the default system |
| 4499 | * class loader. |
| 4500 | */ |
| 4501 | public static final int CONTEXT_INCLUDE_CODE = 0x00000001; |
| 4502 | |
| 4503 | /** |
| 4504 | * Flag for use with {@link #createPackageContext}: ignore any security |
| 4505 | * restrictions on the Context being requested, allowing it to always |
| 4506 | * be loaded. For use with {@link #CONTEXT_INCLUDE_CODE} to allow code |
| 4507 | * to be loaded into a process even when it isn't safe to do so. Use |
| 4508 | * with extreme care! |
| 4509 | */ |
| 4510 | public static final int CONTEXT_IGNORE_SECURITY = 0x00000002; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4511 | |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 4512 | /** |
| 4513 | * Flag for use with {@link #createPackageContext}: a restricted context may |
| 4514 | * disable specific features. For instance, a View associated with a restricted |
| 4515 | * context would ignore particular XML attributes. |
| 4516 | */ |
| 4517 | public static final int CONTEXT_RESTRICTED = 0x00000004; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4518 | |
| 4519 | /** |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4520 | * Flag for use with {@link #createPackageContext}: point all file APIs at |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4521 | * device-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4522 | * |
| 4523 | * @hide |
| 4524 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4525 | public static final int CONTEXT_DEVICE_PROTECTED_STORAGE = 0x00000008; |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4526 | |
| 4527 | /** |
| 4528 | * Flag for use with {@link #createPackageContext}: point all file APIs at |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4529 | * credential-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4530 | * |
| 4531 | * @hide |
| 4532 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4533 | public static final int CONTEXT_CREDENTIAL_PROTECTED_STORAGE = 0x00000010; |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4534 | |
| 4535 | /** |
Dianne Hackborn | fee756f | 2014-07-16 17:31:10 -0700 | [diff] [blame] | 4536 | * @hide Used to indicate we should tell the activity manager about the process |
| 4537 | * loading this code. |
| 4538 | */ |
| 4539 | public static final int CONTEXT_REGISTER_PACKAGE = 0x40000000; |
| 4540 | |
| 4541 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4542 | * Return a new Context object for the given application name. This |
| 4543 | * Context is the same as what the named application gets when it is |
| 4544 | * launched, containing the same resources and class loader. Each call to |
| 4545 | * this method returns a new instance of a Context object; Context objects |
| 4546 | * are not shared, however they share common state (Resources, ClassLoader, |
| 4547 | * etc) so the Context instance itself is fairly lightweight. |
| 4548 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 4549 | * <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] | 4550 | * application with the given package name. |
| 4551 | * |
| 4552 | * <p>Throws {@link java.lang.SecurityException} if the Context requested |
| 4553 | * can not be loaded into the caller's process for security reasons (see |
| 4554 | * {@link #CONTEXT_INCLUDE_CODE} for more information}. |
| 4555 | * |
| 4556 | * @param packageName Name of the application's package. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 4557 | * @param flags Option flags. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4558 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4559 | * @return A {@link Context} for the application. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4560 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4561 | * @throws SecurityException |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4562 | * @throws PackageManager.NameNotFoundException if there is no application with |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4563 | * the given package name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4564 | */ |
| 4565 | public abstract Context createPackageContext(String packageName, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4566 | @CreatePackageOptions int flags) throws PackageManager.NameNotFoundException; |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 4567 | |
| 4568 | /** |
Jeff Sharkey | 6d51571 | 2012-09-20 16:06:08 -0700 | [diff] [blame] | 4569 | * Similar to {@link #createPackageContext(String, int)}, but with a |
| 4570 | * different {@link UserHandle}. For example, {@link #getContentResolver()} |
| 4571 | * will open any {@link Uri} as the given user. |
| 4572 | * |
| 4573 | * @hide |
| 4574 | */ |
| 4575 | public abstract Context createPackageContextAsUser( |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 4576 | String packageName, @CreatePackageOptions int flags, UserHandle user) |
Jeff Sharkey | 6d51571 | 2012-09-20 16:06:08 -0700 | [diff] [blame] | 4577 | throws PackageManager.NameNotFoundException; |
| 4578 | |
| 4579 | /** |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 4580 | * Creates a context given an {@link android.content.pm.ApplicationInfo}. |
| 4581 | * |
| 4582 | * @hide |
| 4583 | */ |
| 4584 | public abstract Context createApplicationContext(ApplicationInfo application, |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 4585 | @CreatePackageOptions int flags) throws PackageManager.NameNotFoundException; |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 4586 | |
| 4587 | /** |
Adam Lesinski | 4e86281 | 2016-11-21 16:02:24 -0800 | [diff] [blame] | 4588 | * Return a new Context object for the given split name. The new Context has a ClassLoader and |
| 4589 | * Resources object that can access the split's and all of its dependencies' code/resources. |
| 4590 | * Each call to this method returns a new instance of a Context object; |
| 4591 | * Context objects are not shared, however common state (ClassLoader, other Resources for |
| 4592 | * the same split) may be so the Context itself can be fairly lightweight. |
| 4593 | * |
| 4594 | * @param splitName The name of the split to include, as declared in the split's |
| 4595 | * <code>AndroidManifest.xml</code>. |
| 4596 | * @return A {@link Context} with the given split's code and/or resources loaded. |
| 4597 | */ |
| 4598 | public abstract Context createContextForSplit(String splitName) |
| 4599 | throws PackageManager.NameNotFoundException; |
| 4600 | |
| 4601 | /** |
Jim Miller | a75a883 | 2013-02-07 16:53:32 -0800 | [diff] [blame] | 4602 | * Get the userId associated with this context |
| 4603 | * @return user id |
| 4604 | * |
| 4605 | * @hide |
| 4606 | */ |
Jeff Sharkey | a73b8fd | 2016-01-06 17:02:08 -0700 | [diff] [blame] | 4607 | @TestApi |
Jeff Sharkey | 8588bc1 | 2016-01-06 16:47:42 -0700 | [diff] [blame] | 4608 | public abstract @UserIdInt int getUserId(); |
Jim Miller | a75a883 | 2013-02-07 16:53:32 -0800 | [diff] [blame] | 4609 | |
| 4610 | /** |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 4611 | * Return a new Context object for the current Context but whose resources |
| 4612 | * are adjusted to match the given Configuration. Each call to this method |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 4613 | * returns a new instance of a Context object; Context objects are not |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 4614 | * shared, however common state (ClassLoader, other Resources for the |
| 4615 | * same configuration) may be so the Context itself can be fairly lightweight. |
| 4616 | * |
| 4617 | * @param overrideConfiguration A {@link Configuration} specifying what |
| 4618 | * values to modify in the base Configuration of the original Context's |
| 4619 | * resources. If the base configuration changes (such as due to an |
| 4620 | * orientation change), the resources of this context will also change except |
| 4621 | * for those that have been explicitly overridden with a value here. |
| 4622 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4623 | * @return A {@link Context} with the given configuration override. |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 4624 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4625 | public abstract Context createConfigurationContext( |
| 4626 | @NonNull Configuration overrideConfiguration); |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 4627 | |
| 4628 | /** |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 4629 | * Return a new Context object for the current Context but whose resources |
| 4630 | * are adjusted to match the metrics of the given Display. Each call to this method |
| 4631 | * returns a new instance of a Context object; Context objects are not |
| 4632 | * shared, however common state (ClassLoader, other Resources for the |
| 4633 | * same configuration) may be so the Context itself can be fairly lightweight. |
| 4634 | * |
| 4635 | * The returned display Context provides a {@link WindowManager} |
| 4636 | * (see {@link #getSystemService(String)}) that is configured to show windows |
| 4637 | * on the given display. The WindowManager's {@link WindowManager#getDefaultDisplay} |
| 4638 | * method can be used to retrieve the Display from the returned Context. |
| 4639 | * |
| 4640 | * @param display A {@link Display} object specifying the display |
| 4641 | * for whose metrics the Context's resources should be tailored and upon which |
| 4642 | * new windows should be shown. |
| 4643 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4644 | * @return A {@link Context} for the display. |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 4645 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4646 | public abstract Context createDisplayContext(@NonNull Display display); |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 4647 | |
| 4648 | /** |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4649 | * Return a new Context object for the current Context but whose storage |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4650 | * APIs are backed by device-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4651 | * <p> |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 4652 | * On devices with direct boot, data stored in this location is encrypted |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4653 | * with a key tied to the physical device, and it can be accessed |
| 4654 | * immediately after the device has booted successfully, both |
| 4655 | * <em>before and after</em> the user has authenticated with their |
| 4656 | * credentials (such as a lock pattern or PIN). |
| 4657 | * <p> |
| 4658 | * Because device-protected data is available without user authentication, |
| 4659 | * you should carefully limit the data you store using this Context. For |
| 4660 | * example, storing sensitive authentication tokens or passwords in the |
| 4661 | * device-protected area is strongly discouraged. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4662 | * <p> |
Jeff Sharkey | 3ea44a5 | 2016-01-09 15:19:56 -0700 | [diff] [blame] | 4663 | * If the underlying device does not have the ability to store |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4664 | * device-protected and credential-protected data using different keys, then |
| 4665 | * both storage areas will become available at the same time. They remain as |
| 4666 | * two distinct storage locations on disk, and only the window of |
| 4667 | * availability changes. |
Jeff Sharkey | 3ea44a5 | 2016-01-09 15:19:56 -0700 | [diff] [blame] | 4668 | * <p> |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4669 | * Each call to this method returns a new instance of a Context object; |
| 4670 | * Context objects are not shared, however common state (ClassLoader, other |
| 4671 | * Resources for the same configuration) may be so the Context itself can be |
| 4672 | * fairly lightweight. |
| 4673 | * |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4674 | * @see #isDeviceProtectedStorage() |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4675 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4676 | public abstract Context createDeviceProtectedStorageContext(); |
| 4677 | |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4678 | /** |
| 4679 | * Return a new Context object for the current Context but whose storage |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4680 | * APIs are backed by credential-protected storage. This is the default |
| 4681 | * storage area for apps unless |
| 4682 | * {@link android.R.attr#defaultToDeviceProtectedStorage} was requested. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4683 | * <p> |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 4684 | * On devices with direct boot, data stored in this location is encrypted |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4685 | * with a key tied to user credentials, which can be accessed |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4686 | * <em>only after</em> the user has entered their credentials (such as a |
| 4687 | * lock pattern or PIN). |
| 4688 | * <p> |
Jeff Sharkey | 3ea44a5 | 2016-01-09 15:19:56 -0700 | [diff] [blame] | 4689 | * If the underlying device does not have the ability to store |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4690 | * device-protected and credential-protected data using different keys, then |
| 4691 | * both storage areas will become available at the same time. They remain as |
| 4692 | * two distinct storage locations on disk, and only the window of |
| 4693 | * availability changes. |
Jeff Sharkey | 3ea44a5 | 2016-01-09 15:19:56 -0700 | [diff] [blame] | 4694 | * <p> |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4695 | * Each call to this method returns a new instance of a Context object; |
| 4696 | * Context objects are not shared, however common state (ClassLoader, other |
| 4697 | * Resources for the same configuration) may be so the Context itself can be |
| 4698 | * fairly lightweight. |
| 4699 | * |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4700 | * @see #isCredentialProtectedStorage() |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 4701 | * @hide |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4702 | */ |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 4703 | @SystemApi |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4704 | public abstract Context createCredentialProtectedStorageContext(); |
| 4705 | |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4706 | /** |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 4707 | * Gets the display adjustments holder for this context. This information |
| 4708 | * is provided on a per-application or activity basis and is used to simulate lower density |
| 4709 | * display metrics for legacy applications and restricted screen sizes. |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 4710 | * |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 4711 | * @param displayId The display id for which to get compatibility info. |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 4712 | * @return The compatibility info holder, or null if not required by the application. |
| 4713 | * @hide |
| 4714 | */ |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 4715 | public abstract DisplayAdjustments getDisplayAdjustments(int displayId); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 4716 | |
| 4717 | /** |
Adam Lesinski | 4ece3d6 | 2016-06-16 18:05:41 -0700 | [diff] [blame] | 4718 | * @hide |
| 4719 | */ |
| 4720 | public abstract Display getDisplay(); |
| 4721 | |
| 4722 | /** |
Andrii Kulian | b047b8b | 2017-02-08 18:38:26 -0800 | [diff] [blame] | 4723 | * @hide |
| 4724 | */ |
| 4725 | public abstract void updateDisplay(int displayId); |
| 4726 | |
| 4727 | /** |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 4728 | * Indicates whether this Context is restricted. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4729 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4730 | * @return {@code true} if this Context is restricted, {@code false} otherwise. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4731 | * |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 4732 | * @see #CONTEXT_RESTRICTED |
| 4733 | */ |
| 4734 | public boolean isRestricted() { |
| 4735 | return false; |
| 4736 | } |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4737 | |
| 4738 | /** |
| 4739 | * Indicates if the storage APIs of this Context are backed by |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4740 | * device-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4741 | * |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4742 | * @see #createDeviceProtectedStorageContext() |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4743 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4744 | public abstract boolean isDeviceProtectedStorage(); |
| 4745 | |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4746 | /** |
| 4747 | * Indicates if the storage APIs of this Context are backed by |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4748 | * credential-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4749 | * |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4750 | * @see #createCredentialProtectedStorageContext() |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 4751 | * @hide |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4752 | */ |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 4753 | @SystemApi |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4754 | public abstract boolean isCredentialProtectedStorage(); |
| 4755 | |
Tony Mak | 46aabe5 | 2016-11-14 12:53:06 +0000 | [diff] [blame] | 4756 | /** |
Seigo Nonaka | 6d6cd68 | 2017-06-22 08:22:18 -0700 | [diff] [blame] | 4757 | * Returns true if the context can load unsafe resources, e.g. fonts. |
| 4758 | * @hide |
| 4759 | */ |
| 4760 | public abstract boolean canLoadUnsafeResources(); |
| 4761 | |
| 4762 | /** |
Tony Mak | 46aabe5 | 2016-11-14 12:53:06 +0000 | [diff] [blame] | 4763 | * @hide |
| 4764 | */ |
| 4765 | public IBinder getActivityToken() { |
| 4766 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 4767 | } |
| 4768 | |
| 4769 | /** |
| 4770 | * @hide |
| 4771 | */ |
| 4772 | @Nullable |
| 4773 | public IServiceConnection getServiceDispatcher(ServiceConnection conn, Handler handler, |
| 4774 | int flags) { |
| 4775 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 4776 | } |
| 4777 | |
| 4778 | /** |
| 4779 | * @hide |
| 4780 | */ |
| 4781 | public IApplicationThread getIApplicationThread() { |
| 4782 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 4783 | } |
Tony Mak | bf9928d | 2016-12-22 11:02:45 +0000 | [diff] [blame] | 4784 | |
| 4785 | /** |
| 4786 | * @hide |
| 4787 | */ |
| 4788 | public Handler getMainThreadHandler() { |
| 4789 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 4790 | } |
Adam Lesinski | a82b626 | 2017-03-21 16:56:17 -0700 | [diff] [blame] | 4791 | |
| 4792 | /** |
Felipe Leme | bb567ae | 2017-10-04 09:56:21 -0700 | [diff] [blame] | 4793 | * @hide |
| 4794 | */ |
| 4795 | public AutofillClient getAutofillClient() { |
| 4796 | return null; |
| 4797 | } |
| 4798 | |
| 4799 | /** |
| 4800 | * @hide |
| 4801 | */ |
| 4802 | public void setAutofillClient(AutofillClient client) { |
| 4803 | } |
| 4804 | |
| 4805 | /** |
Adam Lesinski | a82b626 | 2017-03-21 16:56:17 -0700 | [diff] [blame] | 4806 | * Throws an exception if the Context is using system resources, |
| 4807 | * which are non-runtime-overlay-themable and may show inconsistent UI. |
| 4808 | * @hide |
| 4809 | */ |
| 4810 | public void assertRuntimeOverlayThemable() { |
| 4811 | // Resources.getSystem() is a singleton and the only Resources not managed by |
| 4812 | // ResourcesManager; therefore Resources.getSystem() is not themable. |
| 4813 | if (getResources() == Resources.getSystem()) { |
| 4814 | throw new IllegalArgumentException("Non-UI context used to display UI; " |
| 4815 | + "get a UI context from ActivityThread#getSystemUiContext()"); |
| 4816 | } |
| 4817 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4818 | } |