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