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; |
| 27 | import android.annotation.StringDef; |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 28 | import android.annotation.StringRes; |
| 29 | import android.annotation.StyleRes; |
| 30 | import android.annotation.StyleableRes; |
Jinsuk Kim | 66d1eb2 | 2014-06-06 16:12:18 +0900 | [diff] [blame] | 31 | import android.annotation.SystemApi; |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 32 | import android.content.pm.ApplicationInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | import android.content.pm.PackageManager; |
| 34 | import android.content.res.AssetManager; |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 35 | import android.content.res.ColorStateList; |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 36 | import android.content.res.Configuration; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 37 | import android.content.res.Resources; |
| 38 | import android.content.res.TypedArray; |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 39 | import android.database.DatabaseErrorHandler; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 40 | import android.database.sqlite.SQLiteDatabase; |
| 41 | import android.database.sqlite.SQLiteDatabase.CursorFactory; |
| 42 | import android.graphics.Bitmap; |
| 43 | import android.graphics.drawable.Drawable; |
| 44 | import android.net.Uri; |
| 45 | import android.os.Bundle; |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 46 | import android.os.Environment; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 47 | import android.os.Handler; |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 48 | import android.os.IBinder; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 49 | import android.os.Looper; |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 50 | import android.os.StatFs; |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 51 | import android.os.UserHandle; |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 52 | import android.os.UserManager; |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 53 | import android.provider.MediaStore; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 54 | import android.util.AttributeSet; |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 55 | import android.view.DisplayAdjustments; |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 56 | import android.view.Display; |
Jon Miranda | 836c0a8 | 2014-08-11 12:32:26 -0700 | [diff] [blame] | 57 | import android.view.ViewDebug; |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 58 | import android.view.WindowManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 59 | |
| 60 | import java.io.File; |
| 61 | import java.io.FileInputStream; |
| 62 | import java.io.FileNotFoundException; |
| 63 | import java.io.FileOutputStream; |
| 64 | import java.io.IOException; |
| 65 | import java.io.InputStream; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 66 | import java.lang.annotation.Retention; |
| 67 | import java.lang.annotation.RetentionPolicy; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 68 | |
| 69 | /** |
| 70 | * Interface to global information about an application environment. This is |
| 71 | * an abstract class whose implementation is provided by |
| 72 | * the Android system. It |
| 73 | * allows access to application-specific resources and classes, as well as |
| 74 | * up-calls for application-level operations such as launching activities, |
| 75 | * broadcasting and receiving intents, etc. |
| 76 | */ |
| 77 | public abstract class Context { |
| 78 | /** |
| 79 | * File creation mode: the default mode, where the created file can only |
| 80 | * be accessed by the calling application (or all applications sharing the |
| 81 | * same user ID). |
| 82 | * @see #MODE_WORLD_READABLE |
| 83 | * @see #MODE_WORLD_WRITEABLE |
| 84 | */ |
| 85 | public static final int MODE_PRIVATE = 0x0000; |
| 86 | /** |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 87 | * @deprecated Creating world-readable files is very dangerous, and likely |
| 88 | * to cause security holes in applications. It is strongly discouraged; |
| 89 | * instead, applications should use more formal mechanism for interactions |
| 90 | * such as {@link ContentProvider}, {@link BroadcastReceiver}, and |
| 91 | * {@link android.app.Service}. There are no guarantees that this |
| 92 | * access mode will remain on a file, such as when it goes through a |
| 93 | * backup and restore. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 94 | * File creation mode: allow all other applications to have read access |
| 95 | * to the created file. |
| 96 | * @see #MODE_PRIVATE |
| 97 | * @see #MODE_WORLD_WRITEABLE |
| 98 | */ |
Dianne Hackborn | 556b09e | 2012-09-23 17:46:53 -0700 | [diff] [blame] | 99 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 100 | public static final int MODE_WORLD_READABLE = 0x0001; |
| 101 | /** |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 102 | * @deprecated Creating world-writable files is very dangerous, and likely |
| 103 | * to cause security holes in applications. It is strongly discouraged; |
| 104 | * instead, applications should use more formal mechanism for interactions |
| 105 | * such as {@link ContentProvider}, {@link BroadcastReceiver}, and |
| 106 | * {@link android.app.Service}. There are no guarantees that this |
| 107 | * access mode will remain on a file, such as when it goes through a |
| 108 | * backup and restore. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 109 | * File creation mode: allow all other applications to have write access |
| 110 | * to the created file. |
| 111 | * @see #MODE_PRIVATE |
| 112 | * @see #MODE_WORLD_READABLE |
| 113 | */ |
Dianne Hackborn | 556b09e | 2012-09-23 17:46:53 -0700 | [diff] [blame] | 114 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 115 | public static final int MODE_WORLD_WRITEABLE = 0x0002; |
| 116 | /** |
| 117 | * File creation mode: for use with {@link #openFileOutput}, if the file |
| 118 | * already exists then write data to the end of the existing file |
| 119 | * instead of erasing it. |
| 120 | * @see #openFileOutput |
| 121 | */ |
| 122 | public static final int MODE_APPEND = 0x8000; |
| 123 | |
| 124 | /** |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 125 | * SharedPreference loading flag: when set, the file on disk will |
| 126 | * be checked for modification even if the shared preferences |
| 127 | * instance is already loaded in this process. This behavior is |
| 128 | * sometimes desired in cases where the application has multiple |
| 129 | * processes, all writing to the same SharedPreferences file. |
| 130 | * Generally there are better forms of communication between |
| 131 | * processes, though. |
| 132 | * |
| 133 | * <p>This was the legacy (but undocumented) behavior in and |
| 134 | * before Gingerbread (Android 2.3) and this flag is implied when |
| 135 | * targetting such releases. For applications targetting SDK |
| 136 | * versions <em>greater than</em> Android 2.3, this flag must be |
| 137 | * explicitly set if desired. |
| 138 | * |
| 139 | * @see #getSharedPreferences |
Christopher Tate | d5748b8 | 2015-05-08 18:14:01 -0700 | [diff] [blame] | 140 | * |
| 141 | * @deprecated MODE_MULTI_PROCESS does not work reliably in |
| 142 | * some versions of Android, and furthermore does not provide any |
| 143 | * mechanism for reconciling concurrent modifications across |
| 144 | * processes. Applications should not attempt to use it. Instead, |
| 145 | * they should use an explicit cross-process data management |
| 146 | * approach such as {@link android.content.ContentProvider ContentProvider}. |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 147 | */ |
Christopher Tate | d5748b8 | 2015-05-08 18:14:01 -0700 | [diff] [blame] | 148 | @Deprecated |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 149 | public static final int MODE_MULTI_PROCESS = 0x0004; |
| 150 | |
| 151 | /** |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 152 | * Database open flag: when set, the database is opened with write-ahead |
| 153 | * logging enabled by default. |
| 154 | * |
| 155 | * @see #openOrCreateDatabase(String, int, CursorFactory) |
| 156 | * @see #openOrCreateDatabase(String, int, CursorFactory, DatabaseErrorHandler) |
| 157 | * @see SQLiteDatabase#enableWriteAheadLogging |
| 158 | */ |
| 159 | public static final int MODE_ENABLE_WRITE_AHEAD_LOGGING = 0x0008; |
| 160 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 161 | /** @hide */ |
| 162 | @IntDef(flag = true, |
| 163 | value = { |
| 164 | BIND_AUTO_CREATE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 165 | BIND_DEBUG_UNBIND, |
| 166 | BIND_NOT_FOREGROUND, |
| 167 | BIND_ABOVE_CLIENT, |
| 168 | BIND_ALLOW_OOM_MANAGEMENT, |
Tor Norbye | ce1c67c | 2014-12-02 13:59:17 -0800 | [diff] [blame] | 169 | BIND_WAIVE_PRIORITY, |
| 170 | BIND_IMPORTANT, |
| 171 | BIND_ADJUST_WITH_ACTIVITY |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 172 | }) |
| 173 | @Retention(RetentionPolicy.SOURCE) |
| 174 | public @interface BindServiceFlags {} |
| 175 | |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 176 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 177 | * Flag for {@link #bindService}: automatically create the service as long |
| 178 | * as the binding exists. Note that while this will create the service, |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 179 | * its {@link android.app.Service#onStartCommand} |
| 180 | * method will still only be called due to an |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 181 | * explicit call to {@link #startService}. Even without that, though, |
| 182 | * this still provides you with access to the service object while the |
| 183 | * service is created. |
| 184 | * |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 185 | * <p>Note that prior to {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, |
| 186 | * not supplying this flag would also impact how important the system |
| 187 | * consider's the target service's process to be. When set, the only way |
| 188 | * for it to be raised was by binding from a service in which case it will |
| 189 | * only be important when that activity is in the foreground. Now to |
| 190 | * achieve this behavior you must explicitly supply the new flag |
| 191 | * {@link #BIND_ADJUST_WITH_ACTIVITY}. For compatibility, old applications |
| 192 | * that don't specify {@link #BIND_AUTO_CREATE} will automatically have |
| 193 | * the flags {@link #BIND_WAIVE_PRIORITY} and |
| 194 | * {@link #BIND_ADJUST_WITH_ACTIVITY} set for them in order to achieve |
| 195 | * the same result. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 196 | */ |
| 197 | public static final int BIND_AUTO_CREATE = 0x0001; |
| 198 | |
| 199 | /** |
| 200 | * Flag for {@link #bindService}: include debugging help for mismatched |
| 201 | * calls to unbind. When this flag is set, the callstack of the following |
| 202 | * {@link #unbindService} call is retained, to be printed if a later |
| 203 | * incorrect unbind call is made. Note that doing this requires retaining |
| 204 | * information about the binding that was made for the lifetime of the app, |
| 205 | * resulting in a leak -- this should only be used for debugging. |
| 206 | */ |
| 207 | public static final int BIND_DEBUG_UNBIND = 0x0002; |
| 208 | |
Dianne Hackborn | 09c916b | 2009-12-08 14:50:51 -0800 | [diff] [blame] | 209 | /** |
| 210 | * Flag for {@link #bindService}: don't allow this binding to raise |
| 211 | * the target service's process to the foreground scheduling priority. |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 212 | * It will still be raised to at least the same memory priority |
Dianne Hackborn | 09c916b | 2009-12-08 14:50:51 -0800 | [diff] [blame] | 213 | * as the client (so that its process will not be killable in any |
| 214 | * situation where the client is not killable), but for CPU scheduling |
| 215 | * purposes it may be left in the background. This only has an impact |
| 216 | * in the situation where the binding client is a foreground process |
| 217 | * and the target service is in a background process. |
| 218 | */ |
| 219 | public static final int BIND_NOT_FOREGROUND = 0x0004; |
| 220 | |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 221 | /** |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 222 | * Flag for {@link #bindService}: indicates that the client application |
| 223 | * binding to this service considers the service to be more important than |
| 224 | * 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] | 225 | * 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] | 226 | * this is not guaranteed to be the case. |
| 227 | */ |
| 228 | public static final int BIND_ABOVE_CLIENT = 0x0008; |
| 229 | |
| 230 | /** |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 231 | * Flag for {@link #bindService}: allow the process hosting the bound |
| 232 | * service to go through its normal memory management. It will be |
| 233 | * treated more like a running service, allowing the system to |
| 234 | * (temporarily) expunge the process if low on memory or for some other |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 235 | * whim it may have, and being more aggressive about making it a candidate |
| 236 | * to be killed (and restarted) if running for a long time. |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 237 | */ |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 238 | public static final int BIND_ALLOW_OOM_MANAGEMENT = 0x0010; |
| 239 | |
| 240 | /** |
| 241 | * Flag for {@link #bindService}: don't impact the scheduling or |
| 242 | * memory management priority of the target service's hosting process. |
| 243 | * Allows the service's process to be managed on the background LRU list |
| 244 | * just like a regular application process in the background. |
| 245 | */ |
| 246 | public static final int BIND_WAIVE_PRIORITY = 0x0020; |
| 247 | |
| 248 | /** |
| 249 | * Flag for {@link #bindService}: this service is very important to |
| 250 | * the client, so should be brought to the foreground process level |
| 251 | * when the client is. Normally a process can only be raised to the |
| 252 | * visibility level by a client, even if that client is in the foreground. |
| 253 | */ |
| 254 | public static final int BIND_IMPORTANT = 0x0040; |
| 255 | |
| 256 | /** |
| 257 | * Flag for {@link #bindService}: If binding from an activity, allow the |
| 258 | * target service's process importance to be raised based on whether the |
| 259 | * activity is visible to the user, regardless whether another flag is |
| 260 | * used to reduce the amount that the client process's overall importance |
| 261 | * is used to impact it. |
| 262 | */ |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 263 | public static final int BIND_ADJUST_WITH_ACTIVITY = 0x0080; |
| 264 | |
| 265 | /** |
Dianne Hackborn | d69e4c1 | 2015-04-24 09:54:54 -0700 | [diff] [blame] | 266 | * @hide Flag for {@link #bindService}: Like {@link #BIND_FOREGROUND_SERVICE}, |
| 267 | * but only applies while the device is awake. |
| 268 | */ |
| 269 | public static final int BIND_FOREGROUND_SERVICE_WHILE_AWAKE = 0x02000000; |
| 270 | |
| 271 | /** |
| 272 | * @hide Flag for {@link #bindService}: For only the case where the binding |
| 273 | * is coming from the system, set the process state to FOREGROUND_SERVICE |
| 274 | * instead of the normal maximum of IMPORTANT_FOREGROUND. That is, this is |
| 275 | * saying that the process shouldn't participate in the normal power reduction |
| 276 | * modes (removing network access etc). |
| 277 | */ |
| 278 | public static final int BIND_FOREGROUND_SERVICE = 0x04000000; |
| 279 | |
| 280 | /** |
Dianne Hackborn | f0f94d1 | 2014-03-17 16:04:21 -0700 | [diff] [blame] | 281 | * @hide Flag for {@link #bindService}: Treat the binding as hosting |
| 282 | * an activity, an unbinding as the activity going in the background. |
| 283 | * That is, when unbinding, the process when empty will go on the activity |
| 284 | * LRU list instead of the regular one, keeping it around more aggressively |
| 285 | * than it otherwise would be. This is intended for use with IMEs to try |
| 286 | * to keep IME processes around for faster keyboard switching. |
| 287 | */ |
| 288 | public static final int BIND_TREAT_LIKE_ACTIVITY = 0x08000000; |
| 289 | |
| 290 | /** |
Dianne Hackborn | b12e135 | 2012-09-26 11:39:20 -0700 | [diff] [blame] | 291 | * @hide An idea that is not yet implemented. |
| 292 | * Flag for {@link #bindService}: If binding from an activity, consider |
| 293 | * this service to be visible like the binding activity is. That is, |
| 294 | * it will be treated as something more important to keep around than |
| 295 | * invisible background activities. This will impact the number of |
| 296 | * recent activities the user can switch between without having them |
| 297 | * restart. There is no guarantee this will be respected, as the system |
| 298 | * tries to balance such requests from one app vs. the importantance of |
| 299 | * keeping other apps around. |
| 300 | */ |
Dianne Hackborn | c823051 | 2013-07-13 21:32:12 -0700 | [diff] [blame] | 301 | public static final int BIND_VISIBLE = 0x10000000; |
| 302 | |
| 303 | /** |
| 304 | * @hide |
| 305 | * Flag for {@link #bindService}: Consider this binding to be causing the target |
| 306 | * process to be showing UI, so it will be do a UI_HIDDEN memory trim when it goes |
| 307 | * away. |
| 308 | */ |
| 309 | public static final int BIND_SHOWING_UI = 0x20000000; |
Dianne Hackborn | b12e135 | 2012-09-26 11:39:20 -0700 | [diff] [blame] | 310 | |
| 311 | /** |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 312 | * Flag for {@link #bindService}: Don't consider the bound service to be |
| 313 | * visible, even if the caller is visible. |
| 314 | * @hide |
| 315 | */ |
| 316 | public static final int BIND_NOT_VISIBLE = 0x40000000; |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 317 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 318 | /** Return an AssetManager instance for your application's package. */ |
| 319 | public abstract AssetManager getAssets(); |
| 320 | |
| 321 | /** Return a Resources instance for your application's package. */ |
| 322 | public abstract Resources getResources(); |
| 323 | |
| 324 | /** Return PackageManager instance to find global package information. */ |
| 325 | public abstract PackageManager getPackageManager(); |
| 326 | |
| 327 | /** Return a ContentResolver instance for your application's package. */ |
| 328 | public abstract ContentResolver getContentResolver(); |
| 329 | |
| 330 | /** |
| 331 | * Return the Looper for the main thread of the current process. This is |
| 332 | * the thread used to dispatch calls to application components (activities, |
| 333 | * services, etc). |
Jeff Brown | f9e989d | 2013-04-04 23:04:03 -0700 | [diff] [blame] | 334 | * <p> |
| 335 | * By definition, this method returns the same result as would be obtained |
| 336 | * by calling {@link Looper#getMainLooper() Looper.getMainLooper()}. |
| 337 | * </p> |
| 338 | * |
| 339 | * @return The main looper. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 340 | */ |
| 341 | public abstract Looper getMainLooper(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 342 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 343 | /** |
| 344 | * Return the context of the single, global Application object of the |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 345 | * current process. This generally should only be used if you need a |
| 346 | * Context whose lifecycle is separate from the current context, that is |
| 347 | * tied to the lifetime of the process rather than the current component. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 348 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 349 | * <p>Consider for example how this interacts with |
Brad Fitzpatrick | 36af794 | 2010-12-08 11:31:07 -0800 | [diff] [blame] | 350 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter)}: |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 351 | * <ul> |
| 352 | * <li> <p>If used from an Activity context, the receiver is being registered |
| 353 | * within that activity. This means that you are expected to unregister |
| 354 | * before the activity is done being destroyed; in fact if you do not do |
| 355 | * so, the framework will clean up your leaked registration as it removes |
| 356 | * the activity and log an error. Thus, if you use the Activity context |
| 357 | * to register a receiver that is static (global to the process, not |
| 358 | * associated with an Activity instance) then that registration will be |
| 359 | * removed on you at whatever point the activity you used is destroyed. |
| 360 | * <li> <p>If used from the Context returned here, the receiver is being |
| 361 | * registered with the global state associated with your application. Thus |
| 362 | * it will never be unregistered for you. This is necessary if the receiver |
| 363 | * is associated with static data, not a particular component. However |
| 364 | * using the ApplicationContext elsewhere can easily lead to serious leaks |
| 365 | * if you forget to unregister, unbind, etc. |
| 366 | * </ul> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 367 | */ |
| 368 | public abstract Context getApplicationContext(); |
| 369 | |
| 370 | /** |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 371 | * Add a new {@link ComponentCallbacks} to the base application of the |
| 372 | * Context, which will be called at the same times as the ComponentCallbacks |
| 373 | * methods of activities and other components are called. Note that you |
| 374 | * <em>must</em> be sure to use {@link #unregisterComponentCallbacks} when |
| 375 | * appropriate in the future; this will not be removed for you. |
Dianne Hackborn | 905577f | 2011-09-07 18:31:28 -0700 | [diff] [blame] | 376 | * |
| 377 | * @param callback The interface to call. This can be either a |
| 378 | * {@link ComponentCallbacks} or {@link ComponentCallbacks2} interface. |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 379 | */ |
| 380 | public void registerComponentCallbacks(ComponentCallbacks callback) { |
| 381 | getApplicationContext().registerComponentCallbacks(callback); |
| 382 | } |
| 383 | |
| 384 | /** |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 385 | * Remove a {@link ComponentCallbacks} object that was previously registered |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 386 | * with {@link #registerComponentCallbacks(ComponentCallbacks)}. |
| 387 | */ |
| 388 | public void unregisterComponentCallbacks(ComponentCallbacks callback) { |
| 389 | getApplicationContext().unregisterComponentCallbacks(callback); |
| 390 | } |
| 391 | |
| 392 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 393 | * Return a localized, styled CharSequence from the application's package's |
| 394 | * default string table. |
| 395 | * |
| 396 | * @param resId Resource id for the CharSequence text |
| 397 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 398 | public final CharSequence getText(@StringRes int resId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 399 | return getResources().getText(resId); |
| 400 | } |
| 401 | |
| 402 | /** |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 403 | * 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] | 404 | * default string table. |
| 405 | * |
| 406 | * @param resId Resource id for the string |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 407 | * @return The string data associated with the resource, stripped of styled |
| 408 | * text information. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 409 | */ |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 410 | @NonNull |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 411 | public final String getString(@StringRes int resId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 412 | return getResources().getString(resId); |
| 413 | } |
| 414 | |
| 415 | /** |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 416 | * 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] | 417 | * default string table, substituting the format arguments as defined in |
| 418 | * {@link java.util.Formatter} and {@link java.lang.String#format}. |
| 419 | * |
| 420 | * @param resId Resource id for the format string |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 421 | * @param formatArgs The format arguments that will be used for |
| 422 | * substitution. |
| 423 | * @return The string data associated with the resource, formatted and |
| 424 | * stripped of styled text information. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 425 | */ |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 426 | @NonNull |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 427 | public final String getString(@StringRes int resId, Object... formatArgs) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 428 | return getResources().getString(resId, formatArgs); |
| 429 | } |
| 430 | |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 431 | /** |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 432 | * Returns a color associated with a particular resource ID and styled for |
| 433 | * the current theme. |
| 434 | * |
| 435 | * @param id The desired resource identifier, as generated by the aapt |
| 436 | * tool. This integer encodes the package, type, and resource |
| 437 | * entry. The value 0 is an invalid identifier. |
| 438 | * @return A single color value in the form 0xAARRGGBB. |
| 439 | * @throws android.content.res.Resources.NotFoundException if the given ID |
| 440 | * does not exist. |
| 441 | */ |
Tor Norbye | 3e4cda7 | 2015-06-10 08:14:31 -0700 | [diff] [blame^] | 442 | @ColorInt |
| 443 | public final int getColor(@ColorRes int id) { |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 444 | return getResources().getColor(id, getTheme()); |
| 445 | } |
| 446 | |
| 447 | /** |
| 448 | * Returns a drawable object associated with a particular resource ID and |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 449 | * styled for the current theme. |
| 450 | * |
| 451 | * @param id The desired resource identifier, as generated by the aapt |
| 452 | * tool. This integer encodes the package, type, and resource |
| 453 | * entry. The value 0 is an invalid identifier. |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 454 | * @return An object that can be used to draw this resource, or |
| 455 | * {@code null} if the resource could not be resolved. |
| 456 | * @throws android.content.res.Resources.NotFoundException if the given ID |
| 457 | * does not exist. |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 458 | */ |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 459 | @Nullable |
Tor Norbye | 3e4cda7 | 2015-06-10 08:14:31 -0700 | [diff] [blame^] | 460 | public final Drawable getDrawable(@DrawableRes int id) { |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 461 | return getResources().getDrawable(id, getTheme()); |
| 462 | } |
| 463 | |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 464 | /** |
| 465 | * Returns a color state list associated with a particular resource ID and |
| 466 | * styled for the current theme. |
| 467 | * |
| 468 | * @param id The desired resource identifier, as generated by the aapt |
| 469 | * tool. This integer encodes the package, type, and resource |
| 470 | * entry. The value 0 is an invalid identifier. |
| 471 | * @return A color state list, or {@code null} if the resource could not be |
| 472 | * resolved. |
| 473 | * @throws android.content.res.Resources.NotFoundException if the given ID |
| 474 | * does not exist. |
| 475 | */ |
| 476 | @Nullable |
Tor Norbye | 3e4cda7 | 2015-06-10 08:14:31 -0700 | [diff] [blame^] | 477 | public final ColorStateList getColorStateList(@ColorRes int id) { |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 478 | return getResources().getColorStateList(id, getTheme()); |
| 479 | } |
| 480 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 481 | /** |
| 482 | * Set the base theme for this context. Note that this should be called |
| 483 | * before any views are instantiated in the Context (for example before |
| 484 | * calling {@link android.app.Activity#setContentView} or |
| 485 | * {@link android.view.LayoutInflater#inflate}). |
| 486 | * |
| 487 | * @param resid The style resource describing the theme. |
| 488 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 489 | public abstract void setTheme(@StyleRes int resid); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 490 | |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 491 | /** @hide Needed for some internal implementation... not public because |
| 492 | * you can't assume this actually means anything. */ |
| 493 | public int getThemeResId() { |
| 494 | return 0; |
| 495 | } |
| 496 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 497 | /** |
| 498 | * Return the Theme object associated with this Context. |
| 499 | */ |
Jon Miranda | 836c0a8 | 2014-08-11 12:32:26 -0700 | [diff] [blame] | 500 | @ViewDebug.ExportedProperty(deepExport = true) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 501 | public abstract Resources.Theme getTheme(); |
| 502 | |
| 503 | /** |
| 504 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 505 | * {@link android.content.res.Resources.Theme#obtainStyledAttributes(int[])} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 506 | * for more information. |
| 507 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 508 | * @see android.content.res.Resources.Theme#obtainStyledAttributes(int[]) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 509 | */ |
Tor Norbye | c91531a | 2015-04-01 17:41:55 -0700 | [diff] [blame] | 510 | public final TypedArray obtainStyledAttributes(@StyleableRes int[] attrs) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 511 | return getTheme().obtainStyledAttributes(attrs); |
| 512 | } |
| 513 | |
| 514 | /** |
| 515 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 516 | * {@link android.content.res.Resources.Theme#obtainStyledAttributes(int, int[])} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 517 | * for more information. |
| 518 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 519 | * @see android.content.res.Resources.Theme#obtainStyledAttributes(int, int[]) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 520 | */ |
| 521 | public final TypedArray obtainStyledAttributes( |
Tor Norbye | c91531a | 2015-04-01 17:41:55 -0700 | [diff] [blame] | 522 | @StyleRes int resid, @StyleableRes int[] attrs) throws Resources.NotFoundException { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 523 | return getTheme().obtainStyledAttributes(resid, attrs); |
| 524 | } |
| 525 | |
| 526 | /** |
| 527 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 528 | * {@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] | 529 | * for more information. |
| 530 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 531 | * @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] | 532 | */ |
| 533 | public final TypedArray obtainStyledAttributes( |
Tor Norbye | c91531a | 2015-04-01 17:41:55 -0700 | [diff] [blame] | 534 | AttributeSet set, @StyleableRes int[] attrs) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 535 | return getTheme().obtainStyledAttributes(set, attrs, 0, 0); |
| 536 | } |
| 537 | |
| 538 | /** |
| 539 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 540 | * {@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] | 541 | * for more information. |
| 542 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 543 | * @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] | 544 | */ |
| 545 | public final TypedArray obtainStyledAttributes( |
Tor Norbye | c91531a | 2015-04-01 17:41:55 -0700 | [diff] [blame] | 546 | AttributeSet set, @StyleableRes int[] attrs, @AttrRes int defStyleAttr, |
| 547 | @StyleRes int defStyleRes) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 548 | return getTheme().obtainStyledAttributes( |
| 549 | set, attrs, defStyleAttr, defStyleRes); |
| 550 | } |
| 551 | |
| 552 | /** |
| 553 | * Return a class loader you can use to retrieve classes in this package. |
| 554 | */ |
| 555 | public abstract ClassLoader getClassLoader(); |
| 556 | |
| 557 | /** Return the name of this application's package. */ |
| 558 | public abstract String getPackageName(); |
| 559 | |
Dianne Hackborn | d8e1dbb | 2013-01-17 17:47:37 -0800 | [diff] [blame] | 560 | /** @hide Return the name of the base context this context is derived from. */ |
| 561 | public abstract String getBasePackageName(); |
| 562 | |
Dianne Hackborn | 95d7853 | 2013-09-11 09:51:14 -0700 | [diff] [blame] | 563 | /** @hide Return the package name that should be used for app ops calls from |
| 564 | * this context. This is the same as {@link #getBasePackageName()} except in |
| 565 | * cases where system components are loaded into other app processes, in which |
| 566 | * case this will be the name of the primary package in that process (so that app |
| 567 | * ops uid verification will work with the name). */ |
| 568 | public abstract String getOpPackageName(); |
| 569 | |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 570 | /** Return the full application info for this context's package. */ |
| 571 | public abstract ApplicationInfo getApplicationInfo(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 572 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 573 | /** |
Kenny Root | 3214839 | 2010-01-21 15:40:47 -0800 | [diff] [blame] | 574 | * Return the full path to this context's primary Android package. |
| 575 | * The Android package is a ZIP file which contains the application's |
| 576 | * primary resources. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 577 | * |
| 578 | * <p>Note: this is not generally useful for applications, since they should |
| 579 | * not be directly accessing the file system. |
| 580 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 581 | * @return String Path to the resources. |
| 582 | */ |
| 583 | public abstract String getPackageResourcePath(); |
| 584 | |
| 585 | /** |
Kenny Root | 3214839 | 2010-01-21 15:40:47 -0800 | [diff] [blame] | 586 | * Return the full path to this context's primary Android package. |
| 587 | * The Android package is a ZIP file which contains application's |
| 588 | * primary code and assets. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 589 | * |
| 590 | * <p>Note: this is not generally useful for applications, since they should |
| 591 | * not be directly accessing the file system. |
| 592 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 593 | * @return String Path to the code and assets. |
| 594 | */ |
| 595 | public abstract String getPackageCodePath(); |
| 596 | |
| 597 | /** |
Joe Onorato | 23ecae3 | 2009-06-10 17:07:15 -0700 | [diff] [blame] | 598 | * {@hide} |
| 599 | * Return the full path to the shared prefs file for the given prefs group name. |
| 600 | * |
| 601 | * <p>Note: this is not generally useful for applications, since they should |
| 602 | * not be directly accessing the file system. |
| 603 | */ |
| 604 | public abstract File getSharedPrefsFile(String name); |
| 605 | |
| 606 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 607 | * Retrieve and hold the contents of the preferences file 'name', returning |
| 608 | * a SharedPreferences through which you can retrieve and modify its |
| 609 | * values. Only one instance of the SharedPreferences object is returned |
| 610 | * to any callers for the same name, meaning they will see each other's |
| 611 | * edits as soon as they are made. |
| 612 | * |
| 613 | * @param name Desired preferences file. If a preferences file by this name |
| 614 | * does not exist, it will be created when you retrieve an |
| 615 | * editor (SharedPreferences.edit()) and then commit changes (Editor.commit()). |
| 616 | * @param mode Operating mode. Use 0 or {@link #MODE_PRIVATE} for the |
| 617 | * default operation, {@link #MODE_WORLD_READABLE} |
Christopher Tate | d5748b8 | 2015-05-08 18:14:01 -0700 | [diff] [blame] | 618 | * and {@link #MODE_WORLD_WRITEABLE} to control permissions. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 619 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 620 | * @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] | 621 | * to retrieve and modify the preference values. |
| 622 | * |
| 623 | * @see #MODE_PRIVATE |
| 624 | * @see #MODE_WORLD_READABLE |
| 625 | * @see #MODE_WORLD_WRITEABLE |
| 626 | */ |
| 627 | public abstract SharedPreferences getSharedPreferences(String name, |
| 628 | int mode); |
| 629 | |
| 630 | /** |
| 631 | * Open a private file associated with this Context's application package |
| 632 | * for reading. |
| 633 | * |
| 634 | * @param name The name of the file to open; can not contain path |
| 635 | * separators. |
| 636 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 637 | * @return The resulting {@link FileInputStream}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 638 | * |
| 639 | * @see #openFileOutput |
| 640 | * @see #fileList |
| 641 | * @see #deleteFile |
| 642 | * @see java.io.FileInputStream#FileInputStream(String) |
| 643 | */ |
| 644 | public abstract FileInputStream openFileInput(String name) |
| 645 | throws FileNotFoundException; |
| 646 | |
| 647 | /** |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 648 | * Open a private file associated with this Context's application package |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 649 | * for writing. Creates the file if it doesn't already exist. |
| 650 | * |
Ricardo Cervera | 90a5f98 | 2014-04-04 10:26:05 -0700 | [diff] [blame] | 651 | * <p>No permissions are required to invoke this method, since it uses internal |
| 652 | * storage. |
| 653 | * |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 654 | * @param name The name of the file to open; can not contain path |
| 655 | * separators. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 656 | * @param mode Operating mode. Use 0 or {@link #MODE_PRIVATE} for the |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 657 | * default operation, {@link #MODE_APPEND} to append to an existing file, |
| 658 | * {@link #MODE_WORLD_READABLE} and {@link #MODE_WORLD_WRITEABLE} to control |
| 659 | * permissions. |
| 660 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 661 | * @return The resulting {@link FileOutputStream}. |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 662 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 663 | * @see #MODE_APPEND |
| 664 | * @see #MODE_PRIVATE |
| 665 | * @see #MODE_WORLD_READABLE |
| 666 | * @see #MODE_WORLD_WRITEABLE |
| 667 | * @see #openFileInput |
| 668 | * @see #fileList |
| 669 | * @see #deleteFile |
| 670 | * @see java.io.FileOutputStream#FileOutputStream(String) |
| 671 | */ |
| 672 | public abstract FileOutputStream openFileOutput(String name, int mode) |
| 673 | throws FileNotFoundException; |
| 674 | |
| 675 | /** |
| 676 | * Delete the given private file associated with this Context's |
| 677 | * application package. |
| 678 | * |
| 679 | * @param name The name of the file to delete; can not contain path |
| 680 | * separators. |
| 681 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 682 | * @return {@code true} if the file was successfully deleted; else |
| 683 | * {@code false}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 684 | * |
| 685 | * @see #openFileInput |
| 686 | * @see #openFileOutput |
| 687 | * @see #fileList |
| 688 | * @see java.io.File#delete() |
| 689 | */ |
| 690 | public abstract boolean deleteFile(String name); |
| 691 | |
| 692 | /** |
| 693 | * Returns the absolute path on the filesystem where a file created with |
| 694 | * {@link #openFileOutput} is stored. |
| 695 | * |
| 696 | * @param name The name of the file for which you would like to get |
| 697 | * its path. |
| 698 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 699 | * @return An absolute path to the given file. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 700 | * |
| 701 | * @see #openFileOutput |
| 702 | * @see #getFilesDir |
| 703 | * @see #getDir |
| 704 | */ |
| 705 | public abstract File getFileStreamPath(String name); |
| 706 | |
| 707 | /** |
| 708 | * Returns the absolute path to the directory on the filesystem where |
| 709 | * files created with {@link #openFileOutput} are stored. |
| 710 | * |
Ricardo Cervera | 90a5f98 | 2014-04-04 10:26:05 -0700 | [diff] [blame] | 711 | * <p>No permissions are required to read or write to the returned path, since this |
| 712 | * path is internal storage. |
| 713 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 714 | * @return The path of the directory holding application files. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 715 | * |
| 716 | * @see #openFileOutput |
| 717 | * @see #getFileStreamPath |
| 718 | * @see #getDir |
| 719 | */ |
| 720 | public abstract File getFilesDir(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 721 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 722 | /** |
Christopher Tate | a7835b6 | 2014-07-11 17:25:57 -0700 | [diff] [blame] | 723 | * Returns the absolute path to the directory on the filesystem similar to |
| 724 | * {@link #getFilesDir()}. The difference is that files placed under this |
| 725 | * directory will be excluded from automatic backup to remote storage. See |
| 726 | * {@link android.app.backup.BackupAgent BackupAgent} for a full discussion |
| 727 | * of the automatic backup mechanism in Android. |
| 728 | * |
| 729 | * <p>No permissions are required to read or write to the returned path, since this |
| 730 | * path is internal storage. |
| 731 | * |
| 732 | * @return The path of the directory holding application files that will not be |
| 733 | * automatically backed up to remote storage. |
| 734 | * |
| 735 | * @see #openFileOutput |
| 736 | * @see #getFileStreamPath |
| 737 | * @see #getDir |
| 738 | * @see android.app.backup.BackupAgent |
| 739 | */ |
| 740 | public abstract File getNoBackupFilesDir(); |
| 741 | |
| 742 | /** |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 743 | * Returns the absolute path to the directory on the primary external filesystem |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 744 | * (that is somewhere on {@link android.os.Environment#getExternalStorageDirectory() |
Dianne Hackborn | acaf028 | 2010-03-30 14:39:35 -0700 | [diff] [blame] | 745 | * Environment.getExternalStorageDirectory()}) where the application can |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 746 | * place persistent files it owns. These files are internal to the |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 747 | * applications, and not typically visible to the user as media. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 748 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 749 | * <p>This is like {@link #getFilesDir()} in that these |
| 750 | * files will be deleted when the application is uninstalled, however there |
| 751 | * are some important differences: |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 752 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 753 | * <ul> |
| 754 | * <li>External files are not always available: they will disappear if the |
| 755 | * user mounts the external storage on a computer or removes it. See the |
| 756 | * APIs on {@link android.os.Environment} for information in the storage state. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 757 | * <li>There is no security enforced with these files. For example, any application |
| 758 | * holding {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 759 | * these files. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 760 | * </ul> |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 761 | * |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 762 | * <p>Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions |
| 763 | * are required to read or write to the returned path; it's always |
| 764 | * accessible to the calling app. This only applies to paths generated for |
| 765 | * package name of the calling application. To access paths belonging |
| 766 | * to other packages, {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} |
| 767 | * and/or {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} are required. |
| 768 | * |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 769 | * <p>On devices with multiple users (as described by {@link UserManager}), |
| 770 | * each user has their own isolated external storage. Applications only |
| 771 | * have access to the external storage for the user they're running as.</p> |
| 772 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 773 | * <p>Here is an example of typical code to manipulate a file in |
| 774 | * an application's private storage:</p> |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 775 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 776 | * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java |
| 777 | * private_file} |
| 778 | * |
Dianne Hackborn | acaf028 | 2010-03-30 14:39:35 -0700 | [diff] [blame] | 779 | * <p>If you supply a non-null <var>type</var> to this function, the returned |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 780 | * file will be a path to a sub-directory of the given type. Though these files |
| 781 | * are not automatically scanned by the media scanner, you can explicitly |
| 782 | * add them to the media database with |
| 783 | * {@link android.media.MediaScannerConnection#scanFile(Context, String[], String[], |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 784 | * android.media.MediaScannerConnection.OnScanCompletedListener) |
| 785 | * MediaScannerConnection.scanFile}. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 786 | * Note that this is not the same as |
| 787 | * {@link android.os.Environment#getExternalStoragePublicDirectory |
| 788 | * Environment.getExternalStoragePublicDirectory()}, which provides |
| 789 | * directories of media shared by all applications. The |
| 790 | * directories returned here are |
Dianne Hackborn | acaf028 | 2010-03-30 14:39:35 -0700 | [diff] [blame] | 791 | * owned by the application, and their contents will be removed when the |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 792 | * application is uninstalled. Unlike |
| 793 | * {@link android.os.Environment#getExternalStoragePublicDirectory |
| 794 | * Environment.getExternalStoragePublicDirectory()}, the directory |
| 795 | * returned here will be automatically created for you. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 796 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 797 | * <p>Here is an example of typical code to manipulate a picture in |
| 798 | * an application's private storage and add it to the media database:</p> |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 799 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 800 | * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java |
| 801 | * private_picture} |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 802 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 803 | * @param type The type of files directory to return. May be null for |
| 804 | * the root of the files directory or one of |
| 805 | * the following Environment constants for a subdirectory: |
| 806 | * {@link android.os.Environment#DIRECTORY_MUSIC}, |
| 807 | * {@link android.os.Environment#DIRECTORY_PODCASTS}, |
| 808 | * {@link android.os.Environment#DIRECTORY_RINGTONES}, |
| 809 | * {@link android.os.Environment#DIRECTORY_ALARMS}, |
| 810 | * {@link android.os.Environment#DIRECTORY_NOTIFICATIONS}, |
| 811 | * {@link android.os.Environment#DIRECTORY_PICTURES}, or |
| 812 | * {@link android.os.Environment#DIRECTORY_MOVIES}. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 813 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 814 | * @return The path of the directory holding application files |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 815 | * on external storage. Returns null if external storage is not currently |
| 816 | * mounted so it could not ensure the path exists; you will need to call |
| 817 | * this method again when it is available. |
| 818 | * |
| 819 | * @see #getFilesDir |
Dianne Hackborn | acaf028 | 2010-03-30 14:39:35 -0700 | [diff] [blame] | 820 | * @see android.os.Environment#getExternalStoragePublicDirectory |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 821 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 822 | @Nullable |
| 823 | public abstract File getExternalFilesDir(@Nullable String type); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 824 | |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 825 | /** |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 826 | * Returns absolute paths to application-specific directories on all |
| 827 | * external storage devices where the application can place persistent files |
| 828 | * it owns. These files are internal to the application, and not typically |
| 829 | * visible to the user as media. |
| 830 | * <p> |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 831 | * This is like {@link #getFilesDir()} in that these files will be deleted when |
| 832 | * the application is uninstalled, however there are some important differences: |
| 833 | * <ul> |
| 834 | * <li>External files are not always available: they will disappear if the |
| 835 | * user mounts the external storage on a computer or removes it. |
| 836 | * <li>There is no security enforced with these files. |
| 837 | * </ul> |
| 838 | * <p> |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 839 | * External storage devices returned here are considered a permanent part of |
| 840 | * the device, including both emulated external storage and physical media |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 841 | * slots, such as SD cards in a battery compartment. The returned paths do |
| 842 | * not include transient devices, such as USB flash drives. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 843 | * <p> |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 844 | * An application may store data on any or all of the returned devices. For |
| 845 | * example, an app may choose to store large files on the device with the |
| 846 | * most available space, as measured by {@link StatFs}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 847 | * <p> |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 848 | * No permissions are required to read or write to the returned paths; they |
| 849 | * are always accessible to the calling app. Write access outside of these |
| 850 | * paths on secondary external storage devices is not available. |
| 851 | * <p> |
| 852 | * The first path returned is the same as {@link #getExternalFilesDir(String)}. |
| 853 | * Returned paths may be {@code null} if a storage device is unavailable. |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 854 | * |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 855 | * @see #getExternalFilesDir(String) |
Jeff Sharkey | 4ca728c | 2014-01-10 16:27:19 -0800 | [diff] [blame] | 856 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 857 | */ |
| 858 | public abstract File[] getExternalFilesDirs(String type); |
| 859 | |
| 860 | /** |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 861 | * Return the primary external storage directory where this application's OBB |
| 862 | * files (if there are any) can be found. Note if the application does not have |
| 863 | * any OBB files, this directory may not exist. |
| 864 | * <p> |
| 865 | * This is like {@link #getFilesDir()} in that these files will be deleted when |
| 866 | * the application is uninstalled, however there are some important differences: |
| 867 | * <ul> |
| 868 | * <li>External files are not always available: they will disappear if the |
| 869 | * user mounts the external storage on a computer or removes it. |
| 870 | * <li>There is no security enforced with these files. For example, any application |
| 871 | * holding {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 872 | * these files. |
| 873 | * </ul> |
| 874 | * <p> |
| 875 | * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions |
| 876 | * are required to read or write to the returned path; it's always |
| 877 | * accessible to the calling app. This only applies to paths generated for |
| 878 | * package name of the calling application. To access paths belonging |
| 879 | * to other packages, {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} |
| 880 | * and/or {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} are required. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 881 | * <p> |
| 882 | * On devices with multiple users (as described by {@link UserManager}), |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 883 | * multiple users may share the same OBB storage location. Applications |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 884 | * should ensure that multiple instances running under different users don't |
| 885 | * interfere with each other. |
Dianne Hackborn | 805fd7e | 2011-01-16 18:30:29 -0800 | [diff] [blame] | 886 | */ |
| 887 | public abstract File getObbDir(); |
| 888 | |
| 889 | /** |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 890 | * Returns absolute paths to application-specific directories on all |
| 891 | * external storage devices where the application's OBB files (if there are |
| 892 | * any) can be found. Note if the application does not have any OBB files, |
| 893 | * these directories may not exist. |
| 894 | * <p> |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 895 | * This is like {@link #getFilesDir()} in that these files will be deleted when |
| 896 | * the application is uninstalled, however there are some important differences: |
| 897 | * <ul> |
| 898 | * <li>External files are not always available: they will disappear if the |
| 899 | * user mounts the external storage on a computer or removes it. |
| 900 | * <li>There is no security enforced with these files. |
| 901 | * </ul> |
| 902 | * <p> |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 903 | * External storage devices returned here are considered a permanent part of |
| 904 | * the device, including both emulated external storage and physical media |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 905 | * slots, such as SD cards in a battery compartment. The returned paths do |
| 906 | * not include transient devices, such as USB flash drives. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 907 | * <p> |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 908 | * An application may store data on any or all of the returned devices. For |
| 909 | * example, an app may choose to store large files on the device with the |
| 910 | * most available space, as measured by {@link StatFs}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 911 | * <p> |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 912 | * No permissions are required to read or write to the returned paths; they |
| 913 | * are always accessible to the calling app. Write access outside of these |
| 914 | * paths on secondary external storage devices is not available. |
| 915 | * <p> |
| 916 | * The first path returned is the same as {@link #getObbDir()}. |
| 917 | * Returned paths may be {@code null} if a storage device is unavailable. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 918 | * |
| 919 | * @see #getObbDir() |
Jeff Sharkey | 4ca728c | 2014-01-10 16:27:19 -0800 | [diff] [blame] | 920 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 921 | */ |
| 922 | public abstract File[] getObbDirs(); |
| 923 | |
| 924 | /** |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 925 | * Returns the absolute path to the application specific cache directory |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 926 | * on the filesystem. These files will be ones that get deleted first when the |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 927 | * device runs low on storage. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 928 | * There is no guarantee when these files will be deleted. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 929 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 930 | * <strong>Note: you should not <em>rely</em> on the system deleting these |
| 931 | * files for you; you should always have a reasonable maximum, such as 1 MB, |
| 932 | * for the amount of space you consume with cache files, and prune those |
| 933 | * files when exceeding that space.</strong> |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 934 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 935 | * @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] | 936 | * |
| 937 | * @see #openFileOutput |
| 938 | * @see #getFileStreamPath |
| 939 | * @see #getDir |
| 940 | */ |
| 941 | public abstract File getCacheDir(); |
| 942 | |
| 943 | /** |
Jeff Sharkey | 4ed745d | 2014-07-15 20:39:15 -0700 | [diff] [blame] | 944 | * Returns the absolute path to the application specific cache directory on |
| 945 | * the filesystem designed for storing cached code. The system will delete |
| 946 | * any files stored in this location both when your specific application is |
| 947 | * upgraded, and when the entire platform is upgraded. |
| 948 | * <p> |
| 949 | * This location is optimal for storing compiled or optimized code generated |
| 950 | * by your application at runtime. |
| 951 | * <p> |
| 952 | * Apps require no extra permissions to read or write to the returned path, |
| 953 | * since this path lives in their private storage. |
| 954 | * |
| 955 | * @return The path of the directory holding application code cache files. |
| 956 | */ |
| 957 | public abstract File getCodeCacheDir(); |
| 958 | |
| 959 | /** |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 960 | * Returns the absolute path to the directory on the primary external filesystem |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 961 | * (that is somewhere on {@link android.os.Environment#getExternalStorageDirectory() |
| 962 | * Environment.getExternalStorageDirectory()} where the application can |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 963 | * place cache files it owns. These files are internal to the application, and |
| 964 | * not typically visible to the user as media. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 965 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 966 | * <p>This is like {@link #getCacheDir()} in that these |
| 967 | * files will be deleted when the application is uninstalled, however there |
| 968 | * are some important differences: |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 969 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 970 | * <ul> |
Dianne Hackborn | 556b09e | 2012-09-23 17:46:53 -0700 | [diff] [blame] | 971 | * <li>The platform does not always monitor the space available in external |
| 972 | * storage, and thus may not automatically delete these files. Currently |
| 973 | * the only time files here will be deleted by the platform is when running |
| 974 | * on {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} or later and |
| 975 | * {@link android.os.Environment#isExternalStorageEmulated() |
| 976 | * Environment.isExternalStorageEmulated()} returns true. Note that you should |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 977 | * be managing the maximum space you will use for these anyway, just like |
| 978 | * with {@link #getCacheDir()}. |
| 979 | * <li>External files are not always available: they will disappear if the |
| 980 | * user mounts the external storage on a computer or removes it. See the |
| 981 | * APIs on {@link android.os.Environment} for information in the storage state. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 982 | * <li>There is no security enforced with these files. For example, any application |
| 983 | * holding {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 984 | * these files. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 985 | * </ul> |
| 986 | * |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 987 | * <p>Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions |
| 988 | * are required to read or write to the returned path; it's always |
| 989 | * accessible to the calling app. This only applies to paths generated for |
| 990 | * package name of the calling application. To access paths belonging |
| 991 | * to other packages, {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} |
| 992 | * and/or {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} are required. |
| 993 | * |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 994 | * <p>On devices with multiple users (as described by {@link UserManager}), |
| 995 | * each user has their own isolated external storage. Applications only |
| 996 | * have access to the external storage for the user they're running as.</p> |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 997 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 998 | * @return The path of the directory holding application cache files |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 999 | * on external storage. Returns null if external storage is not currently |
| 1000 | * mounted so it could not ensure the path exists; you will need to call |
| 1001 | * this method again when it is available. |
| 1002 | * |
| 1003 | * @see #getCacheDir |
| 1004 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1005 | @Nullable |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1006 | public abstract File getExternalCacheDir(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1007 | |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1008 | /** |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1009 | * Returns absolute paths to application-specific directories on all |
| 1010 | * external storage devices where the application can place cache files it |
| 1011 | * owns. These files are internal to the application, and not typically |
| 1012 | * visible to the user as media. |
| 1013 | * <p> |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1014 | * This is like {@link #getCacheDir()} in that these files will be deleted when |
| 1015 | * the application is uninstalled, however there are some important differences: |
| 1016 | * <ul> |
| 1017 | * <li>External files are not always available: they will disappear if the |
| 1018 | * user mounts the external storage on a computer or removes it. |
| 1019 | * <li>There is no security enforced with these files. |
| 1020 | * </ul> |
| 1021 | * <p> |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1022 | * External storage devices returned here are considered a permanent part of |
| 1023 | * the device, including both emulated external storage and physical media |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1024 | * slots, such as SD cards in a battery compartment. The returned paths do |
| 1025 | * not include transient devices, such as USB flash drives. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1026 | * <p> |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1027 | * An application may store data on any or all of the returned devices. For |
| 1028 | * example, an app may choose to store large files on the device with the |
| 1029 | * most available space, as measured by {@link StatFs}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1030 | * <p> |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1031 | * No permissions are required to read or write to the returned paths; they |
| 1032 | * are always accessible to the calling app. Write access outside of these |
| 1033 | * paths on secondary external storage devices is not available. |
| 1034 | * <p> |
| 1035 | * The first path returned is the same as {@link #getExternalCacheDir()}. |
| 1036 | * Returned paths may be {@code null} if a storage device is unavailable. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1037 | * |
| 1038 | * @see #getExternalCacheDir() |
Jeff Sharkey | 4ca728c | 2014-01-10 16:27:19 -0800 | [diff] [blame] | 1039 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1040 | */ |
| 1041 | public abstract File[] getExternalCacheDirs(); |
| 1042 | |
| 1043 | /** |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1044 | * Returns absolute paths to application-specific directories on all |
| 1045 | * external storage devices where the application can place media files. |
| 1046 | * These files are scanned and made available to other apps through |
| 1047 | * {@link MediaStore}. |
| 1048 | * <p> |
| 1049 | * This is like {@link #getExternalFilesDirs} in that these files will be |
| 1050 | * deleted when the application is uninstalled, however there are some |
| 1051 | * important differences: |
| 1052 | * <ul> |
| 1053 | * <li>External files are not always available: they will disappear if the |
| 1054 | * user mounts the external storage on a computer or removes it. |
| 1055 | * <li>There is no security enforced with these files. |
| 1056 | * </ul> |
| 1057 | * <p> |
| 1058 | * External storage devices returned here are considered a permanent part of |
| 1059 | * the device, including both emulated external storage and physical media |
| 1060 | * slots, such as SD cards in a battery compartment. The returned paths do |
| 1061 | * not include transient devices, such as USB flash drives. |
| 1062 | * <p> |
| 1063 | * An application may store data on any or all of the returned devices. For |
| 1064 | * example, an app may choose to store large files on the device with the |
| 1065 | * most available space, as measured by {@link StatFs}. |
| 1066 | * <p> |
| 1067 | * No permissions are required to read or write to the returned paths; they |
| 1068 | * are always accessible to the calling app. Write access outside of these |
| 1069 | * paths on secondary external storage devices is not available. |
| 1070 | * <p> |
| 1071 | * Returned paths may be {@code null} if a storage device is unavailable. |
| 1072 | * |
| 1073 | * @see Environment#getExternalStorageState(File) |
| 1074 | */ |
| 1075 | public abstract File[] getExternalMediaDirs(); |
| 1076 | |
| 1077 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1078 | * Returns an array of strings naming the private files associated with |
| 1079 | * this Context's application package. |
| 1080 | * |
| 1081 | * @return Array of strings naming the private files. |
| 1082 | * |
| 1083 | * @see #openFileInput |
| 1084 | * @see #openFileOutput |
| 1085 | * @see #deleteFile |
| 1086 | */ |
| 1087 | public abstract String[] fileList(); |
| 1088 | |
| 1089 | /** |
| 1090 | * Retrieve, creating if needed, a new directory in which the application |
| 1091 | * can place its own custom data files. You can use the returned File |
| 1092 | * object to create and access files in this directory. Note that files |
| 1093 | * created through a File object will only be accessible by your own |
| 1094 | * application; you can only set the mode of the entire directory, not |
| 1095 | * of individual files. |
| 1096 | * |
Nick Kralevich | 92091fa | 2012-12-12 16:24:31 -0800 | [diff] [blame] | 1097 | * @param name Name of the directory to retrieve. This is a directory |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1098 | * that is created as part of your application data. |
Nick Kralevich | 92091fa | 2012-12-12 16:24:31 -0800 | [diff] [blame] | 1099 | * @param mode Operating mode. Use 0 or {@link #MODE_PRIVATE} for the |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1100 | * default operation, {@link #MODE_WORLD_READABLE} and |
| 1101 | * {@link #MODE_WORLD_WRITEABLE} to control permissions. |
| 1102 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1103 | * @return A {@link File} object for the requested directory. The directory |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1104 | * 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] | 1105 | * |
| 1106 | * @see #openFileOutput(String, int) |
| 1107 | */ |
| 1108 | public abstract File getDir(String name, int mode); |
| 1109 | |
| 1110 | /** |
| 1111 | * Open a new private SQLiteDatabase associated with this Context's |
| 1112 | * application package. Create the database file if it doesn't exist. |
| 1113 | * |
| 1114 | * @param name The name (unique in the application package) of the database. |
| 1115 | * @param mode Operating mode. Use 0 or {@link #MODE_PRIVATE} for the |
| 1116 | * default operation, {@link #MODE_WORLD_READABLE} |
| 1117 | * and {@link #MODE_WORLD_WRITEABLE} to control permissions. |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 1118 | * Use {@link #MODE_ENABLE_WRITE_AHEAD_LOGGING} to enable write-ahead logging by default. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1119 | * @param factory An optional factory class that is called to instantiate a |
| 1120 | * cursor when query is called. |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1121 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1122 | * @return The contents of a newly created database with the given name. |
| 1123 | * @throws android.database.sqlite.SQLiteException if the database file could not be opened. |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1124 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1125 | * @see #MODE_PRIVATE |
| 1126 | * @see #MODE_WORLD_READABLE |
| 1127 | * @see #MODE_WORLD_WRITEABLE |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 1128 | * @see #MODE_ENABLE_WRITE_AHEAD_LOGGING |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1129 | * @see #deleteDatabase |
| 1130 | */ |
| 1131 | public abstract SQLiteDatabase openOrCreateDatabase(String name, |
| 1132 | int mode, CursorFactory factory); |
| 1133 | |
| 1134 | /** |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1135 | * Open a new private SQLiteDatabase associated with this Context's |
| 1136 | * application package. Creates the database file if it doesn't exist. |
| 1137 | * |
| 1138 | * <p>Accepts input param: a concrete instance of {@link DatabaseErrorHandler} to be |
| 1139 | * used to handle corruption when sqlite reports database corruption.</p> |
| 1140 | * |
| 1141 | * @param name The name (unique in the application package) of the database. |
| 1142 | * @param mode Operating mode. Use 0 or {@link #MODE_PRIVATE} for the |
| 1143 | * default operation, {@link #MODE_WORLD_READABLE} |
| 1144 | * and {@link #MODE_WORLD_WRITEABLE} to control permissions. |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 1145 | * Use {@link #MODE_ENABLE_WRITE_AHEAD_LOGGING} to enable write-ahead logging by default. |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1146 | * @param factory An optional factory class that is called to instantiate a |
| 1147 | * cursor when query is called. |
| 1148 | * @param errorHandler the {@link DatabaseErrorHandler} to be used when sqlite reports database |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1149 | * corruption. if null, {@link android.database.DefaultDatabaseErrorHandler} is assumed. |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1150 | * @return The contents of a newly created database with the given name. |
| 1151 | * @throws android.database.sqlite.SQLiteException if the database file could not be opened. |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1152 | * |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1153 | * @see #MODE_PRIVATE |
| 1154 | * @see #MODE_WORLD_READABLE |
| 1155 | * @see #MODE_WORLD_WRITEABLE |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 1156 | * @see #MODE_ENABLE_WRITE_AHEAD_LOGGING |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1157 | * @see #deleteDatabase |
| 1158 | */ |
| 1159 | public abstract SQLiteDatabase openOrCreateDatabase(String name, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1160 | int mode, CursorFactory factory, |
| 1161 | @Nullable DatabaseErrorHandler errorHandler); |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1162 | |
| 1163 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1164 | * Delete an existing private SQLiteDatabase associated with this Context's |
| 1165 | * application package. |
| 1166 | * |
| 1167 | * @param name The name (unique in the application package) of the |
| 1168 | * database. |
| 1169 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1170 | * @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] | 1171 | * |
| 1172 | * @see #openOrCreateDatabase |
| 1173 | */ |
| 1174 | public abstract boolean deleteDatabase(String name); |
| 1175 | |
| 1176 | /** |
| 1177 | * Returns the absolute path on the filesystem where a database created with |
| 1178 | * {@link #openOrCreateDatabase} is stored. |
| 1179 | * |
| 1180 | * @param name The name of the database for which you would like to get |
| 1181 | * its path. |
| 1182 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1183 | * @return An absolute path to the given database. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1184 | * |
| 1185 | * @see #openOrCreateDatabase |
| 1186 | */ |
| 1187 | public abstract File getDatabasePath(String name); |
| 1188 | |
| 1189 | /** |
| 1190 | * Returns an array of strings naming the private databases associated with |
| 1191 | * this Context's application package. |
| 1192 | * |
| 1193 | * @return Array of strings naming the private databases. |
| 1194 | * |
| 1195 | * @see #openOrCreateDatabase |
| 1196 | * @see #deleteDatabase |
| 1197 | */ |
| 1198 | public abstract String[] databaseList(); |
| 1199 | |
| 1200 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1201 | * @deprecated Use {@link android.app.WallpaperManager#getDrawable |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1202 | * WallpaperManager.get()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1203 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1204 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1205 | public abstract Drawable getWallpaper(); |
| 1206 | |
| 1207 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1208 | * @deprecated Use {@link android.app.WallpaperManager#peekDrawable |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1209 | * WallpaperManager.peek()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1210 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1211 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1212 | public abstract Drawable peekWallpaper(); |
| 1213 | |
| 1214 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1215 | * @deprecated Use {@link android.app.WallpaperManager#getDesiredMinimumWidth() |
| 1216 | * WallpaperManager.getDesiredMinimumWidth()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1217 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1218 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1219 | public abstract int getWallpaperDesiredMinimumWidth(); |
| 1220 | |
| 1221 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1222 | * @deprecated Use {@link android.app.WallpaperManager#getDesiredMinimumHeight() |
| 1223 | * WallpaperManager.getDesiredMinimumHeight()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1224 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1225 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1226 | public abstract int getWallpaperDesiredMinimumHeight(); |
| 1227 | |
| 1228 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1229 | * @deprecated Use {@link android.app.WallpaperManager#setBitmap(Bitmap) |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1230 | * WallpaperManager.set()} instead. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 1231 | * <p>This method requires the caller to hold the permission |
| 1232 | * {@link android.Manifest.permission#SET_WALLPAPER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1233 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1234 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1235 | public abstract void setWallpaper(Bitmap bitmap) throws IOException; |
| 1236 | |
| 1237 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1238 | * @deprecated Use {@link android.app.WallpaperManager#setStream(InputStream) |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1239 | * WallpaperManager.set()} instead. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 1240 | * <p>This method requires the caller to hold the permission |
| 1241 | * {@link android.Manifest.permission#SET_WALLPAPER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1242 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1243 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1244 | public abstract void setWallpaper(InputStream data) throws IOException; |
| 1245 | |
| 1246 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1247 | * @deprecated Use {@link android.app.WallpaperManager#clear |
| 1248 | * WallpaperManager.clear()} instead. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 1249 | * <p>This method requires the caller to hold the permission |
| 1250 | * {@link android.Manifest.permission#SET_WALLPAPER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1251 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1252 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1253 | public abstract void clearWallpaper() throws IOException; |
| 1254 | |
| 1255 | /** |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1256 | * Same as {@link #startActivity(Intent, Bundle)} with no options |
| 1257 | * specified. |
| 1258 | * |
| 1259 | * @param intent The description of the activity to start. |
| 1260 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1261 | * @throws ActivityNotFoundException |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1262 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1263 | * @see #startActivity(Intent, Bundle) |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1264 | * @see PackageManager#resolveActivity |
| 1265 | */ |
| 1266 | public abstract void startActivity(Intent intent); |
| 1267 | |
| 1268 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1269 | * Version of {@link #startActivity(Intent)} that allows you to specify the |
| 1270 | * user the activity will be started for. This is not available to applications |
| 1271 | * that are not pre-installed on the system image. Using it requires holding |
| 1272 | * the INTERACT_ACROSS_USERS_FULL permission. |
Amith Yamasani | 8264408 | 2012-08-03 13:09:11 -0700 | [diff] [blame] | 1273 | * @param intent The description of the activity to start. |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 1274 | * @param user The UserHandle of the user to start this activity for. |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1275 | * @throws ActivityNotFoundException |
Amith Yamasani | 8264408 | 2012-08-03 13:09:11 -0700 | [diff] [blame] | 1276 | * @hide |
| 1277 | */ |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 1278 | public void startActivityAsUser(Intent intent, UserHandle user) { |
Amith Yamasani | 8264408 | 2012-08-03 13:09:11 -0700 | [diff] [blame] | 1279 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 1280 | } |
| 1281 | |
| 1282 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1283 | * Launch a new activity. You will not receive any information about when |
| 1284 | * the activity exits. |
| 1285 | * |
| 1286 | * <p>Note that if this method is being called from outside of an |
| 1287 | * {@link android.app.Activity} Context, then the Intent must include |
| 1288 | * the {@link Intent#FLAG_ACTIVITY_NEW_TASK} launch flag. This is because, |
| 1289 | * without being started from an existing Activity, there is no existing |
| 1290 | * task in which to place the new activity and thus it needs to be placed |
| 1291 | * in its own separate task. |
| 1292 | * |
| 1293 | * <p>This method throws {@link ActivityNotFoundException} |
| 1294 | * if there was no Activity found to run the given Intent. |
| 1295 | * |
| 1296 | * @param intent The description of the activity to start. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1297 | * @param options Additional options for how the Activity should be started. |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 1298 | * May be null if there are no options. See {@link android.app.ActivityOptions} |
| 1299 | * for how to build the Bundle supplied here; there are no supported definitions |
| 1300 | * for building it manually. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1301 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1302 | * @throws ActivityNotFoundException |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1303 | * |
Scott Main | 60dd520 | 2012-06-23 00:01:22 -0700 | [diff] [blame] | 1304 | * @see #startActivity(Intent) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1305 | * @see PackageManager#resolveActivity |
| 1306 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1307 | public abstract void startActivity(Intent intent, @Nullable Bundle options); |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1308 | |
| 1309 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1310 | * Version of {@link #startActivity(Intent, Bundle)} that allows you to specify the |
| 1311 | * user the activity will be started for. This is not available to applications |
| 1312 | * that are not pre-installed on the system image. Using it requires holding |
| 1313 | * the INTERACT_ACROSS_USERS_FULL permission. |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 1314 | * @param intent The description of the activity to start. |
| 1315 | * @param options Additional options for how the Activity should be started. |
| 1316 | * May be null if there are no options. See {@link android.app.ActivityOptions} |
| 1317 | * for how to build the Bundle supplied here; there are no supported definitions |
| 1318 | * for building it manually. |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 1319 | * @param userId The UserHandle of the user to start this activity for. |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1320 | * @throws ActivityNotFoundException |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 1321 | * @hide |
| 1322 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1323 | public void startActivityAsUser(Intent intent, @Nullable Bundle options, UserHandle userId) { |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 1324 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 1325 | } |
| 1326 | |
| 1327 | /** |
Clara Bayarri | d5bf3ed | 2015-03-27 17:32:45 +0000 | [diff] [blame] | 1328 | * Version of {@link #startActivity(Intent, Bundle)} that returns a result to the caller. This |
| 1329 | * is only supported for Views and Fragments. |
| 1330 | * @param who The identifier for the calling element that will receive the result. |
| 1331 | * @param intent The intent to start. |
| 1332 | * @param requestCode The code that will be returned with onActivityResult() identifying this |
| 1333 | * request. |
| 1334 | * @param options Additional options for how the Activity should be started. |
| 1335 | * May be null if there are no options. See {@link android.app.ActivityOptions} |
| 1336 | * for how to build the Bundle supplied here; there are no supported definitions |
| 1337 | * for building it manually. |
| 1338 | * @hide |
| 1339 | */ |
| 1340 | public void startActivityForResult( |
| 1341 | @NonNull String who, Intent intent, int requestCode, @Nullable Bundle options) { |
| 1342 | throw new RuntimeException("This method is only implemented for Activity-based Contexts. " |
| 1343 | + "Check canStartActivityForResult() before calling."); |
| 1344 | } |
| 1345 | |
| 1346 | /** |
| 1347 | * Identifies whether this Context instance will be able to process calls to |
| 1348 | * {@link #startActivityForResult(String, Intent, int, Bundle)}. |
| 1349 | * @hide |
| 1350 | */ |
| 1351 | public boolean canStartActivityForResult() { |
| 1352 | return false; |
| 1353 | } |
| 1354 | |
| 1355 | /** |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1356 | * Same as {@link #startActivities(Intent[], Bundle)} with no options |
| 1357 | * specified. |
| 1358 | * |
| 1359 | * @param intents An array of Intents to be started. |
| 1360 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1361 | * @throws ActivityNotFoundException |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1362 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1363 | * @see #startActivities(Intent[], Bundle) |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1364 | * @see PackageManager#resolveActivity |
| 1365 | */ |
| 1366 | public abstract void startActivities(Intent[] intents); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1367 | |
| 1368 | /** |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1369 | * Launch multiple new activities. This is generally the same as calling |
| 1370 | * {@link #startActivity(Intent)} for the first Intent in the array, |
| 1371 | * that activity during its creation calling {@link #startActivity(Intent)} |
| 1372 | * for the second entry, etc. Note that unlike that approach, generally |
| 1373 | * none of the activities except the last in the array will be created |
| 1374 | * at this point, but rather will be created when the user first visits |
| 1375 | * them (due to pressing back from the activity on top). |
| 1376 | * |
| 1377 | * <p>This method throws {@link ActivityNotFoundException} |
| 1378 | * if there was no Activity found for <em>any</em> given Intent. In this |
| 1379 | * case the state of the activity stack is undefined (some Intents in the |
| 1380 | * list may be on it, some not), so you probably want to avoid such situations. |
| 1381 | * |
| 1382 | * @param intents An array of Intents to be started. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1383 | * @param options Additional options for how the Activity should be started. |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 1384 | * See {@link android.content.Context#startActivity(Intent, Bundle) |
| 1385 | * Context.startActivity(Intent, Bundle)} for more details. |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1386 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1387 | * @throws ActivityNotFoundException |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1388 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1389 | * @see #startActivities(Intent[]) |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1390 | * @see PackageManager#resolveActivity |
| 1391 | */ |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1392 | public abstract void startActivities(Intent[] intents, Bundle options); |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1393 | |
| 1394 | /** |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1395 | * @hide |
| 1396 | * Launch multiple new activities. This is generally the same as calling |
| 1397 | * {@link #startActivity(Intent)} for the first Intent in the array, |
| 1398 | * that activity during its creation calling {@link #startActivity(Intent)} |
| 1399 | * for the second entry, etc. Note that unlike that approach, generally |
| 1400 | * none of the activities except the last in the array will be created |
| 1401 | * at this point, but rather will be created when the user first visits |
| 1402 | * them (due to pressing back from the activity on top). |
| 1403 | * |
| 1404 | * <p>This method throws {@link ActivityNotFoundException} |
| 1405 | * if there was no Activity found for <em>any</em> given Intent. In this |
| 1406 | * case the state of the activity stack is undefined (some Intents in the |
| 1407 | * list may be on it, some not), so you probably want to avoid such situations. |
| 1408 | * |
| 1409 | * @param intents An array of Intents to be started. |
| 1410 | * @param options Additional options for how the Activity should be started. |
| 1411 | * @param userHandle The user for whom to launch the activities |
| 1412 | * See {@link android.content.Context#startActivity(Intent, Bundle) |
| 1413 | * Context.startActivity(Intent, Bundle)} for more details. |
| 1414 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1415 | * @throws ActivityNotFoundException |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1416 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1417 | * @see #startActivities(Intent[]) |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1418 | * @see PackageManager#resolveActivity |
| 1419 | */ |
| 1420 | public void startActivitiesAsUser(Intent[] intents, Bundle options, UserHandle userHandle) { |
| 1421 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 1422 | } |
| 1423 | |
| 1424 | /** |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1425 | * Same as {@link #startIntentSender(IntentSender, Intent, int, int, int, Bundle)} |
| 1426 | * with no options specified. |
| 1427 | * |
| 1428 | * @param intent The IntentSender to launch. |
| 1429 | * @param fillInIntent If non-null, this will be provided as the |
| 1430 | * intent parameter to {@link IntentSender#sendIntent}. |
| 1431 | * @param flagsMask Intent flags in the original IntentSender that you |
| 1432 | * would like to change. |
| 1433 | * @param flagsValues Desired values for any bits set in |
| 1434 | * <var>flagsMask</var> |
| 1435 | * @param extraFlags Always set to 0. |
| 1436 | * |
| 1437 | * @see #startActivity(Intent) |
| 1438 | * @see #startIntentSender(IntentSender, Intent, int, int, int, Bundle) |
| 1439 | */ |
| 1440 | public abstract void startIntentSender(IntentSender intent, |
| 1441 | Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags) |
| 1442 | throws IntentSender.SendIntentException; |
| 1443 | |
| 1444 | /** |
| 1445 | * Like {@link #startActivity(Intent, Bundle)}, but taking a IntentSender |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1446 | * 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] | 1447 | * as if you had called the regular {@link #startActivity(Intent)} |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1448 | * here; otherwise, its associated action will be executed (such as |
| 1449 | * sending a broadcast) as if you had called |
| 1450 | * {@link IntentSender#sendIntent IntentSender.sendIntent} on it. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1451 | * |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1452 | * @param intent The IntentSender to launch. |
| 1453 | * @param fillInIntent If non-null, this will be provided as the |
| 1454 | * intent parameter to {@link IntentSender#sendIntent}. |
| 1455 | * @param flagsMask Intent flags in the original IntentSender that you |
| 1456 | * would like to change. |
| 1457 | * @param flagsValues Desired values for any bits set in |
| 1458 | * <var>flagsMask</var> |
| 1459 | * @param extraFlags Always set to 0. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1460 | * @param options Additional options for how the Activity should be started. |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 1461 | * See {@link android.content.Context#startActivity(Intent, Bundle) |
| 1462 | * Context.startActivity(Intent, Bundle)} for more details. If options |
| 1463 | * have also been supplied by the IntentSender, options given here will |
| 1464 | * override any that conflict with those given by the IntentSender. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1465 | * |
| 1466 | * @see #startActivity(Intent, Bundle) |
| 1467 | * @see #startIntentSender(IntentSender, Intent, int, int, int) |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1468 | */ |
| 1469 | public abstract void startIntentSender(IntentSender intent, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1470 | @Nullable Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags, |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1471 | Bundle options) throws IntentSender.SendIntentException; |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1472 | |
| 1473 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1474 | * Broadcast the given intent to all interested BroadcastReceivers. This |
| 1475 | * call is asynchronous; it returns immediately, and you will continue |
| 1476 | * executing while the receivers are run. No results are propagated from |
| 1477 | * receivers and receivers can not abort the broadcast. If you want |
| 1478 | * to allow receivers to propagate results or abort the broadcast, you must |
| 1479 | * send an ordered broadcast using |
| 1480 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 1481 | * |
| 1482 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1483 | * |
| 1484 | * @param intent The Intent to broadcast; all receivers matching this |
| 1485 | * Intent will receive the broadcast. |
| 1486 | * |
| 1487 | * @see android.content.BroadcastReceiver |
| 1488 | * @see #registerReceiver |
| 1489 | * @see #sendBroadcast(Intent, String) |
| 1490 | * @see #sendOrderedBroadcast(Intent, String) |
| 1491 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 1492 | */ |
| 1493 | public abstract void sendBroadcast(Intent intent); |
| 1494 | |
| 1495 | /** |
| 1496 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
| 1497 | * an optional required permission to be enforced. This |
| 1498 | * call is asynchronous; it returns immediately, and you will continue |
| 1499 | * executing while the receivers are run. No results are propagated from |
| 1500 | * receivers and receivers can not abort the broadcast. If you want |
| 1501 | * to allow receivers to propagate results or abort the broadcast, you must |
| 1502 | * send an ordered broadcast using |
| 1503 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 1504 | * |
| 1505 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1506 | * |
| 1507 | * @param intent The Intent to broadcast; all receivers matching this |
| 1508 | * Intent will receive the broadcast. |
Brad Fitzpatrick | 26b71be | 2010-12-07 14:52:58 -0800 | [diff] [blame] | 1509 | * @param receiverPermission (optional) String naming a permission that |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1510 | * a receiver must hold in order to receive your broadcast. |
| 1511 | * If null, no permission is required. |
| 1512 | * |
| 1513 | * @see android.content.BroadcastReceiver |
| 1514 | * @see #registerReceiver |
| 1515 | * @see #sendBroadcast(Intent) |
| 1516 | * @see #sendOrderedBroadcast(Intent, String) |
| 1517 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 1518 | */ |
| 1519 | public abstract void sendBroadcast(Intent intent, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1520 | @Nullable String receiverPermission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1521 | |
| 1522 | /** |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 1523 | * Like {@link #sendBroadcast(Intent, String)}, but also allows specification |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1524 | * of an associated app op as per {@link android.app.AppOpsManager}. |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 1525 | * @hide |
| 1526 | */ |
| 1527 | public abstract void sendBroadcast(Intent intent, |
| 1528 | String receiverPermission, int appOp); |
| 1529 | |
| 1530 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1531 | * Broadcast the given intent to all interested BroadcastReceivers, delivering |
| 1532 | * them one at a time to allow more preferred receivers to consume the |
| 1533 | * broadcast before it is delivered to less preferred receivers. This |
| 1534 | * call is asynchronous; it returns immediately, and you will continue |
| 1535 | * executing while the receivers are run. |
| 1536 | * |
| 1537 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1538 | * |
| 1539 | * @param intent The Intent to broadcast; all receivers matching this |
| 1540 | * Intent will receive the broadcast. |
| 1541 | * @param receiverPermission (optional) String naming a permissions that |
| 1542 | * a receiver must hold in order to receive your broadcast. |
| 1543 | * If null, no permission is required. |
| 1544 | * |
| 1545 | * @see android.content.BroadcastReceiver |
| 1546 | * @see #registerReceiver |
| 1547 | * @see #sendBroadcast(Intent) |
| 1548 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 1549 | */ |
| 1550 | public abstract void sendOrderedBroadcast(Intent intent, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1551 | @Nullable String receiverPermission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1552 | |
| 1553 | /** |
| 1554 | * Version of {@link #sendBroadcast(Intent)} that allows you to |
| 1555 | * receive data back from the broadcast. This is accomplished by |
| 1556 | * supplying your own BroadcastReceiver when calling, which will be |
| 1557 | * treated as a final receiver at the end of the broadcast -- its |
| 1558 | * {@link BroadcastReceiver#onReceive} method will be called with |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 1559 | * 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] | 1560 | * be serialized in the same way as calling |
| 1561 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 1562 | * |
| 1563 | * <p>Like {@link #sendBroadcast(Intent)}, this method is |
| 1564 | * asynchronous; it will return before |
| 1565 | * resultReceiver.onReceive() is called. |
| 1566 | * |
| 1567 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1568 | * |
| 1569 | * @param intent The Intent to broadcast; all receivers matching this |
| 1570 | * Intent will receive the broadcast. |
| 1571 | * @param receiverPermission String naming a permissions that |
| 1572 | * a receiver must hold in order to receive your broadcast. |
| 1573 | * If null, no permission is required. |
| 1574 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 1575 | * receiver of the broadcast. |
| 1576 | * @param scheduler A custom Handler with which to schedule the |
| 1577 | * resultReceiver callback; if null it will be |
| 1578 | * scheduled in the Context's main thread. |
| 1579 | * @param initialCode An initial value for the result code. Often |
| 1580 | * Activity.RESULT_OK. |
| 1581 | * @param initialData An initial value for the result data. Often |
| 1582 | * null. |
| 1583 | * @param initialExtras An initial value for the result extras. Often |
| 1584 | * null. |
| 1585 | * |
| 1586 | * @see #sendBroadcast(Intent) |
| 1587 | * @see #sendBroadcast(Intent, String) |
| 1588 | * @see #sendOrderedBroadcast(Intent, String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1589 | * @see android.content.BroadcastReceiver |
| 1590 | * @see #registerReceiver |
| 1591 | * @see android.app.Activity#RESULT_OK |
| 1592 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1593 | public abstract void sendOrderedBroadcast(@NonNull Intent intent, |
| 1594 | @Nullable String receiverPermission, BroadcastReceiver resultReceiver, |
| 1595 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 1596 | @Nullable Bundle initialExtras); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1597 | |
| 1598 | /** |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 1599 | * Like {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, android.os.Handler, |
| 1600 | * int, String, android.os.Bundle)}, but also allows specification |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1601 | * of an associated app op as per {@link android.app.AppOpsManager}. |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 1602 | * @hide |
| 1603 | */ |
| 1604 | public abstract void sendOrderedBroadcast(Intent intent, |
| 1605 | String receiverPermission, int appOp, BroadcastReceiver resultReceiver, |
| 1606 | Handler scheduler, int initialCode, String initialData, |
| 1607 | Bundle initialExtras); |
| 1608 | |
| 1609 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1610 | * Version of {@link #sendBroadcast(Intent)} that allows you to specify the |
| 1611 | * user the broadcast will be sent to. This is not available to applications |
| 1612 | * that are not pre-installed on the system image. Using it requires holding |
| 1613 | * the INTERACT_ACROSS_USERS permission. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 1614 | * @param intent The intent to broadcast |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 1615 | * @param user UserHandle to send the intent to. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 1616 | * @see #sendBroadcast(Intent) |
| 1617 | */ |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 1618 | public abstract void sendBroadcastAsUser(Intent intent, UserHandle user); |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 1619 | |
| 1620 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1621 | * Version of {@link #sendBroadcast(Intent, String)} that allows you to specify the |
| 1622 | * user the broadcast will be sent to. This is not available to applications |
| 1623 | * that are not pre-installed on the system image. Using it requires holding |
| 1624 | * the INTERACT_ACROSS_USERS permission. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1625 | * |
| 1626 | * @param intent The Intent to broadcast; all receivers matching this |
| 1627 | * Intent will receive the broadcast. |
| 1628 | * @param user UserHandle to send the intent to. |
| 1629 | * @param receiverPermission (optional) String naming a permission that |
| 1630 | * a receiver must hold in order to receive your broadcast. |
| 1631 | * If null, no permission is required. |
| 1632 | * |
| 1633 | * @see #sendBroadcast(Intent, String) |
| 1634 | */ |
| 1635 | public abstract void sendBroadcastAsUser(Intent intent, UserHandle user, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1636 | @Nullable String receiverPermission); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1637 | |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 1638 | |
| 1639 | /** |
| 1640 | * Version of {@link #sendBroadcast(Intent, String)} that allows you to specify the |
| 1641 | * user the broadcast will be sent to. This is not available to applications |
| 1642 | * that are not pre-installed on the system image. Using it requires holding |
| 1643 | * the INTERACT_ACROSS_USERS permission. |
| 1644 | * |
| 1645 | * @param intent The Intent to broadcast; all receivers matching this |
| 1646 | * Intent will receive the broadcast. |
| 1647 | * @param user UserHandle to send the intent to. |
| 1648 | * @param receiverPermission (optional) String naming a permission that |
| 1649 | * a receiver must hold in order to receive your broadcast. |
| 1650 | * If null, no permission is required. |
| 1651 | * @param appOp The app op associated with the broadcast. |
| 1652 | * |
| 1653 | * @see #sendBroadcast(Intent, String) |
| 1654 | * |
| 1655 | * @hide |
| 1656 | */ |
| 1657 | public abstract void sendBroadcastAsUser(Intent intent, UserHandle user, |
| 1658 | @Nullable String receiverPermission, int appOp); |
| 1659 | |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1660 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1661 | * Version of |
| 1662 | * {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)} |
| 1663 | * that allows you to specify the |
| 1664 | * user the broadcast will be sent to. This is not available to applications |
| 1665 | * that are not pre-installed on the system image. Using it requires holding |
| 1666 | * the INTERACT_ACROSS_USERS permission. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 1667 | * |
| 1668 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1669 | * |
| 1670 | * @param intent The Intent to broadcast; all receivers matching this |
| 1671 | * Intent will receive the broadcast. |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 1672 | * @param user UserHandle to send the intent to. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1673 | * @param receiverPermission String naming a permissions that |
| 1674 | * a receiver must hold in order to receive your broadcast. |
| 1675 | * If null, no permission is required. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 1676 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 1677 | * receiver of the broadcast. |
| 1678 | * @param scheduler A custom Handler with which to schedule the |
| 1679 | * resultReceiver callback; if null it will be |
| 1680 | * scheduled in the Context's main thread. |
| 1681 | * @param initialCode An initial value for the result code. Often |
| 1682 | * Activity.RESULT_OK. |
| 1683 | * @param initialData An initial value for the result data. Often |
| 1684 | * null. |
| 1685 | * @param initialExtras An initial value for the result extras. Often |
| 1686 | * null. |
| 1687 | * |
| 1688 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 1689 | */ |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 1690 | public abstract void sendOrderedBroadcastAsUser(Intent intent, UserHandle user, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1691 | @Nullable String receiverPermission, BroadcastReceiver resultReceiver, |
| 1692 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 1693 | @Nullable Bundle initialExtras); |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 1694 | |
| 1695 | /** |
Amith Yamasani | 3cf7572 | 2014-05-16 12:37:29 -0700 | [diff] [blame] | 1696 | * Similar to above but takes an appOp as well, to enforce restrictions. |
| 1697 | * @see #sendOrderedBroadcastAsUser(Intent, UserHandle, String, |
| 1698 | * BroadcastReceiver, Handler, int, String, Bundle) |
| 1699 | * @hide |
| 1700 | */ |
| 1701 | public abstract void sendOrderedBroadcastAsUser(Intent intent, UserHandle user, |
| 1702 | @Nullable String receiverPermission, int appOp, BroadcastReceiver resultReceiver, |
| 1703 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 1704 | @Nullable Bundle initialExtras); |
| 1705 | |
| 1706 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1707 | * <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] | 1708 | * Intent you are sending stays around after the broadcast is complete, |
| 1709 | * so that others can quickly retrieve that data through the return |
| 1710 | * value of {@link #registerReceiver(BroadcastReceiver, IntentFilter)}. In |
| 1711 | * all other ways, this behaves the same as |
| 1712 | * {@link #sendBroadcast(Intent)}. |
| 1713 | * |
| 1714 | * <p>You must hold the {@link android.Manifest.permission#BROADCAST_STICKY} |
| 1715 | * permission in order to use this API. If you do not hold that |
| 1716 | * permission, {@link SecurityException} will be thrown. |
| 1717 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1718 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 1719 | * can access them), no protection (anyone can modify them), and many other problems. |
| 1720 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 1721 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 1722 | * desired. |
| 1723 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1724 | * @param intent The Intent to broadcast; all receivers matching this |
| 1725 | * Intent will receive the broadcast, and the Intent will be held to |
| 1726 | * be re-broadcast to future receivers. |
| 1727 | * |
| 1728 | * @see #sendBroadcast(Intent) |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 1729 | * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1730 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1731 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1732 | public abstract void sendStickyBroadcast(Intent intent); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1733 | |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 1734 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1735 | * <p>Version of {@link #sendStickyBroadcast} that allows you to |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 1736 | * receive data back from the broadcast. This is accomplished by |
| 1737 | * supplying your own BroadcastReceiver when calling, which will be |
| 1738 | * treated as a final receiver at the end of the broadcast -- its |
| 1739 | * {@link BroadcastReceiver#onReceive} method will be called with |
| 1740 | * the result values collected from the other receivers. The broadcast will |
| 1741 | * be serialized in the same way as calling |
| 1742 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 1743 | * |
| 1744 | * <p>Like {@link #sendBroadcast(Intent)}, this method is |
| 1745 | * asynchronous; it will return before |
| 1746 | * resultReceiver.onReceive() is called. Note that the sticky data |
| 1747 | * stored is only the data you initially supply to the broadcast, not |
| 1748 | * the result of any changes made by the receivers. |
| 1749 | * |
| 1750 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1751 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1752 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 1753 | * can access them), no protection (anyone can modify them), and many other problems. |
| 1754 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 1755 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 1756 | * desired. |
| 1757 | * |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 1758 | * @param intent The Intent to broadcast; all receivers matching this |
| 1759 | * Intent will receive the broadcast. |
| 1760 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 1761 | * receiver of the broadcast. |
| 1762 | * @param scheduler A custom Handler with which to schedule the |
| 1763 | * resultReceiver callback; if null it will be |
| 1764 | * scheduled in the Context's main thread. |
| 1765 | * @param initialCode An initial value for the result code. Often |
| 1766 | * Activity.RESULT_OK. |
| 1767 | * @param initialData An initial value for the result data. Often |
| 1768 | * null. |
| 1769 | * @param initialExtras An initial value for the result extras. Often |
| 1770 | * null. |
| 1771 | * |
| 1772 | * @see #sendBroadcast(Intent) |
| 1773 | * @see #sendBroadcast(Intent, String) |
| 1774 | * @see #sendOrderedBroadcast(Intent, String) |
| 1775 | * @see #sendStickyBroadcast(Intent) |
| 1776 | * @see android.content.BroadcastReceiver |
| 1777 | * @see #registerReceiver |
| 1778 | * @see android.app.Activity#RESULT_OK |
| 1779 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1780 | @Deprecated |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 1781 | public abstract void sendStickyOrderedBroadcast(Intent intent, |
| 1782 | BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1783 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 1784 | @Nullable Bundle initialExtras); |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 1785 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1786 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1787 | * <p>Remove the data previously sent with {@link #sendStickyBroadcast}, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1788 | * so that it is as if the sticky broadcast had never happened. |
| 1789 | * |
| 1790 | * <p>You must hold the {@link android.Manifest.permission#BROADCAST_STICKY} |
| 1791 | * permission in order to use this API. If you do not hold that |
| 1792 | * permission, {@link SecurityException} will be thrown. |
| 1793 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1794 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 1795 | * can access them), no protection (anyone can modify them), and many other problems. |
| 1796 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 1797 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 1798 | * desired. |
| 1799 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1800 | * @param intent The Intent that was previously broadcast. |
| 1801 | * |
| 1802 | * @see #sendStickyBroadcast |
| 1803 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1804 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1805 | public abstract void removeStickyBroadcast(Intent intent); |
| 1806 | |
| 1807 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1808 | * <p>Version of {@link #sendStickyBroadcast(Intent)} that allows you to specify the |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1809 | * user the broadcast will be sent to. This is not available to applications |
| 1810 | * that are not pre-installed on the system image. Using it requires holding |
| 1811 | * the INTERACT_ACROSS_USERS permission. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1812 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1813 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 1814 | * can access them), no protection (anyone can modify them), and many other problems. |
| 1815 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 1816 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 1817 | * desired. |
| 1818 | * |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1819 | * @param intent The Intent to broadcast; all receivers matching this |
| 1820 | * Intent will receive the broadcast, and the Intent will be held to |
| 1821 | * be re-broadcast to future receivers. |
| 1822 | * @param user UserHandle to send the intent to. |
| 1823 | * |
| 1824 | * @see #sendBroadcast(Intent) |
| 1825 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1826 | @Deprecated |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1827 | public abstract void sendStickyBroadcastAsUser(Intent intent, UserHandle user); |
| 1828 | |
| 1829 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1830 | * <p>Version of |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1831 | * {@link #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)} |
| 1832 | * that allows you to specify the |
| 1833 | * user the broadcast will be sent to. This is not available to applications |
| 1834 | * that are not pre-installed on the system image. Using it requires holding |
| 1835 | * the INTERACT_ACROSS_USERS permission. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1836 | * |
| 1837 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1838 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1839 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 1840 | * can access them), no protection (anyone can modify them), and many other problems. |
| 1841 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 1842 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 1843 | * desired. |
| 1844 | * |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1845 | * @param intent The Intent to broadcast; all receivers matching this |
| 1846 | * Intent will receive the broadcast. |
| 1847 | * @param user UserHandle to send the intent to. |
| 1848 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 1849 | * receiver of the broadcast. |
| 1850 | * @param scheduler A custom Handler with which to schedule the |
| 1851 | * resultReceiver callback; if null it will be |
| 1852 | * scheduled in the Context's main thread. |
| 1853 | * @param initialCode An initial value for the result code. Often |
| 1854 | * Activity.RESULT_OK. |
| 1855 | * @param initialData An initial value for the result data. Often |
| 1856 | * null. |
| 1857 | * @param initialExtras An initial value for the result extras. Often |
| 1858 | * null. |
| 1859 | * |
| 1860 | * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle) |
| 1861 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1862 | @Deprecated |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1863 | public abstract void sendStickyOrderedBroadcastAsUser(Intent intent, |
| 1864 | UserHandle user, BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1865 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 1866 | @Nullable Bundle initialExtras); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1867 | |
| 1868 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1869 | * <p>Version of {@link #removeStickyBroadcast(Intent)} that allows you to specify the |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1870 | * user the broadcast will be sent to. This is not available to applications |
| 1871 | * that are not pre-installed on the system image. Using it requires holding |
| 1872 | * the INTERACT_ACROSS_USERS permission. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1873 | * |
| 1874 | * <p>You must hold the {@link android.Manifest.permission#BROADCAST_STICKY} |
| 1875 | * permission in order to use this API. If you do not hold that |
| 1876 | * permission, {@link SecurityException} will be thrown. |
| 1877 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1878 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 1879 | * can access them), no protection (anyone can modify them), and many other problems. |
| 1880 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 1881 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 1882 | * desired. |
| 1883 | * |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1884 | * @param intent The Intent that was previously broadcast. |
| 1885 | * @param user UserHandle to remove the sticky broadcast from. |
| 1886 | * |
| 1887 | * @see #sendStickyBroadcastAsUser |
| 1888 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 1889 | @Deprecated |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1890 | public abstract void removeStickyBroadcastAsUser(Intent intent, UserHandle user); |
| 1891 | |
| 1892 | /** |
Chris Tate | a34df8a2 | 2009-04-02 23:15:58 -0700 | [diff] [blame] | 1893 | * 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] | 1894 | * <var>receiver</var> will be called with any broadcast Intent that |
| 1895 | * matches <var>filter</var>, in the main application thread. |
| 1896 | * |
| 1897 | * <p>The system may broadcast Intents that are "sticky" -- these stay |
| 1898 | * around after the broadcast as finished, to be sent to any later |
| 1899 | * registrations. If your IntentFilter matches one of these sticky |
| 1900 | * Intents, that Intent will be returned by this function |
| 1901 | * <strong>and</strong> sent to your <var>receiver</var> as if it had just |
| 1902 | * been broadcast. |
| 1903 | * |
| 1904 | * <p>There may be multiple sticky Intents that match <var>filter</var>, |
| 1905 | * in which case each of these will be sent to <var>receiver</var>. In |
| 1906 | * this case, only one of these can be returned directly by the function; |
| 1907 | * which of these that is returned is arbitrarily decided by the system. |
| 1908 | * |
| 1909 | * <p>If you know the Intent your are registering for is sticky, you can |
| 1910 | * supply null for your <var>receiver</var>. In this case, no receiver is |
| 1911 | * registered -- the function simply returns the sticky Intent that |
| 1912 | * matches <var>filter</var>. In the case of multiple matches, the same |
| 1913 | * rules as described above apply. |
| 1914 | * |
| 1915 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1916 | * |
Dianne Hackborn | 6c418d5 | 2011-06-29 14:05:33 -0700 | [diff] [blame] | 1917 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 1918 | * registered with this method will correctly respect the |
| 1919 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 1920 | * Prior to that, it would be ignored and delivered to all matching registered |
| 1921 | * receivers. Be careful if using this for security.</p> |
| 1922 | * |
Chris Tate | a34df8a2 | 2009-04-02 23:15:58 -0700 | [diff] [blame] | 1923 | * <p class="note">Note: this method <em>cannot be called from a |
| 1924 | * {@link BroadcastReceiver} component;</em> that is, from a BroadcastReceiver |
| 1925 | * that is declared in an application's manifest. It is okay, however, to call |
| 1926 | * this method from another BroadcastReceiver that has itself been registered |
| 1927 | * at run time with {@link #registerReceiver}, since the lifetime of such a |
| 1928 | * 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] | 1929 | * |
| 1930 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 1931 | * @param filter Selects the Intent broadcasts to be received. |
| 1932 | * |
| 1933 | * @return The first sticky intent found that matches <var>filter</var>, |
| 1934 | * or null if there are none. |
| 1935 | * |
| 1936 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
| 1937 | * @see #sendBroadcast |
| 1938 | * @see #unregisterReceiver |
| 1939 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1940 | @Nullable |
| 1941 | public abstract Intent registerReceiver(@Nullable BroadcastReceiver receiver, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1942 | IntentFilter filter); |
| 1943 | |
| 1944 | /** |
| 1945 | * Register to receive intent broadcasts, to run in the context of |
| 1946 | * <var>scheduler</var>. See |
| 1947 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter)} for more |
| 1948 | * information. This allows you to enforce permissions on who can |
| 1949 | * broadcast intents to your receiver, or have the receiver run in |
| 1950 | * a different thread than the main application thread. |
| 1951 | * |
| 1952 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1953 | * |
Dianne Hackborn | 6c418d5 | 2011-06-29 14:05:33 -0700 | [diff] [blame] | 1954 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 1955 | * registered with this method will correctly respect the |
| 1956 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 1957 | * Prior to that, it would be ignored and delivered to all matching registered |
| 1958 | * receivers. Be careful if using this for security.</p> |
| 1959 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1960 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 1961 | * @param filter Selects the Intent broadcasts to be received. |
| 1962 | * @param broadcastPermission String naming a permissions that a |
| 1963 | * broadcaster must hold in order to send an Intent to you. If null, |
| 1964 | * no permission is required. |
| 1965 | * @param scheduler Handler identifying the thread that will receive |
| 1966 | * the Intent. If null, the main thread of the process will be used. |
| 1967 | * |
| 1968 | * @return The first sticky intent found that matches <var>filter</var>, |
| 1969 | * or null if there are none. |
| 1970 | * |
| 1971 | * @see #registerReceiver(BroadcastReceiver, IntentFilter) |
| 1972 | * @see #sendBroadcast |
| 1973 | * @see #unregisterReceiver |
| 1974 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1975 | @Nullable |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1976 | public abstract Intent registerReceiver(BroadcastReceiver receiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1977 | IntentFilter filter, @Nullable String broadcastPermission, |
| 1978 | @Nullable Handler scheduler); |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 1979 | |
| 1980 | /** |
| 1981 | * @hide |
| 1982 | * Same as {@link #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
| 1983 | * but for a specific user. This receiver will receiver broadcasts that |
| 1984 | * are sent to the requested user. It |
| 1985 | * requires holding the {@link android.Manifest.permission#INTERACT_ACROSS_USERS_FULL} |
| 1986 | * permission. |
| 1987 | * |
| 1988 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 1989 | * @param user UserHandle to send the intent to. |
| 1990 | * @param filter Selects the Intent broadcasts to be received. |
| 1991 | * @param broadcastPermission String naming a permissions that a |
| 1992 | * broadcaster must hold in order to send an Intent to you. If null, |
| 1993 | * no permission is required. |
| 1994 | * @param scheduler Handler identifying the thread that will receive |
| 1995 | * the Intent. If null, the main thread of the process will be used. |
| 1996 | * |
| 1997 | * @return The first sticky intent found that matches <var>filter</var>, |
| 1998 | * or null if there are none. |
| 1999 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 2000 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2001 | * @see #sendBroadcast |
| 2002 | * @see #unregisterReceiver |
| 2003 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2004 | @Nullable |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2005 | public abstract Intent registerReceiverAsUser(BroadcastReceiver receiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2006 | UserHandle user, IntentFilter filter, @Nullable String broadcastPermission, |
| 2007 | @Nullable Handler scheduler); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2008 | |
| 2009 | /** |
| 2010 | * Unregister a previously registered BroadcastReceiver. <em>All</em> |
| 2011 | * filters that have been registered for this BroadcastReceiver will be |
| 2012 | * removed. |
| 2013 | * |
| 2014 | * @param receiver The BroadcastReceiver to unregister. |
| 2015 | * |
| 2016 | * @see #registerReceiver |
| 2017 | */ |
| 2018 | public abstract void unregisterReceiver(BroadcastReceiver receiver); |
| 2019 | |
| 2020 | /** |
| 2021 | * Request that a given application service be started. The Intent |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 2022 | * should contain either contain the complete class name of a specific service |
| 2023 | * implementation to start or a specific package name to target. If the |
Dianne Hackborn | 6bc3789 | 2013-10-03 11:05:14 -0700 | [diff] [blame] | 2024 | * Intent is less specified, it log a warning about this and which of the |
| 2025 | * multiple matching services it finds and uses will be undefined. If this service |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2026 | * is not already running, it will be instantiated and started (creating a |
| 2027 | * process for it if needed); if it is running then it remains running. |
| 2028 | * |
| 2029 | * <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] | 2030 | * 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] | 2031 | * with the <var>intent</var> given here. This provides a convenient way |
| 2032 | * to submit jobs to a service without having to bind and call on to its |
| 2033 | * interface. |
| 2034 | * |
| 2035 | * <p>Using startService() overrides the default service lifetime that is |
| 2036 | * managed by {@link #bindService}: it requires the service to remain |
| 2037 | * running until {@link #stopService} is called, regardless of whether |
| 2038 | * any clients are connected to it. Note that calls to startService() |
| 2039 | * are not nesting: no matter how many times you call startService(), |
| 2040 | * a single call to {@link #stopService} will stop it. |
| 2041 | * |
| 2042 | * <p>The system attempts to keep running services around as much as |
| 2043 | * possible. The only time they should be stopped is if the current |
| 2044 | * foreground application is using so many resources that the service needs |
| 2045 | * to be killed. If any errors happen in the service's process, it will |
| 2046 | * automatically be restarted. |
| 2047 | * |
| 2048 | * <p>This function will throw {@link SecurityException} if you do not |
| 2049 | * have permission to start the given service. |
| 2050 | * |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 2051 | * @param service Identifies the service to be started. The Intent must be either |
| 2052 | * fully explicit (supplying a component name) or specify a specific package |
| 2053 | * name it is targetted to. Additional values |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2054 | * may be included in the Intent extras to supply arguments along with |
| 2055 | * this specific start call. |
| 2056 | * |
| 2057 | * @return If the service is being started or is already running, the |
| 2058 | * {@link ComponentName} of the actual service that was started is |
| 2059 | * returned; else if the service does not exist null is returned. |
| 2060 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 2061 | * @throws SecurityException |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2062 | * |
| 2063 | * @see #stopService |
| 2064 | * @see #bindService |
| 2065 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2066 | @Nullable |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2067 | public abstract ComponentName startService(Intent service); |
| 2068 | |
| 2069 | /** |
| 2070 | * Request that a given application service be stopped. If the service is |
| 2071 | * not running, nothing happens. Otherwise it is stopped. Note that calls |
| 2072 | * to startService() are not counted -- this stops the service no matter |
| 2073 | * how many times it was started. |
| 2074 | * |
| 2075 | * <p>Note that if a stopped service still has {@link ServiceConnection} |
| 2076 | * objects bound to it with the {@link #BIND_AUTO_CREATE} set, it will |
| 2077 | * not be destroyed until all of these bindings are removed. See |
| 2078 | * the {@link android.app.Service} documentation for more details on a |
| 2079 | * service's lifecycle. |
| 2080 | * |
| 2081 | * <p>This function will throw {@link SecurityException} if you do not |
| 2082 | * have permission to stop the given service. |
| 2083 | * |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 2084 | * @param service Description of the service to be stopped. The Intent must be either |
| 2085 | * fully explicit (supplying a component name) or specify a specific package |
| 2086 | * name it is targetted to. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2087 | * |
| 2088 | * @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] | 2089 | * 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] | 2090 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 2091 | * @throws SecurityException |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2092 | * |
| 2093 | * @see #startService |
| 2094 | */ |
| 2095 | public abstract boolean stopService(Intent service); |
| 2096 | |
| 2097 | /** |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 2098 | * @hide like {@link #startService(Intent)} but for a specific user. |
| 2099 | */ |
| 2100 | public abstract ComponentName startServiceAsUser(Intent service, UserHandle user); |
| 2101 | |
| 2102 | /** |
| 2103 | * @hide like {@link #stopService(Intent)} but for a specific user. |
| 2104 | */ |
| 2105 | public abstract boolean stopServiceAsUser(Intent service, UserHandle user); |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 2106 | |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 2107 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2108 | * Connect to an application service, creating it if needed. This defines |
| 2109 | * a dependency between your application and the service. The given |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 2110 | * <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] | 2111 | * told if it dies and restarts. The service will be considered required |
| 2112 | * by the system only for as long as the calling context exists. For |
| 2113 | * example, if this Context is an Activity that is stopped, the service will |
| 2114 | * not be required to continue running until the Activity is resumed. |
| 2115 | * |
| 2116 | * <p>This function will throw {@link SecurityException} if you do not |
| 2117 | * have permission to bind to the given service. |
| 2118 | * |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 2119 | * <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] | 2120 | * {@link BroadcastReceiver} component</em>. A pattern you can use to |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 2121 | * 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] | 2122 | * {@link #startService} with the arguments containing the command to be |
| 2123 | * sent, with the service calling its |
| 2124 | * {@link android.app.Service#stopSelf(int)} method when done executing |
| 2125 | * that command. See the API demo App/Service/Service Start Arguments |
| 2126 | * Controller for an illustration of this. It is okay, however, to use |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 2127 | * 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] | 2128 | * {@link #registerReceiver}, since the lifetime of this BroadcastReceiver |
| 2129 | * is tied to another object (the one that registered it).</p> |
| 2130 | * |
| 2131 | * @param service Identifies the service to connect to. The Intent may |
| 2132 | * specify either an explicit component name, or a logical |
| 2133 | * description (action, category, etc) to match an |
| 2134 | * {@link IntentFilter} published by a service. |
| 2135 | * @param conn Receives information as the service is started and stopped. |
Christopher Tate | 79b3317 | 2012-06-18 14:54:21 -0700 | [diff] [blame] | 2136 | * This must be a valid ServiceConnection object; it must not be null. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2137 | * @param flags Operation options for the binding. May be 0, |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 2138 | * {@link #BIND_AUTO_CREATE}, {@link #BIND_DEBUG_UNBIND}, |
| 2139 | * {@link #BIND_NOT_FOREGROUND}, {@link #BIND_ABOVE_CLIENT}, |
| 2140 | * {@link #BIND_ALLOW_OOM_MANAGEMENT}, or |
| 2141 | * {@link #BIND_WAIVE_PRIORITY}. |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 2142 | * @return If you have successfully bound to the service, {@code true} is returned; |
| 2143 | * {@code false} is returned if the connection is not made so you will not |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2144 | * receive the service object. |
| 2145 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 2146 | * @throws SecurityException |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2147 | * |
| 2148 | * @see #unbindService |
| 2149 | * @see #startService |
| 2150 | * @see #BIND_AUTO_CREATE |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2151 | * @see #BIND_DEBUG_UNBIND |
| 2152 | * @see #BIND_NOT_FOREGROUND |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2153 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2154 | public abstract boolean bindService(Intent service, @NonNull ServiceConnection conn, |
| 2155 | @BindServiceFlags int flags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2156 | |
| 2157 | /** |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2158 | * Same as {@link #bindService(Intent, ServiceConnection, int)}, but with an explicit userHandle |
Amith Yamasani | 37ce3a8 | 2012-02-06 12:04:42 -0800 | [diff] [blame] | 2159 | * argument for use by system server and other multi-user aware code. |
| 2160 | * @hide |
| 2161 | */ |
Amith Yamasani | c85029f | 2014-09-11 16:47:17 -0700 | [diff] [blame] | 2162 | @SystemApi |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 2163 | @SuppressWarnings("unused") |
| 2164 | public boolean bindServiceAsUser(Intent service, ServiceConnection conn, |
| 2165 | int flags, UserHandle user) { |
Amith Yamasani | 37ce3a8 | 2012-02-06 12:04:42 -0800 | [diff] [blame] | 2166 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 2167 | } |
| 2168 | |
| 2169 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2170 | * Disconnect from an application service. You will no longer receive |
| 2171 | * calls as the service is restarted, and the service is now allowed to |
| 2172 | * stop at any time. |
| 2173 | * |
| 2174 | * @param conn The connection interface previously supplied to |
Christopher Tate | 79b3317 | 2012-06-18 14:54:21 -0700 | [diff] [blame] | 2175 | * bindService(). This parameter must not be null. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2176 | * |
| 2177 | * @see #bindService |
| 2178 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2179 | public abstract void unbindService(@NonNull ServiceConnection conn); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2180 | |
| 2181 | /** |
| 2182 | * Start executing an {@link android.app.Instrumentation} class. The given |
| 2183 | * Instrumentation component will be run by killing its target application |
| 2184 | * (if currently running), starting the target process, instantiating the |
| 2185 | * instrumentation component, and then letting it drive the application. |
| 2186 | * |
| 2187 | * <p>This function is not synchronous -- it returns as soon as the |
| 2188 | * instrumentation has started and while it is running. |
| 2189 | * |
| 2190 | * <p>Instrumentation is normally only allowed to run against a package |
| 2191 | * that is either unsigned or signed with a signature that the |
| 2192 | * the instrumentation package is also signed with (ensuring the target |
| 2193 | * trusts the instrumentation). |
| 2194 | * |
| 2195 | * @param className Name of the Instrumentation component to be run. |
| 2196 | * @param profileFile Optional path to write profiling data as the |
| 2197 | * instrumentation runs, or null for no profiling. |
| 2198 | * @param arguments Additional optional arguments to pass to the |
| 2199 | * instrumentation, or null. |
| 2200 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 2201 | * @return {@code true} if the instrumentation was successfully started, |
| 2202 | * else {@code false} if it could not be found. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2203 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2204 | public abstract boolean startInstrumentation(@NonNull ComponentName className, |
| 2205 | @Nullable String profileFile, @Nullable Bundle arguments); |
| 2206 | |
| 2207 | /** @hide */ |
| 2208 | @StringDef({ |
| 2209 | POWER_SERVICE, |
| 2210 | WINDOW_SERVICE, |
| 2211 | LAYOUT_INFLATER_SERVICE, |
| 2212 | ACCOUNT_SERVICE, |
| 2213 | ACTIVITY_SERVICE, |
| 2214 | ALARM_SERVICE, |
| 2215 | NOTIFICATION_SERVICE, |
| 2216 | ACCESSIBILITY_SERVICE, |
| 2217 | CAPTIONING_SERVICE, |
| 2218 | KEYGUARD_SERVICE, |
| 2219 | LOCATION_SERVICE, |
| 2220 | //@hide: COUNTRY_DETECTOR, |
| 2221 | SEARCH_SERVICE, |
| 2222 | SENSOR_SERVICE, |
| 2223 | STORAGE_SERVICE, |
| 2224 | WALLPAPER_SERVICE, |
| 2225 | VIBRATOR_SERVICE, |
| 2226 | //@hide: STATUS_BAR_SERVICE, |
| 2227 | CONNECTIVITY_SERVICE, |
| 2228 | //@hide: UPDATE_LOCK_SERVICE, |
| 2229 | //@hide: NETWORKMANAGEMENT_SERVICE, |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 2230 | NETWORK_STATS_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2231 | //@hide: NETWORK_POLICY_SERVICE, |
| 2232 | WIFI_SERVICE, |
Yuhao Zheng | a486447 | 2014-04-10 11:45:42 -0700 | [diff] [blame] | 2233 | WIFI_PASSPOINT_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2234 | WIFI_P2P_SERVICE, |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 2235 | WIFI_SCANNING_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 2236 | //@hide: WIFI_RTT_SERVICE, |
Lorenzo Colitti | bd8a374 | 2014-05-22 11:51:27 -0700 | [diff] [blame] | 2237 | //@hide: ETHERNET_SERVICE, |
Vinit Deshpande | 7686c06 | 2014-06-30 15:25:01 -0700 | [diff] [blame] | 2238 | WIFI_RTT_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2239 | NSD_SERVICE, |
| 2240 | AUDIO_SERVICE, |
Jim Miller | ce7eb6d | 2015-04-03 19:29:13 -0700 | [diff] [blame] | 2241 | FINGERPRINT_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2242 | MEDIA_ROUTER_SERVICE, |
| 2243 | TELEPHONY_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 2244 | TELEPHONY_SUBSCRIPTION_SERVICE, |
Jonathan Basseri | 9a1c9b6 | 2015-02-25 13:01:52 -0800 | [diff] [blame] | 2245 | CARRIER_CONFIG_SERVICE, |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2246 | TELECOM_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2247 | CLIPBOARD_SERVICE, |
| 2248 | INPUT_METHOD_SERVICE, |
| 2249 | TEXT_SERVICES_MANAGER_SERVICE, |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 2250 | APPWIDGET_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 2251 | //@hide: VOICE_INTERACTION_MANAGER_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2252 | //@hide: BACKUP_SERVICE, |
| 2253 | DROPBOX_SERVICE, |
| 2254 | DEVICE_POLICY_SERVICE, |
| 2255 | UI_MODE_SERVICE, |
| 2256 | DOWNLOAD_SERVICE, |
| 2257 | NFC_SERVICE, |
| 2258 | BLUETOOTH_SERVICE, |
| 2259 | //@hide: SIP_SERVICE, |
| 2260 | USB_SERVICE, |
Amith Yamasani | 4f58263 | 2014-02-19 14:31:52 -0800 | [diff] [blame] | 2261 | LAUNCHER_APPS_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2262 | //@hide: SERIAL_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 2263 | //@hide: HDMI_CONTROL_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2264 | INPUT_SERVICE, |
| 2265 | DISPLAY_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2266 | USER_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 2267 | RESTRICTIONS_SERVICE, |
| 2268 | APP_OPS_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2269 | CAMERA_SERVICE, |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 2270 | PRINT_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 2271 | CONSUMER_IR_SERVICE, |
| 2272 | //@hide: TRUST_SERVICE, |
| 2273 | TV_INPUT_SERVICE, |
| 2274 | //@hide: NETWORK_SCORE_SERVICE, |
| 2275 | USAGE_STATS_SERVICE, |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 2276 | MEDIA_SESSION_SERVICE, |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 2277 | BATTERY_SERVICE, |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 2278 | JOB_SCHEDULER_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 2279 | //@hide: PERSISTENT_DATA_BLOCK_SERVICE, |
Michael Wright | 446e019 | 2014-12-22 09:38:43 -0800 | [diff] [blame] | 2280 | MEDIA_PROJECTION_SERVICE, |
Mike Lockwood | 67f8e8b | 2014-12-01 13:54:59 -0800 | [diff] [blame] | 2281 | MIDI_SERVICE, |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 2282 | RADIO_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2283 | }) |
| 2284 | @Retention(RetentionPolicy.SOURCE) |
| 2285 | public @interface ServiceName {} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2286 | |
| 2287 | /** |
| 2288 | * Return the handle to a system-level service by name. The class of the |
| 2289 | * returned object varies by the requested name. Currently available names |
| 2290 | * are: |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2291 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2292 | * <dl> |
| 2293 | * <dt> {@link #WINDOW_SERVICE} ("window") |
| 2294 | * <dd> The top-level window manager in which you can place custom |
| 2295 | * windows. The returned object is a {@link android.view.WindowManager}. |
| 2296 | * <dt> {@link #LAYOUT_INFLATER_SERVICE} ("layout_inflater") |
| 2297 | * <dd> A {@link android.view.LayoutInflater} for inflating layout resources |
| 2298 | * in this context. |
| 2299 | * <dt> {@link #ACTIVITY_SERVICE} ("activity") |
| 2300 | * <dd> A {@link android.app.ActivityManager} for interacting with the |
| 2301 | * global activity state of the system. |
| 2302 | * <dt> {@link #POWER_SERVICE} ("power") |
| 2303 | * <dd> A {@link android.os.PowerManager} for controlling power |
| 2304 | * management. |
| 2305 | * <dt> {@link #ALARM_SERVICE} ("alarm") |
| 2306 | * <dd> A {@link android.app.AlarmManager} for receiving intents at the |
| 2307 | * time of your choosing. |
| 2308 | * <dt> {@link #NOTIFICATION_SERVICE} ("notification") |
| 2309 | * <dd> A {@link android.app.NotificationManager} for informing the user |
| 2310 | * of background events. |
| 2311 | * <dt> {@link #KEYGUARD_SERVICE} ("keyguard") |
| 2312 | * <dd> A {@link android.app.KeyguardManager} for controlling keyguard. |
| 2313 | * <dt> {@link #LOCATION_SERVICE} ("location") |
| 2314 | * <dd> A {@link android.location.LocationManager} for controlling location |
| 2315 | * (e.g., GPS) updates. |
| 2316 | * <dt> {@link #SEARCH_SERVICE} ("search") |
| 2317 | * <dd> A {@link android.app.SearchManager} for handling search. |
| 2318 | * <dt> {@link #VIBRATOR_SERVICE} ("vibrator") |
| 2319 | * <dd> A {@link android.os.Vibrator} for interacting with the vibrator |
| 2320 | * hardware. |
| 2321 | * <dt> {@link #CONNECTIVITY_SERVICE} ("connection") |
| 2322 | * <dd> A {@link android.net.ConnectivityManager ConnectivityManager} for |
| 2323 | * handling management of network connections. |
| 2324 | * <dt> {@link #WIFI_SERVICE} ("wifi") |
| 2325 | * <dd> A {@link android.net.wifi.WifiManager WifiManager} for management of |
| 2326 | * Wi-Fi connectivity. |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 2327 | * <dt> {@link #WIFI_P2P_SERVICE} ("wifip2p") |
| 2328 | * <dd> A {@link android.net.wifi.p2p.WifiP2pManager WifiP2pManager} for management of |
| 2329 | * Wi-Fi Direct connectivity. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2330 | * <dt> {@link #INPUT_METHOD_SERVICE} ("input_method") |
| 2331 | * <dd> An {@link android.view.inputmethod.InputMethodManager InputMethodManager} |
| 2332 | * for management of input methods. |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 2333 | * <dt> {@link #UI_MODE_SERVICE} ("uimode") |
| 2334 | * <dd> An {@link android.app.UiModeManager} for controlling UI modes. |
Steve Howard | 7083c42 | 2010-07-28 16:01:23 -0700 | [diff] [blame] | 2335 | * <dt> {@link #DOWNLOAD_SERVICE} ("download") |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 2336 | * <dd> A {@link android.app.DownloadManager} for requesting HTTP downloads |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 2337 | * <dt> {@link #BATTERY_SERVICE} ("batterymanager") |
Todd Poynor | 99f7e12 | 2014-04-15 16:03:42 -0700 | [diff] [blame] | 2338 | * <dd> A {@link android.os.BatteryManager} for managing battery state |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 2339 | * <dt> {@link #JOB_SCHEDULER_SERVICE} ("taskmanager") |
| 2340 | * <dd> A {@link android.app.job.JobScheduler} for managing scheduled tasks |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 2341 | * <dt> {@link #NETWORK_STATS_SERVICE} ("netstats") |
| 2342 | * <dd> A {@link android.app.usage.NetworkStatsManager NetworkStatsManager} for querying network |
| 2343 | * usage statistics. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2344 | * </dl> |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2345 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2346 | * <p>Note: System services obtained via this API may be closely associated with |
| 2347 | * the Context in which they are obtained from. In general, do not share the |
| 2348 | * service objects between various different contexts (Activities, Applications, |
| 2349 | * Services, Providers, etc.) |
| 2350 | * |
| 2351 | * @param name The name of the desired service. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2352 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2353 | * @return The service or null if the name does not exist. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2354 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2355 | * @see #WINDOW_SERVICE |
| 2356 | * @see android.view.WindowManager |
| 2357 | * @see #LAYOUT_INFLATER_SERVICE |
| 2358 | * @see android.view.LayoutInflater |
| 2359 | * @see #ACTIVITY_SERVICE |
| 2360 | * @see android.app.ActivityManager |
| 2361 | * @see #POWER_SERVICE |
| 2362 | * @see android.os.PowerManager |
| 2363 | * @see #ALARM_SERVICE |
| 2364 | * @see android.app.AlarmManager |
| 2365 | * @see #NOTIFICATION_SERVICE |
| 2366 | * @see android.app.NotificationManager |
| 2367 | * @see #KEYGUARD_SERVICE |
| 2368 | * @see android.app.KeyguardManager |
| 2369 | * @see #LOCATION_SERVICE |
| 2370 | * @see android.location.LocationManager |
| 2371 | * @see #SEARCH_SERVICE |
| 2372 | * @see android.app.SearchManager |
| 2373 | * @see #SENSOR_SERVICE |
| 2374 | * @see android.hardware.SensorManager |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 2375 | * @see #STORAGE_SERVICE |
San Mehat | b104340 | 2010-02-05 08:26:50 -0800 | [diff] [blame] | 2376 | * @see android.os.storage.StorageManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2377 | * @see #VIBRATOR_SERVICE |
| 2378 | * @see android.os.Vibrator |
| 2379 | * @see #CONNECTIVITY_SERVICE |
| 2380 | * @see android.net.ConnectivityManager |
| 2381 | * @see #WIFI_SERVICE |
| 2382 | * @see android.net.wifi.WifiManager |
| 2383 | * @see #AUDIO_SERVICE |
| 2384 | * @see android.media.AudioManager |
Dianne Hackborn | b58b8f8 | 2012-06-11 15:08:39 -0700 | [diff] [blame] | 2385 | * @see #MEDIA_ROUTER_SERVICE |
| 2386 | * @see android.media.MediaRouter |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2387 | * @see #TELEPHONY_SERVICE |
| 2388 | * @see android.telephony.TelephonyManager |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 2389 | * @see #TELEPHONY_SUBSCRIPTION_SERVICE |
| 2390 | * @see android.telephony.SubscriptionManager |
Jonathan Basseri | 9a1c9b6 | 2015-02-25 13:01:52 -0800 | [diff] [blame] | 2391 | * @see #CARRIER_CONFIG_SERVICE |
| 2392 | * @see android.telephony.CarrierConfigManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2393 | * @see #INPUT_METHOD_SERVICE |
| 2394 | * @see android.view.inputmethod.InputMethodManager |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 2395 | * @see #UI_MODE_SERVICE |
| 2396 | * @see android.app.UiModeManager |
Steve Howard | 7083c42 | 2010-07-28 16:01:23 -0700 | [diff] [blame] | 2397 | * @see #DOWNLOAD_SERVICE |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 2398 | * @see android.app.DownloadManager |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 2399 | * @see #BATTERY_SERVICE |
| 2400 | * @see android.os.BatteryManager |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 2401 | * @see #JOB_SCHEDULER_SERVICE |
| 2402 | * @see android.app.job.JobScheduler |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 2403 | * @see #NETWORK_STATS_SERVICE |
| 2404 | * @see android.app.usage.NetworkStatsManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2405 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2406 | public abstract Object getSystemService(@ServiceName @NonNull String name); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2407 | |
| 2408 | /** |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 2409 | * Return the handle to a system-level service by class. |
| 2410 | * <p> |
| 2411 | * Currently available classes are: |
| 2412 | * {@link android.view.WindowManager}, {@link android.view.LayoutInflater}, |
| 2413 | * {@link android.app.ActivityManager}, {@link android.os.PowerManager}, |
| 2414 | * {@link android.app.AlarmManager}, {@link android.app.NotificationManager}, |
| 2415 | * {@link android.app.KeyguardManager}, {@link android.location.LocationManager}, |
| 2416 | * {@link android.app.SearchManager}, {@link android.os.Vibrator}, |
| 2417 | * {@link android.net.ConnectivityManager}, |
| 2418 | * {@link android.net.wifi.WifiManager}, |
| 2419 | * {@link android.media.AudioManager}, {@link android.media.MediaRouter}, |
| 2420 | * {@link android.telephony.TelephonyManager}, {@link android.telephony.SubscriptionManager}, |
| 2421 | * {@link android.view.inputmethod.InputMethodManager}, |
| 2422 | * {@link android.app.UiModeManager}, {@link android.app.DownloadManager}, |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 2423 | * {@link android.os.BatteryManager}, {@link android.app.job.JobScheduler}, |
| 2424 | * {@link android.app.usage.NetworkStatsManager}. |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 2425 | * </p><p> |
| 2426 | * Note: System services obtained via this API may be closely associated with |
| 2427 | * the Context in which they are obtained from. In general, do not share the |
| 2428 | * service objects between various different contexts (Activities, Applications, |
| 2429 | * Services, Providers, etc.) |
| 2430 | * </p> |
| 2431 | * |
| 2432 | * @param serviceClass The class of the desired service. |
| 2433 | * @return The service or null if the class is not a supported system service. |
| 2434 | */ |
| 2435 | @SuppressWarnings("unchecked") |
| 2436 | public final <T> T getSystemService(Class<T> serviceClass) { |
| 2437 | // Because subclasses may override getSystemService(String) we cannot |
| 2438 | // perform a lookup by class alone. We must first map the class to its |
| 2439 | // service name then invoke the string-based method. |
| 2440 | String serviceName = getSystemServiceName(serviceClass); |
| 2441 | return serviceName != null ? (T)getSystemService(serviceName) : null; |
| 2442 | } |
| 2443 | |
| 2444 | /** |
| 2445 | * Gets the name of the system-level service that is represented by the specified class. |
| 2446 | * |
| 2447 | * @param serviceClass The class of the desired service. |
| 2448 | * @return The service name or null if the class is not a supported system service. |
| 2449 | * |
| 2450 | * @hide |
| 2451 | */ |
| 2452 | public abstract String getSystemServiceName(Class<?> serviceClass); |
| 2453 | |
| 2454 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2455 | * Use with {@link #getSystemService} to retrieve a |
| 2456 | * {@link android.os.PowerManager} for controlling power management, |
| 2457 | * including "wake locks," which let you keep the device on while |
| 2458 | * you're running long tasks. |
| 2459 | */ |
| 2460 | public static final String POWER_SERVICE = "power"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2461 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2462 | /** |
| 2463 | * Use with {@link #getSystemService} to retrieve a |
| 2464 | * {@link android.view.WindowManager} for accessing the system's window |
| 2465 | * manager. |
| 2466 | * |
| 2467 | * @see #getSystemService |
| 2468 | * @see android.view.WindowManager |
| 2469 | */ |
| 2470 | public static final String WINDOW_SERVICE = "window"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2471 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2472 | /** |
| 2473 | * Use with {@link #getSystemService} to retrieve a |
| 2474 | * {@link android.view.LayoutInflater} for inflating layout resources in this |
| 2475 | * context. |
| 2476 | * |
| 2477 | * @see #getSystemService |
| 2478 | * @see android.view.LayoutInflater |
| 2479 | */ |
| 2480 | public static final String LAYOUT_INFLATER_SERVICE = "layout_inflater"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2481 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2482 | /** |
| 2483 | * Use with {@link #getSystemService} to retrieve a |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 2484 | * {@link android.accounts.AccountManager} for receiving intents at a |
| 2485 | * time of your choosing. |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 2486 | * |
| 2487 | * @see #getSystemService |
| 2488 | * @see android.accounts.AccountManager |
| 2489 | */ |
| 2490 | public static final String ACCOUNT_SERVICE = "account"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2491 | |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 2492 | /** |
| 2493 | * Use with {@link #getSystemService} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2494 | * {@link android.app.ActivityManager} for interacting with the global |
| 2495 | * system state. |
| 2496 | * |
| 2497 | * @see #getSystemService |
| 2498 | * @see android.app.ActivityManager |
| 2499 | */ |
| 2500 | public static final String ACTIVITY_SERVICE = "activity"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2501 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2502 | /** |
| 2503 | * Use with {@link #getSystemService} to retrieve a |
| 2504 | * {@link android.app.AlarmManager} for receiving intents at a |
| 2505 | * time of your choosing. |
| 2506 | * |
| 2507 | * @see #getSystemService |
| 2508 | * @see android.app.AlarmManager |
| 2509 | */ |
| 2510 | public static final String ALARM_SERVICE = "alarm"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2511 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2512 | /** |
| 2513 | * Use with {@link #getSystemService} to retrieve a |
| 2514 | * {@link android.app.NotificationManager} for informing the user of |
| 2515 | * background events. |
| 2516 | * |
| 2517 | * @see #getSystemService |
| 2518 | * @see android.app.NotificationManager |
| 2519 | */ |
| 2520 | public static final String NOTIFICATION_SERVICE = "notification"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2521 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2522 | /** |
| 2523 | * Use with {@link #getSystemService} to retrieve a |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 2524 | * {@link android.view.accessibility.AccessibilityManager} for giving the user |
| 2525 | * feedback for UI events through the registered event listeners. |
| 2526 | * |
| 2527 | * @see #getSystemService |
| 2528 | * @see android.view.accessibility.AccessibilityManager |
| 2529 | */ |
| 2530 | public static final String ACCESSIBILITY_SERVICE = "accessibility"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2531 | |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 2532 | /** |
| 2533 | * Use with {@link #getSystemService} to retrieve a |
Alan Viverette | 69ce69b | 2013-08-29 12:23:48 -0700 | [diff] [blame] | 2534 | * {@link android.view.accessibility.CaptioningManager} for obtaining |
| 2535 | * captioning properties and listening for changes in captioning |
| 2536 | * preferences. |
| 2537 | * |
| 2538 | * @see #getSystemService |
| 2539 | * @see android.view.accessibility.CaptioningManager |
| 2540 | */ |
| 2541 | public static final String CAPTIONING_SERVICE = "captioning"; |
| 2542 | |
| 2543 | /** |
| 2544 | * Use with {@link #getSystemService} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2545 | * {@link android.app.NotificationManager} for controlling keyguard. |
| 2546 | * |
| 2547 | * @see #getSystemService |
| 2548 | * @see android.app.KeyguardManager |
| 2549 | */ |
| 2550 | public static final String KEYGUARD_SERVICE = "keyguard"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2551 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2552 | /** |
| 2553 | * Use with {@link #getSystemService} to retrieve a {@link |
| 2554 | * android.location.LocationManager} for controlling location |
| 2555 | * updates. |
| 2556 | * |
| 2557 | * @see #getSystemService |
| 2558 | * @see android.location.LocationManager |
| 2559 | */ |
| 2560 | public static final String LOCATION_SERVICE = "location"; |
Bai Tao | a58a875 | 2010-07-13 15:32:16 +0800 | [diff] [blame] | 2561 | |
| 2562 | /** |
| 2563 | * Use with {@link #getSystemService} to retrieve a |
| 2564 | * {@link android.location.CountryDetector} for detecting the country that |
| 2565 | * the user is in. |
| 2566 | * |
| 2567 | * @hide |
| 2568 | */ |
| 2569 | public static final String COUNTRY_DETECTOR = "country_detector"; |
| 2570 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2571 | /** |
| 2572 | * Use with {@link #getSystemService} to retrieve a {@link |
| 2573 | * android.app.SearchManager} for handling searches. |
| 2574 | * |
| 2575 | * @see #getSystemService |
| 2576 | * @see android.app.SearchManager |
| 2577 | */ |
| 2578 | public static final String SEARCH_SERVICE = "search"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2579 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2580 | /** |
| 2581 | * Use with {@link #getSystemService} to retrieve a {@link |
| 2582 | * android.hardware.SensorManager} for accessing sensors. |
| 2583 | * |
| 2584 | * @see #getSystemService |
| 2585 | * @see android.hardware.SensorManager |
| 2586 | */ |
| 2587 | public static final String SENSOR_SERVICE = "sensor"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2588 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2589 | /** |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 2590 | * Use with {@link #getSystemService} to retrieve a {@link |
Kenny Root | 02c8730 | 2010-07-01 08:10:18 -0700 | [diff] [blame] | 2591 | * android.os.storage.StorageManager} for accessing system storage |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 2592 | * functions. |
| 2593 | * |
| 2594 | * @see #getSystemService |
San Mehat | b104340 | 2010-02-05 08:26:50 -0800 | [diff] [blame] | 2595 | * @see android.os.storage.StorageManager |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 2596 | */ |
| 2597 | public static final String STORAGE_SERVICE = "storage"; |
| 2598 | |
| 2599 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2600 | * Use with {@link #getSystemService} to retrieve a |
| 2601 | * com.android.server.WallpaperService for accessing wallpapers. |
| 2602 | * |
| 2603 | * @see #getSystemService |
| 2604 | */ |
| 2605 | public static final String WALLPAPER_SERVICE = "wallpaper"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2606 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2607 | /** |
| 2608 | * Use with {@link #getSystemService} to retrieve a {@link |
| 2609 | * android.os.Vibrator} for interacting with the vibration hardware. |
| 2610 | * |
| 2611 | * @see #getSystemService |
| 2612 | * @see android.os.Vibrator |
| 2613 | */ |
| 2614 | public static final String VIBRATOR_SERVICE = "vibrator"; |
Robert Greenwalt | 9e696c2 | 2010-04-01 14:45:18 -0700 | [diff] [blame] | 2615 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2616 | /** |
| 2617 | * Use with {@link #getSystemService} to retrieve a {@link |
| 2618 | * android.app.StatusBarManager} for interacting with the status bar. |
| 2619 | * |
| 2620 | * @see #getSystemService |
| 2621 | * @see android.app.StatusBarManager |
| 2622 | * @hide |
| 2623 | */ |
| 2624 | public static final String STATUS_BAR_SERVICE = "statusbar"; |
| 2625 | |
| 2626 | /** |
| 2627 | * Use with {@link #getSystemService} to retrieve a {@link |
| 2628 | * android.net.ConnectivityManager} for handling management of |
| 2629 | * network connections. |
| 2630 | * |
| 2631 | * @see #getSystemService |
| 2632 | * @see android.net.ConnectivityManager |
| 2633 | */ |
| 2634 | public static final String CONNECTIVITY_SERVICE = "connectivity"; |
| 2635 | |
| 2636 | /** |
| 2637 | * Use with {@link #getSystemService} to retrieve a {@link |
Christopher Tate | 8662cab5 | 2012-02-23 14:59:36 -0800 | [diff] [blame] | 2638 | * android.os.IUpdateLock} for managing runtime sequences that |
| 2639 | * must not be interrupted by headless OTA application or similar. |
| 2640 | * |
| 2641 | * @hide |
| 2642 | * @see #getSystemService |
| 2643 | * @see android.os.UpdateLock |
| 2644 | */ |
| 2645 | public static final String UPDATE_LOCK_SERVICE = "updatelock"; |
| 2646 | |
| 2647 | /** |
Dianne Hackborn | 35f72be | 2013-09-16 10:57:39 -0700 | [diff] [blame] | 2648 | * Constant for the internal network management service, not really a Context service. |
Dianne Hackborn | 0a6a80f | 2013-09-16 15:20:27 -0700 | [diff] [blame] | 2649 | * @hide |
San Mehat | d1df8ac | 2010-01-26 06:17:26 -0800 | [diff] [blame] | 2650 | */ |
| 2651 | public static final String NETWORKMANAGEMENT_SERVICE = "network_management"; |
| 2652 | |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 2653 | /** |
| 2654 | * Use with {@link #getSystemService} to retrieve a {@link |
| 2655 | * android.app.usage.NetworkStatsManager} for querying network usage stats. |
| 2656 | * |
| 2657 | * @see #getSystemService |
| 2658 | * @see android.app.usage.NetworkStatsManager |
| 2659 | */ |
Jeff Sharkey | 7527990 | 2011-05-24 18:39:45 -0700 | [diff] [blame] | 2660 | public static final String NETWORK_STATS_SERVICE = "netstats"; |
| 2661 | /** {@hide} */ |
Jeff Sharkey | eedcb95 | 2011-05-17 14:55:15 -0700 | [diff] [blame] | 2662 | public static final String NETWORK_POLICY_SERVICE = "netpolicy"; |
| 2663 | |
San Mehat | d1df8ac | 2010-01-26 06:17:26 -0800 | [diff] [blame] | 2664 | /** |
| 2665 | * Use with {@link #getSystemService} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2666 | * android.net.wifi.WifiManager} for handling management of |
| 2667 | * Wi-Fi access. |
| 2668 | * |
| 2669 | * @see #getSystemService |
| 2670 | * @see android.net.wifi.WifiManager |
| 2671 | */ |
| 2672 | public static final String WIFI_SERVICE = "wifi"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2673 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2674 | /** |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 2675 | * Use with {@link #getSystemService} to retrieve a {@link |
Roger Chang | 7fee723 | 2014-05-15 14:46:49 -0700 | [diff] [blame] | 2676 | * android.net.wifi.passpoint.WifiPasspointManager} for handling management of |
Yuhao Zheng | a486447 | 2014-04-10 11:45:42 -0700 | [diff] [blame] | 2677 | * Wi-Fi passpoint access. |
Yuhao Zheng | 10bf635 | 2014-03-25 15:00:45 -0700 | [diff] [blame] | 2678 | * |
| 2679 | * @see #getSystemService |
Roger Chang | 7fee723 | 2014-05-15 14:46:49 -0700 | [diff] [blame] | 2680 | * @see android.net.wifi.passpoint.WifiPasspointManager |
Yuhao Zheng | 0cb59f2 | 2014-05-27 10:35:02 -0700 | [diff] [blame] | 2681 | * @hide |
Yuhao Zheng | 10bf635 | 2014-03-25 15:00:45 -0700 | [diff] [blame] | 2682 | */ |
Yuhao Zheng | a486447 | 2014-04-10 11:45:42 -0700 | [diff] [blame] | 2683 | public static final String WIFI_PASSPOINT_SERVICE = "wifipasspoint"; |
Yuhao Zheng | 10bf635 | 2014-03-25 15:00:45 -0700 | [diff] [blame] | 2684 | |
| 2685 | /** |
| 2686 | * Use with {@link #getSystemService} to retrieve a {@link |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 2687 | * android.net.wifi.p2p.WifiP2pManager} for handling management of |
Irfan Sheriff | 651cdfc | 2011-09-07 00:31:20 -0700 | [diff] [blame] | 2688 | * Wi-Fi peer-to-peer connections. |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 2689 | * |
| 2690 | * @see #getSystemService |
| 2691 | * @see android.net.wifi.p2p.WifiP2pManager |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 2692 | */ |
| 2693 | public static final String WIFI_P2P_SERVICE = "wifip2p"; |
| 2694 | |
| 2695 | /** |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 2696 | * Use with {@link #getSystemService} to retrieve a {@link |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 2697 | * android.net.wifi.WifiScanner} for scanning the wifi universe |
| 2698 | * |
| 2699 | * @see #getSystemService |
| 2700 | * @see android.net.wifi.WifiScanner |
| 2701 | * @hide |
| 2702 | */ |
Wei Wang | 35d552f | 2014-07-08 21:37:01 -0700 | [diff] [blame] | 2703 | @SystemApi |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 2704 | public static final String WIFI_SCANNING_SERVICE = "wifiscanner"; |
| 2705 | |
| 2706 | /** |
| 2707 | * Use with {@link #getSystemService} to retrieve a {@link |
Vinit Deshpande | 7686c06 | 2014-06-30 15:25:01 -0700 | [diff] [blame] | 2708 | * android.net.wifi.RttManager} for ranging devices with wifi |
| 2709 | * |
| 2710 | * @see #getSystemService |
| 2711 | * @see android.net.wifi.RttManager |
| 2712 | * @hide |
| 2713 | */ |
| 2714 | @SystemApi |
| 2715 | public static final String WIFI_RTT_SERVICE = "rttmanager"; |
| 2716 | |
| 2717 | /** |
| 2718 | * Use with {@link #getSystemService} to retrieve a {@link |
Dianne Hackborn | fee756f | 2014-07-16 17:31:10 -0700 | [diff] [blame] | 2719 | * android.net.EthernetManager} for handling management of |
Lorenzo Colitti | f9ff2c9 | 2014-05-21 16:32:11 -0700 | [diff] [blame] | 2720 | * Ethernet access. |
| 2721 | * |
| 2722 | * @see #getSystemService |
Dianne Hackborn | fee756f | 2014-07-16 17:31:10 -0700 | [diff] [blame] | 2723 | * @see android.net.EthernetManager |
Lorenzo Colitti | f9ff2c9 | 2014-05-21 16:32:11 -0700 | [diff] [blame] | 2724 | * |
| 2725 | * @hide |
| 2726 | */ |
| 2727 | public static final String ETHERNET_SERVICE = "ethernet"; |
| 2728 | |
| 2729 | /** |
| 2730 | * Use with {@link #getSystemService} to retrieve a {@link |
Irfan Sheriff | 60309fc | 2012-04-24 14:52:37 -0700 | [diff] [blame] | 2731 | * android.net.nsd.NsdManager} for handling management of network service |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 2732 | * discovery |
| 2733 | * |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 2734 | * @see #getSystemService |
Irfan Sheriff | 60309fc | 2012-04-24 14:52:37 -0700 | [diff] [blame] | 2735 | * @see android.net.nsd.NsdManager |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 2736 | */ |
| 2737 | public static final String NSD_SERVICE = "servicediscovery"; |
| 2738 | |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 2739 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2740 | * Use with {@link #getSystemService} to retrieve a |
| 2741 | * {@link android.media.AudioManager} for handling management of volume, |
| 2742 | * ringer modes and audio routing. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2743 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2744 | * @see #getSystemService |
| 2745 | * @see android.media.AudioManager |
| 2746 | */ |
| 2747 | public static final String AUDIO_SERVICE = "audio"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2748 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2749 | /** |
| 2750 | * Use with {@link #getSystemService} to retrieve a |
Jim Miller | ce7eb6d | 2015-04-03 19:29:13 -0700 | [diff] [blame] | 2751 | * {@link android.hardware.fingerprint.FingerprintManager} for handling management |
Jim Miller | 08fa40c | 2014-04-29 18:18:47 -0700 | [diff] [blame] | 2752 | * of fingerprints. |
| 2753 | * |
| 2754 | * @see #getSystemService |
Jim Miller | ce7eb6d | 2015-04-03 19:29:13 -0700 | [diff] [blame] | 2755 | * @see android.hardware.fingerprint.FingerprintManager |
Jim Miller | 08fa40c | 2014-04-29 18:18:47 -0700 | [diff] [blame] | 2756 | */ |
| 2757 | public static final String FINGERPRINT_SERVICE = "fingerprint"; |
| 2758 | |
| 2759 | /** |
| 2760 | * Use with {@link #getSystemService} to retrieve a |
Dianne Hackborn | b58b8f8 | 2012-06-11 15:08:39 -0700 | [diff] [blame] | 2761 | * {@link android.media.MediaRouter} for controlling and managing |
| 2762 | * routing of media. |
| 2763 | * |
| 2764 | * @see #getSystemService |
| 2765 | * @see android.media.MediaRouter |
| 2766 | */ |
| 2767 | public static final String MEDIA_ROUTER_SERVICE = "media_router"; |
| 2768 | |
| 2769 | /** |
| 2770 | * Use with {@link #getSystemService} to retrieve a |
RoboErik | 42ea7ee | 2014-05-16 16:27:35 -0700 | [diff] [blame] | 2771 | * {@link android.media.session.MediaSessionManager} for managing media Sessions. |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 2772 | * |
| 2773 | * @see #getSystemService |
RoboErik | 42ea7ee | 2014-05-16 16:27:35 -0700 | [diff] [blame] | 2774 | * @see android.media.session.MediaSessionManager |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 2775 | */ |
| 2776 | public static final String MEDIA_SESSION_SERVICE = "media_session"; |
| 2777 | |
| 2778 | /** |
| 2779 | * Use with {@link #getSystemService} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2780 | * {@link android.telephony.TelephonyManager} for handling management the |
| 2781 | * telephony features of the device. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2782 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2783 | * @see #getSystemService |
| 2784 | * @see android.telephony.TelephonyManager |
| 2785 | */ |
| 2786 | public static final String TELEPHONY_SERVICE = "phone"; |
| 2787 | |
| 2788 | /** |
| 2789 | * Use with {@link #getSystemService} to retrieve a |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 2790 | * {@link android.telephony.SubscriptionManager} for handling management the |
| 2791 | * telephony subscriptions of the device. |
| 2792 | * |
| 2793 | * @see #getSystemService |
| 2794 | * @see android.telephony.SubscriptionManager |
| 2795 | */ |
| 2796 | public static final String TELEPHONY_SUBSCRIPTION_SERVICE = "telephony_subscription_service"; |
| 2797 | |
| 2798 | /** |
| 2799 | * Use with {@link #getSystemService} to retrieve a |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2800 | * {@link android.telecom.TelecomManager} to manage telecom-related features |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 2801 | * of the device. |
| 2802 | * |
| 2803 | * @see #getSystemService |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2804 | * @see android.telecom.TelecomManager |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 2805 | */ |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2806 | public static final String TELECOM_SERVICE = "telecom"; |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 2807 | |
| 2808 | /** |
| 2809 | * Use with {@link #getSystemService} to retrieve a |
Jonathan Basseri | 9a1c9b6 | 2015-02-25 13:01:52 -0800 | [diff] [blame] | 2810 | * {@link android.telephony.CarrierConfigManager} for reading carrier configuration values. |
| 2811 | * |
| 2812 | * @see #getSystemService |
| 2813 | * @see android.telephony.CarrierConfigManager |
| 2814 | */ |
| 2815 | public static final String CARRIER_CONFIG_SERVICE = "carrier_config"; |
| 2816 | |
| 2817 | /** |
| 2818 | * Use with {@link #getSystemService} to retrieve a |
| 2819 | * {@link android.text.ClipboardManager} for accessing and modifying |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 2820 | * {@link android.content.ClipboardManager} for accessing and modifying |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2821 | * the contents of the global clipboard. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2822 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2823 | * @see #getSystemService |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 2824 | * @see android.content.ClipboardManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2825 | */ |
| 2826 | public static final String CLIPBOARD_SERVICE = "clipboard"; |
| 2827 | |
| 2828 | /** |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2829 | * Use with {@link #getSystemService} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2830 | * {@link android.view.inputmethod.InputMethodManager} for accessing input |
| 2831 | * methods. |
| 2832 | * |
| 2833 | * @see #getSystemService |
| 2834 | */ |
| 2835 | public static final String INPUT_METHOD_SERVICE = "input_method"; |
| 2836 | |
| 2837 | /** |
| 2838 | * Use with {@link #getSystemService} to retrieve a |
satok | 988323c | 2011-06-22 16:38:13 +0900 | [diff] [blame] | 2839 | * {@link android.view.textservice.TextServicesManager} for accessing |
| 2840 | * text services. |
| 2841 | * |
| 2842 | * @see #getSystemService |
| 2843 | */ |
| 2844 | public static final String TEXT_SERVICES_MANAGER_SERVICE = "textservices"; |
| 2845 | |
| 2846 | /** |
| 2847 | * Use with {@link #getSystemService} to retrieve a |
Dan Egnor | e38d58b | 2009-12-30 19:29:03 -0800 | [diff] [blame] | 2848 | * {@link android.appwidget.AppWidgetManager} for accessing AppWidgets. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2849 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2850 | * @see #getSystemService |
| 2851 | */ |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 2852 | public static final String APPWIDGET_SERVICE = "appwidget"; |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 2853 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2854 | /** |
Dianne Hackborn | 91097de | 2014-04-04 18:02:06 -0700 | [diff] [blame] | 2855 | * Official published name of the (internal) voice interaction manager service. |
| 2856 | * |
| 2857 | * @hide |
| 2858 | * @see #getSystemService |
| 2859 | */ |
| 2860 | public static final String VOICE_INTERACTION_MANAGER_SERVICE = "voiceinteraction"; |
| 2861 | |
| 2862 | /** |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 2863 | * Use with {@link #getSystemService} to retrieve an |
Christopher Tate | 4528186 | 2010-03-05 15:46:30 -0800 | [diff] [blame] | 2864 | * {@link android.app.backup.IBackupManager IBackupManager} for communicating |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 2865 | * with the backup mechanism. |
Dianne Hackborn | 7f20543 | 2009-07-28 00:13:47 -0700 | [diff] [blame] | 2866 | * @hide |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2867 | * |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 2868 | * @see #getSystemService |
| 2869 | */ |
Christopher Tate | d5cf722 | 2014-07-29 16:53:09 -0700 | [diff] [blame] | 2870 | @SystemApi |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 2871 | public static final String BACKUP_SERVICE = "backup"; |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 2872 | |
| 2873 | /** |
| 2874 | * Use with {@link #getSystemService} to retrieve a |
Dan Egnor | 1337b01 | 2010-01-04 11:01:44 -0800 | [diff] [blame] | 2875 | * {@link android.os.DropBoxManager} instance for recording |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 2876 | * diagnostic logs. |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 2877 | * @see #getSystemService |
| 2878 | */ |
| 2879 | public static final String DROPBOX_SERVICE = "dropbox"; |
| 2880 | |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 2881 | /** |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2882 | * Use with {@link #getSystemService} to retrieve a |
Dianne Hackborn | 87bba1e | 2010-02-26 17:25:54 -0800 | [diff] [blame] | 2883 | * {@link android.app.admin.DevicePolicyManager} for working with global |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 2884 | * device policy management. |
| 2885 | * |
| 2886 | * @see #getSystemService |
| 2887 | */ |
| 2888 | public static final String DEVICE_POLICY_SERVICE = "device_policy"; |
| 2889 | |
| 2890 | /** |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 2891 | * Use with {@link #getSystemService} to retrieve a |
| 2892 | * {@link android.app.UiModeManager} for controlling UI modes. |
| 2893 | * |
| 2894 | * @see #getSystemService |
| 2895 | */ |
| 2896 | public static final String UI_MODE_SERVICE = "uimode"; |
| 2897 | |
| 2898 | /** |
Steve Howard | a270936 | 2010-07-02 17:12:48 -0700 | [diff] [blame] | 2899 | * Use with {@link #getSystemService} to retrieve a |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 2900 | * {@link android.app.DownloadManager} for requesting HTTP downloads. |
Steve Howard | a270936 | 2010-07-02 17:12:48 -0700 | [diff] [blame] | 2901 | * |
| 2902 | * @see #getSystemService |
Steve Howard | a270936 | 2010-07-02 17:12:48 -0700 | [diff] [blame] | 2903 | */ |
| 2904 | public static final String DOWNLOAD_SERVICE = "download"; |
| 2905 | |
| 2906 | /** |
Chung-yih Wang | 2d94231 | 2010-08-05 12:17:37 +0800 | [diff] [blame] | 2907 | * Use with {@link #getSystemService} to retrieve a |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 2908 | * {@link android.os.BatteryManager} for managing battery state. |
| 2909 | * |
| 2910 | * @see #getSystemService |
| 2911 | */ |
| 2912 | public static final String BATTERY_SERVICE = "batterymanager"; |
| 2913 | |
| 2914 | /** |
| 2915 | * Use with {@link #getSystemService} to retrieve a |
Nick Pelly | 50b4d8f | 2010-12-07 22:40:28 -0800 | [diff] [blame] | 2916 | * {@link android.nfc.NfcManager} for using NFC. |
| 2917 | * |
| 2918 | * @see #getSystemService |
| 2919 | */ |
| 2920 | public static final String NFC_SERVICE = "nfc"; |
| 2921 | |
| 2922 | /** |
| 2923 | * Use with {@link #getSystemService} to retrieve a |
Florian Salbrechter | 084da9b | 2015-03-25 11:00:55 +0000 | [diff] [blame] | 2924 | * {@link android.bluetooth.BluetoothManager} for using Bluetooth. |
Jaikumar Ganesh | 1abb1cb | 2012-01-25 16:14:50 -0800 | [diff] [blame] | 2925 | * |
| 2926 | * @see #getSystemService |
Jaikumar Ganesh | 1abb1cb | 2012-01-25 16:14:50 -0800 | [diff] [blame] | 2927 | */ |
| 2928 | public static final String BLUETOOTH_SERVICE = "bluetooth"; |
| 2929 | |
| 2930 | /** |
| 2931 | * Use with {@link #getSystemService} to retrieve a |
Chung-yih Wang | 2d94231 | 2010-08-05 12:17:37 +0800 | [diff] [blame] | 2932 | * {@link android.net.sip.SipManager} for accessing the SIP related service. |
| 2933 | * |
| 2934 | * @see #getSystemService |
| 2935 | */ |
| 2936 | /** @hide */ |
| 2937 | public static final String SIP_SERVICE = "sip"; |
| 2938 | |
| 2939 | /** |
Mike Lockwood | e7d511e | 2010-12-30 13:39:37 -0500 | [diff] [blame] | 2940 | * Use with {@link #getSystemService} to retrieve a {@link |
Mike Lockwood | c4308f0 | 2011-03-01 08:04:54 -0800 | [diff] [blame] | 2941 | * 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] | 2942 | * and for controlling this device's behavior as a USB device. |
| 2943 | * |
| 2944 | * @see #getSystemService |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 2945 | * @see android.hardware.usb.UsbManager |
Mike Lockwood | e7d511e | 2010-12-30 13:39:37 -0500 | [diff] [blame] | 2946 | */ |
| 2947 | public static final String USB_SERVICE = "usb"; |
| 2948 | |
| 2949 | /** |
Mike Lockwood | b01e8bf | 2011-08-29 20:11:07 -0400 | [diff] [blame] | 2950 | * Use with {@link #getSystemService} to retrieve a {@link |
| 2951 | * android.hardware.SerialManager} for access to serial ports. |
| 2952 | * |
| 2953 | * @see #getSystemService |
Dianne Hackborn | 35f72be | 2013-09-16 10:57:39 -0700 | [diff] [blame] | 2954 | * @see android.hardware.SerialManager |
Mike Lockwood | b01e8bf | 2011-08-29 20:11:07 -0400 | [diff] [blame] | 2955 | * |
| 2956 | * @hide |
| 2957 | */ |
| 2958 | public static final String SERIAL_SERVICE = "serial"; |
| 2959 | |
| 2960 | /** |
Jeff Brown | 9df6e7a | 2012-04-05 11:49:26 -0700 | [diff] [blame] | 2961 | * Use with {@link #getSystemService} to retrieve a |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 2962 | * {@link android.hardware.hdmi.HdmiControlManager} for controlling and managing |
| 2963 | * HDMI-CEC protocol. |
| 2964 | * |
| 2965 | * @see #getSystemService |
| 2966 | * @see android.hardware.hdmi.HdmiControlManager |
Jinsuk Kim | 66d1eb2 | 2014-06-06 16:12:18 +0900 | [diff] [blame] | 2967 | * @hide |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 2968 | */ |
Jinsuk Kim | 66d1eb2 | 2014-06-06 16:12:18 +0900 | [diff] [blame] | 2969 | @SystemApi |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 2970 | public static final String HDMI_CONTROL_SERVICE = "hdmi_control"; |
Jinsuk Kim | fbcd503 | 2014-03-21 16:25:13 +0900 | [diff] [blame] | 2971 | |
| 2972 | /** |
| 2973 | * Use with {@link #getSystemService} to retrieve a |
Jeff Brown | 9df6e7a | 2012-04-05 11:49:26 -0700 | [diff] [blame] | 2974 | * {@link android.hardware.input.InputManager} for interacting with input devices. |
| 2975 | * |
| 2976 | * @see #getSystemService |
| 2977 | * @see android.hardware.input.InputManager |
| 2978 | */ |
| 2979 | public static final String INPUT_SERVICE = "input"; |
| 2980 | |
| 2981 | /** |
Glenn Kasten | 07b0465 | 2012-04-23 15:00:43 -0700 | [diff] [blame] | 2982 | * Use with {@link #getSystemService} to retrieve a |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 2983 | * {@link android.hardware.display.DisplayManager} for interacting with display devices. |
| 2984 | * |
| 2985 | * @see #getSystemService |
| 2986 | * @see android.hardware.display.DisplayManager |
| 2987 | */ |
| 2988 | public static final String DISPLAY_SERVICE = "display"; |
| 2989 | |
| 2990 | /** |
| 2991 | * Use with {@link #getSystemService} to retrieve a |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 2992 | * {@link android.os.UserManager} for managing users on devices that support multiple users. |
| 2993 | * |
| 2994 | * @see #getSystemService |
| 2995 | * @see android.os.UserManager |
| 2996 | */ |
| 2997 | public static final String USER_SERVICE = "user"; |
| 2998 | |
| 2999 | /** |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 3000 | * Use with {@link #getSystemService} to retrieve a |
Amith Yamasani | 4f58263 | 2014-02-19 14:31:52 -0800 | [diff] [blame] | 3001 | * {@link android.content.pm.LauncherApps} for querying and monitoring launchable apps across |
| 3002 | * profiles of a user. |
| 3003 | * |
| 3004 | * @see #getSystemService |
| 3005 | * @see android.content.pm.LauncherApps |
| 3006 | */ |
| 3007 | public static final String LAUNCHER_APPS_SERVICE = "launcherapps"; |
| 3008 | |
| 3009 | /** |
| 3010 | * Use with {@link #getSystemService} to retrieve a |
Amith Yamasani | f20d640 | 2014-05-24 15:34:37 -0700 | [diff] [blame] | 3011 | * {@link android.content.RestrictionsManager} for retrieving application restrictions |
| 3012 | * and requesting permissions for restricted operations. |
| 3013 | * @see #getSystemService |
| 3014 | * @see android.content.RestrictionsManager |
| 3015 | */ |
| 3016 | public static final String RESTRICTIONS_SERVICE = "restrictions"; |
| 3017 | |
| 3018 | /** |
| 3019 | * Use with {@link #getSystemService} to retrieve a |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 3020 | * {@link android.app.AppOpsManager} for tracking application operations |
| 3021 | * on the device. |
| 3022 | * |
| 3023 | * @see #getSystemService |
| 3024 | * @see android.app.AppOpsManager |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 3025 | */ |
| 3026 | public static final String APP_OPS_SERVICE = "appops"; |
| 3027 | |
| 3028 | /** |
Eino-Ville Talvala | b267554 | 2012-12-12 13:29:45 -0800 | [diff] [blame] | 3029 | * Use with {@link #getSystemService} to retrieve a |
Eino-Ville Talvala | 2f1a2e4 | 2013-07-25 17:12:05 -0700 | [diff] [blame] | 3030 | * {@link android.hardware.camera2.CameraManager} for interacting with |
Eino-Ville Talvala | b267554 | 2012-12-12 13:29:45 -0800 | [diff] [blame] | 3031 | * camera devices. |
| 3032 | * |
| 3033 | * @see #getSystemService |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 3034 | * @see android.hardware.camera2.CameraManager |
Eino-Ville Talvala | b267554 | 2012-12-12 13:29:45 -0800 | [diff] [blame] | 3035 | */ |
| 3036 | public static final String CAMERA_SERVICE = "camera"; |
| 3037 | |
| 3038 | /** |
Svetoslav Ganov | 4b9a4d1 | 2013-06-11 15:20:06 -0700 | [diff] [blame] | 3039 | * {@link android.print.PrintManager} for printing and managing |
Jeff Brown | 511cd35 | 2013-08-23 17:43:37 -0700 | [diff] [blame] | 3040 | * printers and print tasks. |
Svetoslav Ganov | 4b9a4d1 | 2013-06-11 15:20:06 -0700 | [diff] [blame] | 3041 | * |
| 3042 | * @see #getSystemService |
| 3043 | * @see android.print.PrintManager |
| 3044 | */ |
| 3045 | public static final String PRINT_SERVICE = "print"; |
| 3046 | |
| 3047 | /** |
Erik Gilling | 51e95df | 2013-06-26 11:06:51 -0700 | [diff] [blame] | 3048 | * Use with {@link #getSystemService} to retrieve a |
| 3049 | * {@link android.hardware.ConsumerIrManager} for transmitting infrared |
| 3050 | * signals from the device. |
| 3051 | * |
| 3052 | * @see #getSystemService |
| 3053 | * @see android.hardware.ConsumerIrManager |
| 3054 | */ |
| 3055 | public static final String CONSUMER_IR_SERVICE = "consumer_ir"; |
| 3056 | |
| 3057 | /** |
Adrian Roos | 82142c2 | 2014-03-27 14:56:59 +0100 | [diff] [blame] | 3058 | * {@link android.app.trust.TrustManager} for managing trust agents. |
| 3059 | * @see #getSystemService |
| 3060 | * @see android.app.trust.TrustManager |
| 3061 | * @hide |
| 3062 | */ |
| 3063 | public static final String TRUST_SERVICE = "trust"; |
| 3064 | |
| 3065 | /** |
Jae Seo | 3957091 | 2014-02-20 18:23:25 -0800 | [diff] [blame] | 3066 | * Use with {@link #getSystemService} to retrieve a |
Jae Seo | d5cc4a2 | 2014-05-30 16:57:43 -0700 | [diff] [blame] | 3067 | * {@link android.media.tv.TvInputManager} for interacting with TV inputs |
| 3068 | * on the device. |
Jae Seo | 3957091 | 2014-02-20 18:23:25 -0800 | [diff] [blame] | 3069 | * |
| 3070 | * @see #getSystemService |
Jae Seo | d5cc4a2 | 2014-05-30 16:57:43 -0700 | [diff] [blame] | 3071 | * @see android.media.tv.TvInputManager |
Jae Seo | 3957091 | 2014-02-20 18:23:25 -0800 | [diff] [blame] | 3072 | */ |
| 3073 | public static final String TV_INPUT_SERVICE = "tv_input"; |
| 3074 | |
| 3075 | /** |
Jeff Davidson | b51e0a6 | 2014-04-09 12:38:15 -0700 | [diff] [blame] | 3076 | * {@link android.net.NetworkScoreManager} for managing network scoring. |
| 3077 | * @see #getSystemService |
| 3078 | * @see android.net.NetworkScoreManager |
| 3079 | * @hide |
| 3080 | */ |
Jeff Davidson | 5ad2079 | 2014-07-21 13:55:42 -0700 | [diff] [blame] | 3081 | @SystemApi |
Jeff Davidson | b51e0a6 | 2014-04-09 12:38:15 -0700 | [diff] [blame] | 3082 | public static final String NETWORK_SCORE_SERVICE = "network_score"; |
| 3083 | |
| 3084 | /** |
Dianne Hackborn | e22b3b1 | 2014-05-07 18:06:44 -0700 | [diff] [blame] | 3085 | * Use with {@link #getSystemService} to retrieve a {@link |
Adam Lesinski | aa60767 | 2014-11-24 11:27:50 -0800 | [diff] [blame] | 3086 | * android.app.usage.UsageStatsManager} for querying device usage stats. |
Dianne Hackborn | e22b3b1 | 2014-05-07 18:06:44 -0700 | [diff] [blame] | 3087 | * |
| 3088 | * @see #getSystemService |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 3089 | * @see android.app.usage.UsageStatsManager |
Dianne Hackborn | e22b3b1 | 2014-05-07 18:06:44 -0700 | [diff] [blame] | 3090 | */ |
| 3091 | public static final String USAGE_STATS_SERVICE = "usagestats"; |
| 3092 | |
| 3093 | /** |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 3094 | * Use with {@link #getSystemService} to retrieve a {@link |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 3095 | * android.app.job.JobScheduler} instance for managing occasional |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 3096 | * background tasks. |
| 3097 | * @see #getSystemService |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 3098 | * @see android.app.job.JobScheduler |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 3099 | */ |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 3100 | public static final String JOB_SCHEDULER_SERVICE = "jobscheduler"; |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 3101 | |
| 3102 | /** |
Andres Morales | 68d4acd | 2014-07-01 19:40:41 -0700 | [diff] [blame] | 3103 | * Use with {@link #getSystemService} to retrieve a {@link |
Andres Morales | 33df937 | 2014-09-26 17:08:59 -0700 | [diff] [blame] | 3104 | * android.service.persistentdata.PersistentDataBlockManager} instance |
| 3105 | * for interacting with a storage device that lives across factory resets. |
| 3106 | * |
Andres Morales | 68d4acd | 2014-07-01 19:40:41 -0700 | [diff] [blame] | 3107 | * @see #getSystemService |
| 3108 | * @see android.service.persistentdata.PersistentDataBlockManager |
| 3109 | * @hide |
| 3110 | */ |
Andres Morales | 33df937 | 2014-09-26 17:08:59 -0700 | [diff] [blame] | 3111 | @SystemApi |
Andres Morales | 68d4acd | 2014-07-01 19:40:41 -0700 | [diff] [blame] | 3112 | public static final String PERSISTENT_DATA_BLOCK_SERVICE = "persistent_data_block"; |
| 3113 | |
| 3114 | /** |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 3115 | * Use with {@link #getSystemService} to retrieve a {@link |
| 3116 | * android.media.projection.MediaProjectionManager} instance for managing |
| 3117 | * media projection sessions. |
| 3118 | * @see #getSystemService |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3119 | * @see android.media.projection.MediaProjectionManager |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 3120 | */ |
| 3121 | public static final String MEDIA_PROJECTION_SERVICE = "media_projection"; |
| 3122 | |
| 3123 | /** |
Mike Lockwood | 67f8e8b | 2014-12-01 13:54:59 -0800 | [diff] [blame] | 3124 | * Use with {@link #getSystemService} to retrieve a |
Mike Lockwood | b673770 | 2015-02-20 08:28:47 -0800 | [diff] [blame] | 3125 | * {@link android.media.midi.MidiManager} for accessing the MIDI service. |
Mike Lockwood | 67f8e8b | 2014-12-01 13:54:59 -0800 | [diff] [blame] | 3126 | * |
| 3127 | * @see #getSystemService |
Mike Lockwood | 67f8e8b | 2014-12-01 13:54:59 -0800 | [diff] [blame] | 3128 | */ |
| 3129 | public static final String MIDI_SERVICE = "midi"; |
| 3130 | |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 3131 | |
| 3132 | /** |
| 3133 | * Use with {@link #getSystemService} to retrieve a |
| 3134 | * {@link android.hardware.radio.RadioManager} for accessing the broadcast radio service. |
| 3135 | * |
| 3136 | * @see #getSystemService |
| 3137 | * @hide |
| 3138 | */ |
| 3139 | public static final String RADIO_SERVICE = "radio"; |
| 3140 | |
Paul McLean | a33be21 | 2015-02-20 07:52:45 -0800 | [diff] [blame] | 3141 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3142 | * Determine whether the given permission is allowed for a particular |
| 3143 | * process and user ID running in the system. |
| 3144 | * |
| 3145 | * @param permission The name of the permission being checked. |
| 3146 | * @param pid The process ID being checked against. Must be > 0. |
| 3147 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 3148 | * user, which will pass every permission check. |
| 3149 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3150 | * @return {@link PackageManager#PERMISSION_GRANTED} if the given |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3151 | * pid/uid is allowed that permission, or |
| 3152 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 3153 | * |
| 3154 | * @see PackageManager#checkPermission(String, String) |
| 3155 | * @see #checkCallingPermission |
| 3156 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 3157 | @CheckResult(suggest="#enforcePermission(String,int,int,String)") |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3158 | @PackageManager.PermissionResult |
| 3159 | 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] | 3160 | |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 3161 | /** @hide */ |
| 3162 | @PackageManager.PermissionResult |
| 3163 | public abstract int checkPermission(@NonNull String permission, int pid, int uid, |
| 3164 | IBinder callerToken); |
| 3165 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3166 | /** |
| 3167 | * Determine whether the calling process of an IPC you are handling has been |
| 3168 | * granted a particular permission. This is basically the same as calling |
| 3169 | * {@link #checkPermission(String, int, int)} with the pid and uid returned |
| 3170 | * by {@link android.os.Binder#getCallingPid} and |
| 3171 | * {@link android.os.Binder#getCallingUid}. One important difference |
| 3172 | * is that if you are not currently processing an IPC, this function |
| 3173 | * will always fail. This is done to protect against accidentally |
| 3174 | * leaking permissions; you can use {@link #checkCallingOrSelfPermission} |
| 3175 | * to avoid this protection. |
| 3176 | * |
| 3177 | * @param permission The name of the permission being checked. |
| 3178 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3179 | * @return {@link PackageManager#PERMISSION_GRANTED} if the calling |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3180 | * pid/uid is allowed that permission, or |
| 3181 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 3182 | * |
| 3183 | * @see PackageManager#checkPermission(String, String) |
| 3184 | * @see #checkPermission |
| 3185 | * @see #checkCallingOrSelfPermission |
| 3186 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 3187 | @CheckResult(suggest="#enforceCallingPermission(String,String)") |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3188 | @PackageManager.PermissionResult |
| 3189 | public abstract int checkCallingPermission(@NonNull String permission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3190 | |
| 3191 | /** |
| 3192 | * Determine whether the calling process of an IPC <em>or you</em> have been |
| 3193 | * granted a particular permission. This is the same as |
| 3194 | * {@link #checkCallingPermission}, except it grants your own permissions |
| 3195 | * if you are not currently processing an IPC. Use with care! |
| 3196 | * |
| 3197 | * @param permission The name of the permission being checked. |
| 3198 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3199 | * @return {@link PackageManager#PERMISSION_GRANTED} if the calling |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3200 | * pid/uid is allowed that permission, or |
| 3201 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 3202 | * |
| 3203 | * @see PackageManager#checkPermission(String, String) |
| 3204 | * @see #checkPermission |
| 3205 | * @see #checkCallingPermission |
| 3206 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 3207 | @CheckResult(suggest="#enforceCallingOrSelfPermission(String,String)") |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3208 | @PackageManager.PermissionResult |
| 3209 | public abstract int checkCallingOrSelfPermission(@NonNull String permission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3210 | |
| 3211 | /** |
Svetoslav | c6d1c34 | 2015-02-26 14:44:43 -0800 | [diff] [blame] | 3212 | * Determine whether <em>you</em> have been granted a particular permission. |
| 3213 | * |
| 3214 | * @param permission The name of the permission being checked. |
| 3215 | * |
| 3216 | * @return {@link PackageManager#PERMISSION_GRANTED} if you have the |
| 3217 | * permission, or {@link PackageManager#PERMISSION_DENIED} if not. |
| 3218 | * |
| 3219 | * @see PackageManager#checkPermission(String, String) |
| 3220 | * @see #checkCallingPermission(String) |
| 3221 | */ |
| 3222 | @PackageManager.PermissionResult |
| 3223 | public abstract int checkSelfPermission(@NonNull String permission); |
| 3224 | |
| 3225 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3226 | * If the given permission is not allowed for a particular process |
| 3227 | * and user ID running in the system, throw a {@link SecurityException}. |
| 3228 | * |
| 3229 | * @param permission The name of the permission being checked. |
| 3230 | * @param pid The process ID being checked against. Must be > 0. |
| 3231 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 3232 | * user, which will pass every permission check. |
| 3233 | * @param message A message to include in the exception if it is thrown. |
| 3234 | * |
| 3235 | * @see #checkPermission(String, int, int) |
| 3236 | */ |
| 3237 | public abstract void enforcePermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3238 | @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] | 3239 | |
| 3240 | /** |
| 3241 | * If the calling process of an IPC you are handling has not been |
| 3242 | * granted a particular permission, throw a {@link |
| 3243 | * SecurityException}. This is basically the same as calling |
| 3244 | * {@link #enforcePermission(String, int, int, String)} with the |
| 3245 | * pid and uid returned by {@link android.os.Binder#getCallingPid} |
| 3246 | * and {@link android.os.Binder#getCallingUid}. One important |
| 3247 | * difference is that if you are not currently processing an IPC, |
| 3248 | * this function will always throw the SecurityException. This is |
| 3249 | * done to protect against accidentally leaking permissions; you |
| 3250 | * can use {@link #enforceCallingOrSelfPermission} to avoid this |
| 3251 | * protection. |
| 3252 | * |
| 3253 | * @param permission The name of the permission being checked. |
| 3254 | * @param message A message to include in the exception if it is thrown. |
| 3255 | * |
| 3256 | * @see #checkCallingPermission(String) |
| 3257 | */ |
| 3258 | public abstract void enforceCallingPermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3259 | @NonNull String permission, @Nullable String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3260 | |
| 3261 | /** |
| 3262 | * If neither you nor the calling process of an IPC you are |
| 3263 | * handling has been granted a particular permission, throw a |
| 3264 | * {@link SecurityException}. This is the same as {@link |
| 3265 | * #enforceCallingPermission}, except it grants your own |
| 3266 | * permissions if you are not currently processing an IPC. Use |
| 3267 | * with care! |
| 3268 | * |
| 3269 | * @param permission The name of the permission being checked. |
| 3270 | * @param message A message to include in the exception if it is thrown. |
| 3271 | * |
| 3272 | * @see #checkCallingOrSelfPermission(String) |
| 3273 | */ |
| 3274 | public abstract void enforceCallingOrSelfPermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3275 | @NonNull String permission, @Nullable String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3276 | |
| 3277 | /** |
| 3278 | * Grant permission to access a specific Uri to another package, regardless |
| 3279 | * of whether that package has general permission to access the Uri's |
| 3280 | * content provider. This can be used to grant specific, temporary |
| 3281 | * permissions, typically in response to user interaction (such as the |
| 3282 | * user opening an attachment that you would like someone else to |
| 3283 | * display). |
| 3284 | * |
| 3285 | * <p>Normally you should use {@link Intent#FLAG_GRANT_READ_URI_PERMISSION |
| 3286 | * Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 3287 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
| 3288 | * Intent.FLAG_GRANT_WRITE_URI_PERMISSION} with the Intent being used to |
| 3289 | * start an activity instead of this function directly. If you use this |
| 3290 | * function directly, you should be sure to call |
| 3291 | * {@link #revokeUriPermission} when the target should no longer be allowed |
| 3292 | * to access it. |
| 3293 | * |
| 3294 | * <p>To succeed, the content provider owning the Uri must have set the |
| 3295 | * {@link android.R.styleable#AndroidManifestProvider_grantUriPermissions |
| 3296 | * grantUriPermissions} attribute in its manifest or included the |
| 3297 | * {@link android.R.styleable#AndroidManifestGrantUriPermission |
| 3298 | * <grant-uri-permissions>} tag. |
| 3299 | * |
| 3300 | * @param toPackage The package you would like to allow to access the Uri. |
| 3301 | * @param uri The Uri you would like to grant access to. |
| 3302 | * @param modeFlags The desired access modes. Any combination of |
| 3303 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3304 | * Intent.FLAG_GRANT_READ_URI_PERMISSION}, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3305 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3306 | * Intent.FLAG_GRANT_WRITE_URI_PERMISSION}, |
| 3307 | * {@link Intent#FLAG_GRANT_PERSISTABLE_URI_PERMISSION |
| 3308 | * Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION}, or |
| 3309 | * {@link Intent#FLAG_GRANT_PREFIX_URI_PERMISSION |
| 3310 | * Intent.FLAG_GRANT_PREFIX_URI_PERMISSION}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3311 | * |
| 3312 | * @see #revokeUriPermission |
| 3313 | */ |
| 3314 | public abstract void grantUriPermission(String toPackage, Uri uri, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3315 | @Intent.GrantUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3316 | |
| 3317 | /** |
| 3318 | * Remove all permissions to access a particular content provider Uri |
| 3319 | * that were previously added with {@link #grantUriPermission}. The given |
| 3320 | * 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] | 3321 | * 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] | 3322 | * revoke both "content://foo/target" and "content://foo/target/sub", but not |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3323 | * "content://foo". It will not remove any prefix grants that exist at a |
| 3324 | * higher level. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3325 | * |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 3326 | * <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] | 3327 | * regular permission access to a Uri, but had received access to it through |
| 3328 | * a specific Uri permission grant, you could not revoke that grant with this |
| 3329 | * function and a {@link SecurityException} would be thrown. As of |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 3330 | * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this function will not throw a security exception, |
Dianne Hackborn | 192679a | 2014-09-10 14:28:48 -0700 | [diff] [blame] | 3331 | * but will remove whatever permission grants to the Uri had been given to the app |
| 3332 | * (or none).</p> |
| 3333 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3334 | * @param uri The Uri you would like to revoke access to. |
| 3335 | * @param modeFlags The desired access modes. Any combination of |
| 3336 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION |
| 3337 | * Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 3338 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
| 3339 | * Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 3340 | * |
| 3341 | * @see #grantUriPermission |
| 3342 | */ |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3343 | 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] | 3344 | |
| 3345 | /** |
| 3346 | * Determine whether a particular process and user ID has been granted |
| 3347 | * permission to access a specific URI. This only checks for permissions |
| 3348 | * that have been explicitly granted -- if the given process/uid has |
| 3349 | * more general access to the URI's content provider then this check will |
| 3350 | * always fail. |
| 3351 | * |
| 3352 | * @param uri The uri that is being checked. |
| 3353 | * @param pid The process ID being checked against. Must be > 0. |
| 3354 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 3355 | * user, which will pass every permission check. |
| 3356 | * @param modeFlags The type of access to grant. May be one or both of |
| 3357 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 3358 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 3359 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3360 | * @return {@link PackageManager#PERMISSION_GRANTED} if the given |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3361 | * pid/uid is allowed to access that uri, or |
| 3362 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 3363 | * |
| 3364 | * @see #checkCallingUriPermission |
| 3365 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 3366 | @CheckResult(suggest="#enforceUriPermission(Uri,int,int,String)") |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3367 | public abstract int checkUriPermission(Uri uri, int pid, int uid, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3368 | @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3369 | |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 3370 | /** @hide */ |
| 3371 | public abstract int checkUriPermission(Uri uri, int pid, int uid, |
| 3372 | @Intent.AccessUriMode int modeFlags, IBinder callerToken); |
| 3373 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3374 | /** |
| 3375 | * Determine whether the calling process and user ID has been |
| 3376 | * granted permission to access a specific URI. This is basically |
| 3377 | * the same as calling {@link #checkUriPermission(Uri, int, int, |
| 3378 | * int)} with the pid and uid returned by {@link |
| 3379 | * android.os.Binder#getCallingPid} and {@link |
| 3380 | * android.os.Binder#getCallingUid}. One important difference is |
| 3381 | * that if you are not currently processing an IPC, this function |
| 3382 | * will always fail. |
| 3383 | * |
| 3384 | * @param uri The uri that is being checked. |
| 3385 | * @param modeFlags The type of access to grant. May be one or both of |
| 3386 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 3387 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 3388 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3389 | * @return {@link PackageManager#PERMISSION_GRANTED} if the caller |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3390 | * is allowed to access that uri, or |
| 3391 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 3392 | * |
| 3393 | * @see #checkUriPermission(Uri, int, int, int) |
| 3394 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 3395 | @CheckResult(suggest="#enforceCallingUriPermission(Uri,int,String)") |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3396 | 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] | 3397 | |
| 3398 | /** |
| 3399 | * Determine whether the calling process of an IPC <em>or you</em> has been granted |
| 3400 | * permission to access a specific URI. This is the same as |
| 3401 | * {@link #checkCallingUriPermission}, except it grants your own permissions |
| 3402 | * if you are not currently processing an IPC. Use with care! |
| 3403 | * |
| 3404 | * @param uri The uri that is being checked. |
| 3405 | * @param modeFlags The type of access to grant. May be one or both of |
| 3406 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 3407 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 3408 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3409 | * @return {@link PackageManager#PERMISSION_GRANTED} if the caller |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3410 | * is allowed to access that uri, or |
| 3411 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 3412 | * |
| 3413 | * @see #checkCallingUriPermission |
| 3414 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 3415 | @CheckResult(suggest="#enforceCallingOrSelfUriPermission(Uri,int,String)") |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3416 | public abstract int checkCallingOrSelfUriPermission(Uri uri, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3417 | @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3418 | |
| 3419 | /** |
| 3420 | * Check both a Uri and normal permission. This allows you to perform |
| 3421 | * both {@link #checkPermission} and {@link #checkUriPermission} in one |
| 3422 | * call. |
| 3423 | * |
| 3424 | * @param uri The Uri whose permission is to be checked, or null to not |
| 3425 | * do this check. |
| 3426 | * @param readPermission The permission that provides overall read access, |
| 3427 | * or null to not do this check. |
| 3428 | * @param writePermission The permission that provides overall write |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3429 | * access, or null to not do this check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3430 | * @param pid The process ID being checked against. Must be > 0. |
| 3431 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 3432 | * user, which will pass every permission check. |
| 3433 | * @param modeFlags The type of access to grant. May be one or both of |
| 3434 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 3435 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 3436 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3437 | * @return {@link PackageManager#PERMISSION_GRANTED} if the caller |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3438 | * is allowed to access that uri or holds one of the given permissions, or |
| 3439 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 3440 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 3441 | @CheckResult(suggest="#enforceUriPermission(Uri,String,String,int,int,int,String)") |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3442 | public abstract int checkUriPermission(@Nullable Uri uri, @Nullable String readPermission, |
| 3443 | @Nullable String writePermission, int pid, int uid, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3444 | @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3445 | |
| 3446 | /** |
| 3447 | * If a particular process and user ID has not been granted |
| 3448 | * permission to access a specific URI, throw {@link |
| 3449 | * SecurityException}. This only checks for permissions that have |
| 3450 | * been explicitly granted -- if the given process/uid has more |
| 3451 | * general access to the URI's content provider then this check |
| 3452 | * will always fail. |
| 3453 | * |
| 3454 | * @param uri The uri that is being checked. |
| 3455 | * @param pid The process ID being checked against. Must be > 0. |
| 3456 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 3457 | * user, which will pass every permission check. |
| 3458 | * @param modeFlags The type of access to grant. May be one or both of |
| 3459 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 3460 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 3461 | * @param message A message to include in the exception if it is thrown. |
| 3462 | * |
| 3463 | * @see #checkUriPermission(Uri, int, int, int) |
| 3464 | */ |
| 3465 | public abstract void enforceUriPermission( |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3466 | 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] | 3467 | |
| 3468 | /** |
| 3469 | * If the calling process and user ID has not been granted |
| 3470 | * permission to access a specific URI, throw {@link |
| 3471 | * SecurityException}. This is basically the same as calling |
| 3472 | * {@link #enforceUriPermission(Uri, int, int, int, String)} with |
| 3473 | * the pid and uid returned by {@link |
| 3474 | * android.os.Binder#getCallingPid} and {@link |
| 3475 | * android.os.Binder#getCallingUid}. One important difference is |
| 3476 | * that if you are not currently processing an IPC, this function |
| 3477 | * will always throw a SecurityException. |
| 3478 | * |
| 3479 | * @param uri The uri that is being checked. |
| 3480 | * @param modeFlags The type of access to grant. May be one or both of |
| 3481 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 3482 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 3483 | * @param message A message to include in the exception if it is thrown. |
| 3484 | * |
| 3485 | * @see #checkCallingUriPermission(Uri, int) |
| 3486 | */ |
| 3487 | public abstract void enforceCallingUriPermission( |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3488 | Uri uri, @Intent.AccessUriMode int modeFlags, String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3489 | |
| 3490 | /** |
| 3491 | * If the calling process of an IPC <em>or you</em> has not been |
| 3492 | * granted permission to access a specific URI, throw {@link |
| 3493 | * SecurityException}. This is the same as {@link |
| 3494 | * #enforceCallingUriPermission}, except it grants your own |
| 3495 | * permissions if you are not currently processing an IPC. Use |
| 3496 | * with care! |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3497 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3498 | * @param uri The uri that is being checked. |
| 3499 | * @param modeFlags The type of access to grant. May be one or both of |
| 3500 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 3501 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 3502 | * @param message A message to include in the exception if it is thrown. |
| 3503 | * |
| 3504 | * @see #checkCallingOrSelfUriPermission(Uri, int) |
| 3505 | */ |
| 3506 | public abstract void enforceCallingOrSelfUriPermission( |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3507 | Uri uri, @Intent.AccessUriMode int modeFlags, String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3508 | |
| 3509 | /** |
| 3510 | * Enforce both a Uri and normal permission. This allows you to perform |
| 3511 | * both {@link #enforcePermission} and {@link #enforceUriPermission} in one |
| 3512 | * call. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3513 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3514 | * @param uri The Uri whose permission is to be checked, or null to not |
| 3515 | * do this check. |
| 3516 | * @param readPermission The permission that provides overall read access, |
| 3517 | * or null to not do this check. |
| 3518 | * @param writePermission The permission that provides overall write |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3519 | * access, or null to not do this check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3520 | * @param pid The process ID being checked against. Must be > 0. |
| 3521 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 3522 | * user, which will pass every permission check. |
| 3523 | * @param modeFlags The type of access to grant. May be one or both of |
| 3524 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 3525 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 3526 | * @param message A message to include in the exception if it is thrown. |
| 3527 | * |
| 3528 | * @see #checkUriPermission(Uri, String, String, int, int, int) |
| 3529 | */ |
| 3530 | public abstract void enforceUriPermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3531 | @Nullable Uri uri, @Nullable String readPermission, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 3532 | @Nullable String writePermission, int pid, int uid, @Intent.AccessUriMode int modeFlags, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3533 | @Nullable String message); |
| 3534 | |
| 3535 | /** @hide */ |
| 3536 | @IntDef(flag = true, |
| 3537 | value = {CONTEXT_INCLUDE_CODE, CONTEXT_IGNORE_SECURITY, CONTEXT_RESTRICTED}) |
| 3538 | @Retention(RetentionPolicy.SOURCE) |
| 3539 | public @interface CreatePackageOptions {} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3540 | |
| 3541 | /** |
| 3542 | * Flag for use with {@link #createPackageContext}: include the application |
| 3543 | * code with the context. This means loading code into the caller's |
| 3544 | * process, so that {@link #getClassLoader()} can be used to instantiate |
| 3545 | * the application's classes. Setting this flags imposes security |
| 3546 | * restrictions on what application context you can access; if the |
| 3547 | * requested application can not be safely loaded into your process, |
| 3548 | * java.lang.SecurityException will be thrown. If this flag is not set, |
| 3549 | * there will be no restrictions on the packages that can be loaded, |
| 3550 | * but {@link #getClassLoader} will always return the default system |
| 3551 | * class loader. |
| 3552 | */ |
| 3553 | public static final int CONTEXT_INCLUDE_CODE = 0x00000001; |
| 3554 | |
| 3555 | /** |
| 3556 | * Flag for use with {@link #createPackageContext}: ignore any security |
| 3557 | * restrictions on the Context being requested, allowing it to always |
| 3558 | * be loaded. For use with {@link #CONTEXT_INCLUDE_CODE} to allow code |
| 3559 | * to be loaded into a process even when it isn't safe to do so. Use |
| 3560 | * with extreme care! |
| 3561 | */ |
| 3562 | public static final int CONTEXT_IGNORE_SECURITY = 0x00000002; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3563 | |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 3564 | /** |
| 3565 | * Flag for use with {@link #createPackageContext}: a restricted context may |
| 3566 | * disable specific features. For instance, a View associated with a restricted |
| 3567 | * context would ignore particular XML attributes. |
| 3568 | */ |
| 3569 | public static final int CONTEXT_RESTRICTED = 0x00000004; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3570 | |
| 3571 | /** |
Dianne Hackborn | fee756f | 2014-07-16 17:31:10 -0700 | [diff] [blame] | 3572 | * @hide Used to indicate we should tell the activity manager about the process |
| 3573 | * loading this code. |
| 3574 | */ |
| 3575 | public static final int CONTEXT_REGISTER_PACKAGE = 0x40000000; |
| 3576 | |
| 3577 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3578 | * Return a new Context object for the given application name. This |
| 3579 | * Context is the same as what the named application gets when it is |
| 3580 | * launched, containing the same resources and class loader. Each call to |
| 3581 | * this method returns a new instance of a Context object; Context objects |
| 3582 | * are not shared, however they share common state (Resources, ClassLoader, |
| 3583 | * etc) so the Context instance itself is fairly lightweight. |
| 3584 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3585 | * <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] | 3586 | * application with the given package name. |
| 3587 | * |
| 3588 | * <p>Throws {@link java.lang.SecurityException} if the Context requested |
| 3589 | * can not be loaded into the caller's process for security reasons (see |
| 3590 | * {@link #CONTEXT_INCLUDE_CODE} for more information}. |
| 3591 | * |
| 3592 | * @param packageName Name of the application's package. |
| 3593 | * @param flags Option flags, one of {@link #CONTEXT_INCLUDE_CODE} |
| 3594 | * or {@link #CONTEXT_IGNORE_SECURITY}. |
| 3595 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3596 | * @return A {@link Context} for the application. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3597 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3598 | * @throws SecurityException |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3599 | * @throws PackageManager.NameNotFoundException if there is no application with |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3600 | * the given package name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3601 | */ |
| 3602 | public abstract Context createPackageContext(String packageName, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3603 | @CreatePackageOptions int flags) throws PackageManager.NameNotFoundException; |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 3604 | |
| 3605 | /** |
Jeff Sharkey | 6d51571 | 2012-09-20 16:06:08 -0700 | [diff] [blame] | 3606 | * Similar to {@link #createPackageContext(String, int)}, but with a |
| 3607 | * different {@link UserHandle}. For example, {@link #getContentResolver()} |
| 3608 | * will open any {@link Uri} as the given user. |
| 3609 | * |
| 3610 | * @hide |
| 3611 | */ |
| 3612 | public abstract Context createPackageContextAsUser( |
| 3613 | String packageName, int flags, UserHandle user) |
| 3614 | throws PackageManager.NameNotFoundException; |
| 3615 | |
| 3616 | /** |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 3617 | * Creates a context given an {@link android.content.pm.ApplicationInfo}. |
| 3618 | * |
| 3619 | * @hide |
| 3620 | */ |
| 3621 | public abstract Context createApplicationContext(ApplicationInfo application, |
| 3622 | int flags) throws PackageManager.NameNotFoundException; |
| 3623 | |
| 3624 | /** |
Jim Miller | a75a883 | 2013-02-07 16:53:32 -0800 | [diff] [blame] | 3625 | * Get the userId associated with this context |
| 3626 | * @return user id |
| 3627 | * |
| 3628 | * @hide |
| 3629 | */ |
| 3630 | public abstract int getUserId(); |
| 3631 | |
| 3632 | /** |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 3633 | * Return a new Context object for the current Context but whose resources |
| 3634 | * are adjusted to match the given Configuration. Each call to this method |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 3635 | * returns a new instance of a Context object; Context objects are not |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 3636 | * shared, however common state (ClassLoader, other Resources for the |
| 3637 | * same configuration) may be so the Context itself can be fairly lightweight. |
| 3638 | * |
| 3639 | * @param overrideConfiguration A {@link Configuration} specifying what |
| 3640 | * values to modify in the base Configuration of the original Context's |
| 3641 | * resources. If the base configuration changes (such as due to an |
| 3642 | * orientation change), the resources of this context will also change except |
| 3643 | * for those that have been explicitly overridden with a value here. |
| 3644 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3645 | * @return A {@link Context} with the given configuration override. |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 3646 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3647 | public abstract Context createConfigurationContext( |
| 3648 | @NonNull Configuration overrideConfiguration); |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 3649 | |
| 3650 | /** |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 3651 | * Return a new Context object for the current Context but whose resources |
| 3652 | * are adjusted to match the metrics of the given Display. Each call to this method |
| 3653 | * returns a new instance of a Context object; Context objects are not |
| 3654 | * shared, however common state (ClassLoader, other Resources for the |
| 3655 | * same configuration) may be so the Context itself can be fairly lightweight. |
| 3656 | * |
| 3657 | * The returned display Context provides a {@link WindowManager} |
| 3658 | * (see {@link #getSystemService(String)}) that is configured to show windows |
| 3659 | * on the given display. The WindowManager's {@link WindowManager#getDefaultDisplay} |
| 3660 | * method can be used to retrieve the Display from the returned Context. |
| 3661 | * |
| 3662 | * @param display A {@link Display} object specifying the display |
| 3663 | * for whose metrics the Context's resources should be tailored and upon which |
| 3664 | * new windows should be shown. |
| 3665 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3666 | * @return A {@link Context} for the display. |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 3667 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3668 | public abstract Context createDisplayContext(@NonNull Display display); |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 3669 | |
| 3670 | /** |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 3671 | * Gets the display adjustments holder for this context. This information |
| 3672 | * is provided on a per-application or activity basis and is used to simulate lower density |
| 3673 | * display metrics for legacy applications and restricted screen sizes. |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 3674 | * |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 3675 | * @param displayId The display id for which to get compatibility info. |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 3676 | * @return The compatibility info holder, or null if not required by the application. |
| 3677 | * @hide |
| 3678 | */ |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 3679 | public abstract DisplayAdjustments getDisplayAdjustments(int displayId); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 3680 | |
| 3681 | /** |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 3682 | * Indicates whether this Context is restricted. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3683 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3684 | * @return {@code true} if this Context is restricted, {@code false} otherwise. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3685 | * |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 3686 | * @see #CONTEXT_RESTRICTED |
| 3687 | */ |
| 3688 | public boolean isRestricted() { |
| 3689 | return false; |
| 3690 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3691 | } |