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 | |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 19 | import android.content.pm.ApplicationInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 20 | import android.content.pm.PackageManager; |
| 21 | import android.content.res.AssetManager; |
| 22 | import android.content.res.Resources; |
| 23 | import android.content.res.TypedArray; |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 24 | import android.database.DatabaseErrorHandler; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 25 | import android.database.sqlite.SQLiteDatabase; |
| 26 | import android.database.sqlite.SQLiteDatabase.CursorFactory; |
| 27 | import android.graphics.Bitmap; |
| 28 | import android.graphics.drawable.Drawable; |
Adam Powell | ac695c6 | 2010-07-20 18:19:27 -0700 | [diff] [blame] | 29 | import android.media.MediaScannerConnection.OnScanCompletedListener; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | import android.net.Uri; |
| 31 | import android.os.Bundle; |
| 32 | import android.os.Handler; |
| 33 | import android.os.Looper; |
| 34 | import android.util.AttributeSet; |
| 35 | |
| 36 | import java.io.File; |
| 37 | import java.io.FileInputStream; |
| 38 | import java.io.FileNotFoundException; |
| 39 | import java.io.FileOutputStream; |
| 40 | import java.io.IOException; |
| 41 | import java.io.InputStream; |
| 42 | |
| 43 | /** |
| 44 | * Interface to global information about an application environment. This is |
| 45 | * an abstract class whose implementation is provided by |
| 46 | * the Android system. It |
| 47 | * allows access to application-specific resources and classes, as well as |
| 48 | * up-calls for application-level operations such as launching activities, |
| 49 | * broadcasting and receiving intents, etc. |
| 50 | */ |
| 51 | public abstract class Context { |
| 52 | /** |
| 53 | * File creation mode: the default mode, where the created file can only |
| 54 | * be accessed by the calling application (or all applications sharing the |
| 55 | * same user ID). |
| 56 | * @see #MODE_WORLD_READABLE |
| 57 | * @see #MODE_WORLD_WRITEABLE |
| 58 | */ |
| 59 | public static final int MODE_PRIVATE = 0x0000; |
| 60 | /** |
| 61 | * File creation mode: allow all other applications to have read access |
| 62 | * to the created file. |
| 63 | * @see #MODE_PRIVATE |
| 64 | * @see #MODE_WORLD_WRITEABLE |
| 65 | */ |
| 66 | public static final int MODE_WORLD_READABLE = 0x0001; |
| 67 | /** |
| 68 | * File creation mode: allow all other applications to have write access |
| 69 | * to the created file. |
| 70 | * @see #MODE_PRIVATE |
| 71 | * @see #MODE_WORLD_READABLE |
| 72 | */ |
| 73 | public static final int MODE_WORLD_WRITEABLE = 0x0002; |
| 74 | /** |
| 75 | * File creation mode: for use with {@link #openFileOutput}, if the file |
| 76 | * already exists then write data to the end of the existing file |
| 77 | * instead of erasing it. |
| 78 | * @see #openFileOutput |
| 79 | */ |
| 80 | public static final int MODE_APPEND = 0x8000; |
| 81 | |
| 82 | /** |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 83 | * SharedPreference loading flag: when set, the file on disk will |
| 84 | * be checked for modification even if the shared preferences |
| 85 | * instance is already loaded in this process. This behavior is |
| 86 | * sometimes desired in cases where the application has multiple |
| 87 | * processes, all writing to the same SharedPreferences file. |
| 88 | * Generally there are better forms of communication between |
| 89 | * processes, though. |
| 90 | * |
| 91 | * <p>This was the legacy (but undocumented) behavior in and |
| 92 | * before Gingerbread (Android 2.3) and this flag is implied when |
| 93 | * targetting such releases. For applications targetting SDK |
| 94 | * versions <em>greater than</em> Android 2.3, this flag must be |
| 95 | * explicitly set if desired. |
| 96 | * |
| 97 | * @see #getSharedPreferences |
| 98 | */ |
| 99 | public static final int MODE_MULTI_PROCESS = 0x0004; |
| 100 | |
| 101 | /** |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 102 | * Database open flag: when set, the database is opened with write-ahead |
| 103 | * logging enabled by default. |
| 104 | * |
| 105 | * @see #openOrCreateDatabase(String, int, CursorFactory) |
| 106 | * @see #openOrCreateDatabase(String, int, CursorFactory, DatabaseErrorHandler) |
| 107 | * @see SQLiteDatabase#enableWriteAheadLogging |
| 108 | */ |
| 109 | public static final int MODE_ENABLE_WRITE_AHEAD_LOGGING = 0x0008; |
| 110 | |
| 111 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 112 | * Flag for {@link #bindService}: automatically create the service as long |
| 113 | * as the binding exists. Note that while this will create the service, |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 114 | * its {@link android.app.Service#onStartCommand} |
| 115 | * method will still only be called due to an |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 116 | * explicit call to {@link #startService}. Even without that, though, |
| 117 | * this still provides you with access to the service object while the |
| 118 | * service is created. |
| 119 | * |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 120 | * <p>Note that prior to {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, |
| 121 | * not supplying this flag would also impact how important the system |
| 122 | * consider's the target service's process to be. When set, the only way |
| 123 | * for it to be raised was by binding from a service in which case it will |
| 124 | * only be important when that activity is in the foreground. Now to |
| 125 | * achieve this behavior you must explicitly supply the new flag |
| 126 | * {@link #BIND_ADJUST_WITH_ACTIVITY}. For compatibility, old applications |
| 127 | * that don't specify {@link #BIND_AUTO_CREATE} will automatically have |
| 128 | * the flags {@link #BIND_WAIVE_PRIORITY} and |
| 129 | * {@link #BIND_ADJUST_WITH_ACTIVITY} set for them in order to achieve |
| 130 | * the same result. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 131 | */ |
| 132 | public static final int BIND_AUTO_CREATE = 0x0001; |
| 133 | |
| 134 | /** |
| 135 | * Flag for {@link #bindService}: include debugging help for mismatched |
| 136 | * calls to unbind. When this flag is set, the callstack of the following |
| 137 | * {@link #unbindService} call is retained, to be printed if a later |
| 138 | * incorrect unbind call is made. Note that doing this requires retaining |
| 139 | * information about the binding that was made for the lifetime of the app, |
| 140 | * resulting in a leak -- this should only be used for debugging. |
| 141 | */ |
| 142 | public static final int BIND_DEBUG_UNBIND = 0x0002; |
| 143 | |
Dianne Hackborn | 09c916b | 2009-12-08 14:50:51 -0800 | [diff] [blame] | 144 | /** |
| 145 | * Flag for {@link #bindService}: don't allow this binding to raise |
| 146 | * the target service's process to the foreground scheduling priority. |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 147 | * It will still be raised to at least the same memory priority |
Dianne Hackborn | 09c916b | 2009-12-08 14:50:51 -0800 | [diff] [blame] | 148 | * as the client (so that its process will not be killable in any |
| 149 | * situation where the client is not killable), but for CPU scheduling |
| 150 | * purposes it may be left in the background. This only has an impact |
| 151 | * in the situation where the binding client is a foreground process |
| 152 | * and the target service is in a background process. |
| 153 | */ |
| 154 | public static final int BIND_NOT_FOREGROUND = 0x0004; |
| 155 | |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 156 | /** |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 157 | * Flag for {@link #bindService}: indicates that the client application |
| 158 | * binding to this service considers the service to be more important than |
| 159 | * the app itself. When set, the platform will try to have the out of |
| 160 | * memory kill the app before it kills the service it is bound to, though |
| 161 | * this is not guaranteed to be the case. |
| 162 | */ |
| 163 | public static final int BIND_ABOVE_CLIENT = 0x0008; |
| 164 | |
| 165 | /** |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 166 | * Flag for {@link #bindService}: allow the process hosting the bound |
| 167 | * service to go through its normal memory management. It will be |
| 168 | * treated more like a running service, allowing the system to |
| 169 | * (temporarily) expunge the process if low on memory or for some other |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 170 | * whim it may have, and being more aggressive about making it a candidate |
| 171 | * to be killed (and restarted) if running for a long time. |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 172 | */ |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 173 | public static final int BIND_ALLOW_OOM_MANAGEMENT = 0x0010; |
| 174 | |
| 175 | /** |
| 176 | * Flag for {@link #bindService}: don't impact the scheduling or |
| 177 | * memory management priority of the target service's hosting process. |
| 178 | * Allows the service's process to be managed on the background LRU list |
| 179 | * just like a regular application process in the background. |
| 180 | */ |
| 181 | public static final int BIND_WAIVE_PRIORITY = 0x0020; |
| 182 | |
| 183 | /** |
| 184 | * Flag for {@link #bindService}: this service is very important to |
| 185 | * the client, so should be brought to the foreground process level |
| 186 | * when the client is. Normally a process can only be raised to the |
| 187 | * visibility level by a client, even if that client is in the foreground. |
| 188 | */ |
| 189 | public static final int BIND_IMPORTANT = 0x0040; |
| 190 | |
| 191 | /** |
| 192 | * Flag for {@link #bindService}: If binding from an activity, allow the |
| 193 | * target service's process importance to be raised based on whether the |
| 194 | * activity is visible to the user, regardless whether another flag is |
| 195 | * used to reduce the amount that the client process's overall importance |
| 196 | * is used to impact it. |
| 197 | */ |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 198 | public static final int BIND_ADJUST_WITH_ACTIVITY = 0x0080; |
| 199 | |
| 200 | /** |
| 201 | * Flag for {@link #bindService}: Don't consider the bound service to be |
| 202 | * visible, even if the caller is visible. |
| 203 | * @hide |
| 204 | */ |
| 205 | public static final int BIND_NOT_VISIBLE = 0x40000000; |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 206 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 207 | /** Return an AssetManager instance for your application's package. */ |
| 208 | public abstract AssetManager getAssets(); |
| 209 | |
| 210 | /** Return a Resources instance for your application's package. */ |
| 211 | public abstract Resources getResources(); |
| 212 | |
| 213 | /** Return PackageManager instance to find global package information. */ |
| 214 | public abstract PackageManager getPackageManager(); |
| 215 | |
| 216 | /** Return a ContentResolver instance for your application's package. */ |
| 217 | public abstract ContentResolver getContentResolver(); |
| 218 | |
| 219 | /** |
| 220 | * Return the Looper for the main thread of the current process. This is |
| 221 | * the thread used to dispatch calls to application components (activities, |
| 222 | * services, etc). |
| 223 | */ |
| 224 | public abstract Looper getMainLooper(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 225 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 226 | /** |
| 227 | * Return the context of the single, global Application object of the |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 228 | * current process. This generally should only be used if you need a |
| 229 | * Context whose lifecycle is separate from the current context, that is |
| 230 | * tied to the lifetime of the process rather than the current component. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 231 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 232 | * <p>Consider for example how this interacts with |
Brad Fitzpatrick | 36af794 | 2010-12-08 11:31:07 -0800 | [diff] [blame] | 233 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter)}: |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 234 | * <ul> |
| 235 | * <li> <p>If used from an Activity context, the receiver is being registered |
| 236 | * within that activity. This means that you are expected to unregister |
| 237 | * before the activity is done being destroyed; in fact if you do not do |
| 238 | * so, the framework will clean up your leaked registration as it removes |
| 239 | * the activity and log an error. Thus, if you use the Activity context |
| 240 | * to register a receiver that is static (global to the process, not |
| 241 | * associated with an Activity instance) then that registration will be |
| 242 | * removed on you at whatever point the activity you used is destroyed. |
| 243 | * <li> <p>If used from the Context returned here, the receiver is being |
| 244 | * registered with the global state associated with your application. Thus |
| 245 | * it will never be unregistered for you. This is necessary if the receiver |
| 246 | * is associated with static data, not a particular component. However |
| 247 | * using the ApplicationContext elsewhere can easily lead to serious leaks |
| 248 | * if you forget to unregister, unbind, etc. |
| 249 | * </ul> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 250 | */ |
| 251 | public abstract Context getApplicationContext(); |
| 252 | |
| 253 | /** |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 254 | * Add a new {@link ComponentCallbacks} to the base application of the |
| 255 | * Context, which will be called at the same times as the ComponentCallbacks |
| 256 | * methods of activities and other components are called. Note that you |
| 257 | * <em>must</em> be sure to use {@link #unregisterComponentCallbacks} when |
| 258 | * appropriate in the future; this will not be removed for you. |
Dianne Hackborn | 905577f | 2011-09-07 18:31:28 -0700 | [diff] [blame] | 259 | * |
| 260 | * @param callback The interface to call. This can be either a |
| 261 | * {@link ComponentCallbacks} or {@link ComponentCallbacks2} interface. |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 262 | */ |
| 263 | public void registerComponentCallbacks(ComponentCallbacks callback) { |
| 264 | getApplicationContext().registerComponentCallbacks(callback); |
| 265 | } |
| 266 | |
| 267 | /** |
| 268 | * Remove a {@link ComponentCallbacks} objec that was previously registered |
| 269 | * with {@link #registerComponentCallbacks(ComponentCallbacks)}. |
| 270 | */ |
| 271 | public void unregisterComponentCallbacks(ComponentCallbacks callback) { |
| 272 | getApplicationContext().unregisterComponentCallbacks(callback); |
| 273 | } |
| 274 | |
| 275 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 276 | * Return a localized, styled CharSequence from the application's package's |
| 277 | * default string table. |
| 278 | * |
| 279 | * @param resId Resource id for the CharSequence text |
| 280 | */ |
| 281 | public final CharSequence getText(int resId) { |
| 282 | return getResources().getText(resId); |
| 283 | } |
| 284 | |
| 285 | /** |
| 286 | * Return a localized string from the application's package's |
| 287 | * default string table. |
| 288 | * |
| 289 | * @param resId Resource id for the string |
| 290 | */ |
| 291 | public final String getString(int resId) { |
| 292 | return getResources().getString(resId); |
| 293 | } |
| 294 | |
| 295 | /** |
| 296 | * Return a localized formatted string from the application's package's |
| 297 | * default string table, substituting the format arguments as defined in |
| 298 | * {@link java.util.Formatter} and {@link java.lang.String#format}. |
| 299 | * |
| 300 | * @param resId Resource id for the format string |
| 301 | * @param formatArgs The format arguments that will be used for substitution. |
| 302 | */ |
| 303 | |
| 304 | public final String getString(int resId, Object... formatArgs) { |
| 305 | return getResources().getString(resId, formatArgs); |
| 306 | } |
| 307 | |
| 308 | /** |
| 309 | * Set the base theme for this context. Note that this should be called |
| 310 | * before any views are instantiated in the Context (for example before |
| 311 | * calling {@link android.app.Activity#setContentView} or |
| 312 | * {@link android.view.LayoutInflater#inflate}). |
| 313 | * |
| 314 | * @param resid The style resource describing the theme. |
| 315 | */ |
| 316 | public abstract void setTheme(int resid); |
| 317 | |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 318 | /** @hide Needed for some internal implementation... not public because |
| 319 | * you can't assume this actually means anything. */ |
| 320 | public int getThemeResId() { |
| 321 | return 0; |
| 322 | } |
| 323 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 324 | /** |
| 325 | * Return the Theme object associated with this Context. |
| 326 | */ |
| 327 | public abstract Resources.Theme getTheme(); |
| 328 | |
| 329 | /** |
| 330 | * Retrieve styled attribute information in this Context's theme. See |
| 331 | * {@link Resources.Theme#obtainStyledAttributes(int[])} |
| 332 | * for more information. |
| 333 | * |
| 334 | * @see Resources.Theme#obtainStyledAttributes(int[]) |
| 335 | */ |
| 336 | public final TypedArray obtainStyledAttributes( |
| 337 | int[] attrs) { |
| 338 | return getTheme().obtainStyledAttributes(attrs); |
| 339 | } |
| 340 | |
| 341 | /** |
| 342 | * Retrieve styled attribute information in this Context's theme. See |
| 343 | * {@link Resources.Theme#obtainStyledAttributes(int, int[])} |
| 344 | * for more information. |
| 345 | * |
| 346 | * @see Resources.Theme#obtainStyledAttributes(int, int[]) |
| 347 | */ |
| 348 | public final TypedArray obtainStyledAttributes( |
| 349 | int resid, int[] attrs) throws Resources.NotFoundException { |
| 350 | return getTheme().obtainStyledAttributes(resid, attrs); |
| 351 | } |
| 352 | |
| 353 | /** |
| 354 | * Retrieve styled attribute information in this Context's theme. See |
| 355 | * {@link Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int)} |
| 356 | * for more information. |
| 357 | * |
| 358 | * @see Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int) |
| 359 | */ |
| 360 | public final TypedArray obtainStyledAttributes( |
| 361 | AttributeSet set, int[] attrs) { |
| 362 | return getTheme().obtainStyledAttributes(set, attrs, 0, 0); |
| 363 | } |
| 364 | |
| 365 | /** |
| 366 | * Retrieve styled attribute information in this Context's theme. See |
| 367 | * {@link Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int)} |
| 368 | * for more information. |
| 369 | * |
| 370 | * @see Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int) |
| 371 | */ |
| 372 | public final TypedArray obtainStyledAttributes( |
| 373 | AttributeSet set, int[] attrs, int defStyleAttr, int defStyleRes) { |
| 374 | return getTheme().obtainStyledAttributes( |
| 375 | set, attrs, defStyleAttr, defStyleRes); |
| 376 | } |
| 377 | |
| 378 | /** |
| 379 | * Return a class loader you can use to retrieve classes in this package. |
| 380 | */ |
| 381 | public abstract ClassLoader getClassLoader(); |
| 382 | |
| 383 | /** Return the name of this application's package. */ |
| 384 | public abstract String getPackageName(); |
| 385 | |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 386 | /** Return the full application info for this context's package. */ |
| 387 | public abstract ApplicationInfo getApplicationInfo(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 388 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 389 | /** |
Kenny Root | 3214839 | 2010-01-21 15:40:47 -0800 | [diff] [blame] | 390 | * Return the full path to this context's primary Android package. |
| 391 | * The Android package is a ZIP file which contains the application's |
| 392 | * primary resources. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 393 | * |
| 394 | * <p>Note: this is not generally useful for applications, since they should |
| 395 | * not be directly accessing the file system. |
| 396 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 397 | * @return String Path to the resources. |
| 398 | */ |
| 399 | public abstract String getPackageResourcePath(); |
| 400 | |
| 401 | /** |
Kenny Root | 3214839 | 2010-01-21 15:40:47 -0800 | [diff] [blame] | 402 | * Return the full path to this context's primary Android package. |
| 403 | * The Android package is a ZIP file which contains application's |
| 404 | * primary code and assets. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 405 | * |
| 406 | * <p>Note: this is not generally useful for applications, since they should |
| 407 | * not be directly accessing the file system. |
| 408 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 409 | * @return String Path to the code and assets. |
| 410 | */ |
| 411 | public abstract String getPackageCodePath(); |
| 412 | |
| 413 | /** |
Joe Onorato | 23ecae3 | 2009-06-10 17:07:15 -0700 | [diff] [blame] | 414 | * {@hide} |
| 415 | * Return the full path to the shared prefs file for the given prefs group name. |
| 416 | * |
| 417 | * <p>Note: this is not generally useful for applications, since they should |
| 418 | * not be directly accessing the file system. |
| 419 | */ |
| 420 | public abstract File getSharedPrefsFile(String name); |
| 421 | |
| 422 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 423 | * Retrieve and hold the contents of the preferences file 'name', returning |
| 424 | * a SharedPreferences through which you can retrieve and modify its |
| 425 | * values. Only one instance of the SharedPreferences object is returned |
| 426 | * to any callers for the same name, meaning they will see each other's |
| 427 | * edits as soon as they are made. |
| 428 | * |
| 429 | * @param name Desired preferences file. If a preferences file by this name |
| 430 | * does not exist, it will be created when you retrieve an |
| 431 | * editor (SharedPreferences.edit()) and then commit changes (Editor.commit()). |
| 432 | * @param mode Operating mode. Use 0 or {@link #MODE_PRIVATE} for the |
| 433 | * default operation, {@link #MODE_WORLD_READABLE} |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 434 | * and {@link #MODE_WORLD_WRITEABLE} to control permissions. The bit |
| 435 | * {@link #MODE_MULTI_PROCESS} can also be used if multiple processes |
| 436 | * are mutating the same SharedPreferences file. {@link #MODE_MULTI_PROCESS} |
| 437 | * is always on in apps targetting Gingerbread (Android 2.3) and below, and |
| 438 | * off by default in later versions. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 439 | * |
| 440 | * @return Returns the single SharedPreferences instance that can be used |
| 441 | * to retrieve and modify the preference values. |
| 442 | * |
| 443 | * @see #MODE_PRIVATE |
| 444 | * @see #MODE_WORLD_READABLE |
| 445 | * @see #MODE_WORLD_WRITEABLE |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 446 | * @see #MODE_MULTI_PROCESS |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 447 | */ |
| 448 | public abstract SharedPreferences getSharedPreferences(String name, |
| 449 | int mode); |
| 450 | |
| 451 | /** |
| 452 | * Open a private file associated with this Context's application package |
| 453 | * for reading. |
| 454 | * |
| 455 | * @param name The name of the file to open; can not contain path |
| 456 | * separators. |
| 457 | * |
| 458 | * @return FileInputStream Resulting input stream. |
| 459 | * |
| 460 | * @see #openFileOutput |
| 461 | * @see #fileList |
| 462 | * @see #deleteFile |
| 463 | * @see java.io.FileInputStream#FileInputStream(String) |
| 464 | */ |
| 465 | public abstract FileInputStream openFileInput(String name) |
| 466 | throws FileNotFoundException; |
| 467 | |
| 468 | /** |
| 469 | * Open a private file associated with this Context's application package |
| 470 | * for writing. Creates the file if it doesn't already exist. |
| 471 | * |
| 472 | * @param name The name of the file to open; can not contain path |
| 473 | * separators. |
| 474 | * @param mode Operating mode. Use 0 or {@link #MODE_PRIVATE} for the |
| 475 | * default operation, {@link #MODE_APPEND} to append to an existing file, |
| 476 | * {@link #MODE_WORLD_READABLE} and {@link #MODE_WORLD_WRITEABLE} to control |
| 477 | * permissions. |
| 478 | * |
| 479 | * @return FileOutputStream Resulting output stream. |
| 480 | * |
| 481 | * @see #MODE_APPEND |
| 482 | * @see #MODE_PRIVATE |
| 483 | * @see #MODE_WORLD_READABLE |
| 484 | * @see #MODE_WORLD_WRITEABLE |
| 485 | * @see #openFileInput |
| 486 | * @see #fileList |
| 487 | * @see #deleteFile |
| 488 | * @see java.io.FileOutputStream#FileOutputStream(String) |
| 489 | */ |
| 490 | public abstract FileOutputStream openFileOutput(String name, int mode) |
| 491 | throws FileNotFoundException; |
| 492 | |
| 493 | /** |
| 494 | * Delete the given private file associated with this Context's |
| 495 | * application package. |
| 496 | * |
| 497 | * @param name The name of the file to delete; can not contain path |
| 498 | * separators. |
| 499 | * |
| 500 | * @return True if the file was successfully deleted; else |
| 501 | * false. |
| 502 | * |
| 503 | * @see #openFileInput |
| 504 | * @see #openFileOutput |
| 505 | * @see #fileList |
| 506 | * @see java.io.File#delete() |
| 507 | */ |
| 508 | public abstract boolean deleteFile(String name); |
| 509 | |
| 510 | /** |
| 511 | * Returns the absolute path on the filesystem where a file created with |
| 512 | * {@link #openFileOutput} is stored. |
| 513 | * |
| 514 | * @param name The name of the file for which you would like to get |
| 515 | * its path. |
| 516 | * |
| 517 | * @return Returns an absolute path to the given file. |
| 518 | * |
| 519 | * @see #openFileOutput |
| 520 | * @see #getFilesDir |
| 521 | * @see #getDir |
| 522 | */ |
| 523 | public abstract File getFileStreamPath(String name); |
| 524 | |
| 525 | /** |
| 526 | * Returns the absolute path to the directory on the filesystem where |
| 527 | * files created with {@link #openFileOutput} are stored. |
| 528 | * |
| 529 | * @return Returns the path of the directory holding application files. |
| 530 | * |
| 531 | * @see #openFileOutput |
| 532 | * @see #getFileStreamPath |
| 533 | * @see #getDir |
| 534 | */ |
| 535 | public abstract File getFilesDir(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 536 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 537 | /** |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 538 | * Returns the absolute path to the directory on the external filesystem |
| 539 | * (that is somewhere on {@link android.os.Environment#getExternalStorageDirectory() |
Dianne Hackborn | acaf028 | 2010-03-30 14:39:35 -0700 | [diff] [blame] | 540 | * Environment.getExternalStorageDirectory()}) where the application can |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 541 | * place persistent files it owns. These files are private to the |
| 542 | * applications, and not typically visible to the user as media. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 543 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 544 | * <p>This is like {@link #getFilesDir()} in that these |
| 545 | * files will be deleted when the application is uninstalled, however there |
| 546 | * are some important differences: |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 547 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 548 | * <ul> |
| 549 | * <li>External files are not always available: they will disappear if the |
| 550 | * user mounts the external storage on a computer or removes it. See the |
| 551 | * APIs on {@link android.os.Environment} for information in the storage state. |
| 552 | * <li>There is no security enforced with these files. All applications |
| 553 | * can read and write files placed here. |
| 554 | * </ul> |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 555 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 556 | * <p>Here is an example of typical code to manipulate a file in |
| 557 | * an application's private storage:</p> |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 558 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 559 | * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java |
| 560 | * private_file} |
| 561 | * |
Dianne Hackborn | acaf028 | 2010-03-30 14:39:35 -0700 | [diff] [blame] | 562 | * <p>If you supply a non-null <var>type</var> to this function, the returned |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 563 | * file will be a path to a sub-directory of the given type. Though these files |
| 564 | * are not automatically scanned by the media scanner, you can explicitly |
| 565 | * add them to the media database with |
| 566 | * {@link android.media.MediaScannerConnection#scanFile(Context, String[], String[], |
Ray Chen | b7c8c76 | 2010-03-30 17:21:39 -0700 | [diff] [blame] | 567 | * OnScanCompletedListener) MediaScannerConnection.scanFile}. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 568 | * Note that this is not the same as |
| 569 | * {@link android.os.Environment#getExternalStoragePublicDirectory |
| 570 | * Environment.getExternalStoragePublicDirectory()}, which provides |
| 571 | * directories of media shared by all applications. The |
| 572 | * directories returned here are |
Dianne Hackborn | acaf028 | 2010-03-30 14:39:35 -0700 | [diff] [blame] | 573 | * owned by the application, and their contents will be removed when the |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 574 | * application is uninstalled. Unlike |
| 575 | * {@link android.os.Environment#getExternalStoragePublicDirectory |
| 576 | * Environment.getExternalStoragePublicDirectory()}, the directory |
| 577 | * returned here will be automatically created for you. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 578 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 579 | * <p>Here is an example of typical code to manipulate a picture in |
| 580 | * an application's private storage and add it to the media database:</p> |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 581 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 582 | * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java |
| 583 | * private_picture} |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 584 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 585 | * @param type The type of files directory to return. May be null for |
| 586 | * the root of the files directory or one of |
| 587 | * the following Environment constants for a subdirectory: |
| 588 | * {@link android.os.Environment#DIRECTORY_MUSIC}, |
| 589 | * {@link android.os.Environment#DIRECTORY_PODCASTS}, |
| 590 | * {@link android.os.Environment#DIRECTORY_RINGTONES}, |
| 591 | * {@link android.os.Environment#DIRECTORY_ALARMS}, |
| 592 | * {@link android.os.Environment#DIRECTORY_NOTIFICATIONS}, |
| 593 | * {@link android.os.Environment#DIRECTORY_PICTURES}, or |
| 594 | * {@link android.os.Environment#DIRECTORY_MOVIES}. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 595 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 596 | * @return Returns the path of the directory holding application files |
| 597 | * on external storage. Returns null if external storage is not currently |
| 598 | * mounted so it could not ensure the path exists; you will need to call |
| 599 | * this method again when it is available. |
| 600 | * |
| 601 | * @see #getFilesDir |
Dianne Hackborn | acaf028 | 2010-03-30 14:39:35 -0700 | [diff] [blame] | 602 | * @see android.os.Environment#getExternalStoragePublicDirectory |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 603 | */ |
| 604 | public abstract File getExternalFilesDir(String type); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 605 | |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 606 | /** |
Dianne Hackborn | 805fd7e | 2011-01-16 18:30:29 -0800 | [diff] [blame] | 607 | * Return the directory where this application's OBB files (if there |
| 608 | * are any) can be found. Note if the application does not have any OBB |
| 609 | * files, this directory may not exist. |
| 610 | */ |
| 611 | public abstract File getObbDir(); |
| 612 | |
| 613 | /** |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 614 | * Returns the absolute path to the application specific cache directory |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 615 | * on the filesystem. These files will be ones that get deleted first when the |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 616 | * device runs low on storage. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 617 | * There is no guarantee when these files will be deleted. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 618 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 619 | * <strong>Note: you should not <em>rely</em> on the system deleting these |
| 620 | * files for you; you should always have a reasonable maximum, such as 1 MB, |
| 621 | * for the amount of space you consume with cache files, and prune those |
| 622 | * files when exceeding that space.</strong> |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 623 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 624 | * @return Returns the path of the directory holding application cache files. |
| 625 | * |
| 626 | * @see #openFileOutput |
| 627 | * @see #getFileStreamPath |
| 628 | * @see #getDir |
| 629 | */ |
| 630 | public abstract File getCacheDir(); |
| 631 | |
| 632 | /** |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 633 | * Returns the absolute path to the directory on the external filesystem |
| 634 | * (that is somewhere on {@link android.os.Environment#getExternalStorageDirectory() |
| 635 | * Environment.getExternalStorageDirectory()} where the application can |
| 636 | * place cache files it owns. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 637 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 638 | * <p>This is like {@link #getCacheDir()} in that these |
| 639 | * files will be deleted when the application is uninstalled, however there |
| 640 | * are some important differences: |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 641 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 642 | * <ul> |
| 643 | * <li>The platform does not monitor the space available in external storage, |
| 644 | * and thus will not automatically delete these files. Note that you should |
| 645 | * be managing the maximum space you will use for these anyway, just like |
| 646 | * with {@link #getCacheDir()}. |
| 647 | * <li>External files are not always available: they will disappear if the |
| 648 | * user mounts the external storage on a computer or removes it. See the |
| 649 | * APIs on {@link android.os.Environment} for information in the storage state. |
| 650 | * <li>There is no security enforced with these files. All applications |
| 651 | * can read and write files placed here. |
| 652 | * </ul> |
| 653 | * |
| 654 | * @return Returns the path of the directory holding application cache files |
| 655 | * on external storage. Returns null if external storage is not currently |
| 656 | * mounted so it could not ensure the path exists; you will need to call |
| 657 | * this method again when it is available. |
| 658 | * |
| 659 | * @see #getCacheDir |
| 660 | */ |
| 661 | public abstract File getExternalCacheDir(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 662 | |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 663 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 664 | * Returns an array of strings naming the private files associated with |
| 665 | * this Context's application package. |
| 666 | * |
| 667 | * @return Array of strings naming the private files. |
| 668 | * |
| 669 | * @see #openFileInput |
| 670 | * @see #openFileOutput |
| 671 | * @see #deleteFile |
| 672 | */ |
| 673 | public abstract String[] fileList(); |
| 674 | |
| 675 | /** |
| 676 | * Retrieve, creating if needed, a new directory in which the application |
| 677 | * can place its own custom data files. You can use the returned File |
| 678 | * object to create and access files in this directory. Note that files |
| 679 | * created through a File object will only be accessible by your own |
| 680 | * application; you can only set the mode of the entire directory, not |
| 681 | * of individual files. |
| 682 | * |
| 683 | * @param name Name of the directory to retrieve. This is a directory |
| 684 | * that is created as part of your application data. |
| 685 | * @param mode Operating mode. Use 0 or {@link #MODE_PRIVATE} for the |
| 686 | * default operation, {@link #MODE_WORLD_READABLE} and |
| 687 | * {@link #MODE_WORLD_WRITEABLE} to control permissions. |
| 688 | * |
| 689 | * @return Returns a File object for the requested directory. The directory |
| 690 | * will have been created if it does not already exist. |
| 691 | * |
| 692 | * @see #openFileOutput(String, int) |
| 693 | */ |
| 694 | public abstract File getDir(String name, int mode); |
| 695 | |
| 696 | /** |
| 697 | * Open a new private SQLiteDatabase associated with this Context's |
| 698 | * application package. Create the database file if it doesn't exist. |
| 699 | * |
| 700 | * @param name The name (unique in the application package) of the database. |
| 701 | * @param mode Operating mode. Use 0 or {@link #MODE_PRIVATE} for the |
| 702 | * default operation, {@link #MODE_WORLD_READABLE} |
| 703 | * and {@link #MODE_WORLD_WRITEABLE} to control permissions. |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 704 | * Use {@link #MODE_ENABLE_WRITE_AHEAD_LOGGING} to enable write-ahead logging by default. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 705 | * @param factory An optional factory class that is called to instantiate a |
| 706 | * cursor when query is called. |
| 707 | * |
| 708 | * @return The contents of a newly created database with the given name. |
| 709 | * @throws android.database.sqlite.SQLiteException if the database file could not be opened. |
| 710 | * |
| 711 | * @see #MODE_PRIVATE |
| 712 | * @see #MODE_WORLD_READABLE |
| 713 | * @see #MODE_WORLD_WRITEABLE |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 714 | * @see #MODE_ENABLE_WRITE_AHEAD_LOGGING |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 715 | * @see #deleteDatabase |
| 716 | */ |
| 717 | public abstract SQLiteDatabase openOrCreateDatabase(String name, |
| 718 | int mode, CursorFactory factory); |
| 719 | |
| 720 | /** |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 721 | * Open a new private SQLiteDatabase associated with this Context's |
| 722 | * application package. Creates the database file if it doesn't exist. |
| 723 | * |
| 724 | * <p>Accepts input param: a concrete instance of {@link DatabaseErrorHandler} to be |
| 725 | * used to handle corruption when sqlite reports database corruption.</p> |
| 726 | * |
| 727 | * @param name The name (unique in the application package) of the database. |
| 728 | * @param mode Operating mode. Use 0 or {@link #MODE_PRIVATE} for the |
| 729 | * default operation, {@link #MODE_WORLD_READABLE} |
| 730 | * and {@link #MODE_WORLD_WRITEABLE} to control permissions. |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 731 | * Use {@link #MODE_ENABLE_WRITE_AHEAD_LOGGING} to enable write-ahead logging by default. |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 732 | * @param factory An optional factory class that is called to instantiate a |
| 733 | * cursor when query is called. |
| 734 | * @param errorHandler the {@link DatabaseErrorHandler} to be used when sqlite reports database |
Vasu Nori | 03acd51 | 2010-06-03 14:39:40 -0700 | [diff] [blame] | 735 | * corruption. if null, {@link android.database.DefaultDatabaseErrorHandler} is assumed. |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 736 | * @return The contents of a newly created database with the given name. |
| 737 | * @throws android.database.sqlite.SQLiteException if the database file could not be opened. |
| 738 | * |
| 739 | * @see #MODE_PRIVATE |
| 740 | * @see #MODE_WORLD_READABLE |
| 741 | * @see #MODE_WORLD_WRITEABLE |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 742 | * @see #MODE_ENABLE_WRITE_AHEAD_LOGGING |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 743 | * @see #deleteDatabase |
| 744 | */ |
| 745 | public abstract SQLiteDatabase openOrCreateDatabase(String name, |
| 746 | int mode, CursorFactory factory, DatabaseErrorHandler errorHandler); |
| 747 | |
| 748 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 749 | * Delete an existing private SQLiteDatabase associated with this Context's |
| 750 | * application package. |
| 751 | * |
| 752 | * @param name The name (unique in the application package) of the |
| 753 | * database. |
| 754 | * |
| 755 | * @return True if the database was successfully deleted; else false. |
| 756 | * |
| 757 | * @see #openOrCreateDatabase |
| 758 | */ |
| 759 | public abstract boolean deleteDatabase(String name); |
| 760 | |
| 761 | /** |
| 762 | * Returns the absolute path on the filesystem where a database created with |
| 763 | * {@link #openOrCreateDatabase} is stored. |
| 764 | * |
| 765 | * @param name The name of the database for which you would like to get |
| 766 | * its path. |
| 767 | * |
| 768 | * @return Returns an absolute path to the given database. |
| 769 | * |
| 770 | * @see #openOrCreateDatabase |
| 771 | */ |
| 772 | public abstract File getDatabasePath(String name); |
| 773 | |
| 774 | /** |
| 775 | * Returns an array of strings naming the private databases associated with |
| 776 | * this Context's application package. |
| 777 | * |
| 778 | * @return Array of strings naming the private databases. |
| 779 | * |
| 780 | * @see #openOrCreateDatabase |
| 781 | * @see #deleteDatabase |
| 782 | */ |
| 783 | public abstract String[] databaseList(); |
| 784 | |
| 785 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 786 | * @deprecated Use {@link android.app.WallpaperManager#getDrawable |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 787 | * WallpaperManager.get()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 788 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 789 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 790 | public abstract Drawable getWallpaper(); |
| 791 | |
| 792 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 793 | * @deprecated Use {@link android.app.WallpaperManager#peekDrawable |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 794 | * WallpaperManager.peek()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 795 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 796 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 797 | public abstract Drawable peekWallpaper(); |
| 798 | |
| 799 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 800 | * @deprecated Use {@link android.app.WallpaperManager#getDesiredMinimumWidth() |
| 801 | * WallpaperManager.getDesiredMinimumWidth()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 802 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 803 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 804 | public abstract int getWallpaperDesiredMinimumWidth(); |
| 805 | |
| 806 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 807 | * @deprecated Use {@link android.app.WallpaperManager#getDesiredMinimumHeight() |
| 808 | * WallpaperManager.getDesiredMinimumHeight()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 809 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 810 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 811 | public abstract int getWallpaperDesiredMinimumHeight(); |
| 812 | |
| 813 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 814 | * @deprecated Use {@link android.app.WallpaperManager#setBitmap(Bitmap) |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 815 | * WallpaperManager.set()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 816 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 817 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 818 | public abstract void setWallpaper(Bitmap bitmap) throws IOException; |
| 819 | |
| 820 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 821 | * @deprecated Use {@link android.app.WallpaperManager#setStream(InputStream) |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 822 | * WallpaperManager.set()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 823 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 824 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 825 | public abstract void setWallpaper(InputStream data) throws IOException; |
| 826 | |
| 827 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 828 | * @deprecated Use {@link android.app.WallpaperManager#clear |
| 829 | * WallpaperManager.clear()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 830 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 831 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 832 | public abstract void clearWallpaper() throws IOException; |
| 833 | |
| 834 | /** |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 835 | * Same as {@link #startActivity(Intent, Bundle)} with no options |
| 836 | * specified. |
| 837 | * |
| 838 | * @param intent The description of the activity to start. |
| 839 | * |
| 840 | * @throws ActivityNotFoundException |
| 841 | * |
| 842 | * @see {@link #startActivity(Intent, Bundle)} |
| 843 | * @see PackageManager#resolveActivity |
| 844 | */ |
| 845 | public abstract void startActivity(Intent intent); |
| 846 | |
| 847 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 848 | * Launch a new activity. You will not receive any information about when |
| 849 | * the activity exits. |
| 850 | * |
| 851 | * <p>Note that if this method is being called from outside of an |
| 852 | * {@link android.app.Activity} Context, then the Intent must include |
| 853 | * the {@link Intent#FLAG_ACTIVITY_NEW_TASK} launch flag. This is because, |
| 854 | * without being started from an existing Activity, there is no existing |
| 855 | * task in which to place the new activity and thus it needs to be placed |
| 856 | * in its own separate task. |
| 857 | * |
| 858 | * <p>This method throws {@link ActivityNotFoundException} |
| 859 | * if there was no Activity found to run the given Intent. |
| 860 | * |
| 861 | * @param intent The description of the activity to start. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 862 | * @param options Additional options for how the Activity should be started. |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 863 | * May be null if there are no options. See {@link android.app.ActivityOptions} |
| 864 | * for how to build the Bundle supplied here; there are no supported definitions |
| 865 | * for building it manually. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 866 | * |
| 867 | * @throws ActivityNotFoundException |
| 868 | * |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 869 | * @see {@link #startActivity(Intent)} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 870 | * @see PackageManager#resolveActivity |
| 871 | */ |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 872 | public abstract void startActivity(Intent intent, Bundle options); |
| 873 | |
| 874 | /** |
| 875 | * Same as {@link #startActivities(Intent[], Bundle)} with no options |
| 876 | * specified. |
| 877 | * |
| 878 | * @param intents An array of Intents to be started. |
| 879 | * |
| 880 | * @throws ActivityNotFoundException |
| 881 | * |
| 882 | * @see {@link #startActivities(Intent[], Bundle)} |
| 883 | * @see PackageManager#resolveActivity |
| 884 | */ |
| 885 | public abstract void startActivities(Intent[] intents); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 886 | |
| 887 | /** |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 888 | * Launch multiple new activities. This is generally the same as calling |
| 889 | * {@link #startActivity(Intent)} for the first Intent in the array, |
| 890 | * that activity during its creation calling {@link #startActivity(Intent)} |
| 891 | * for the second entry, etc. Note that unlike that approach, generally |
| 892 | * none of the activities except the last in the array will be created |
| 893 | * at this point, but rather will be created when the user first visits |
| 894 | * them (due to pressing back from the activity on top). |
| 895 | * |
| 896 | * <p>This method throws {@link ActivityNotFoundException} |
| 897 | * if there was no Activity found for <em>any</em> given Intent. In this |
| 898 | * case the state of the activity stack is undefined (some Intents in the |
| 899 | * list may be on it, some not), so you probably want to avoid such situations. |
| 900 | * |
| 901 | * @param intents An array of Intents to be started. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 902 | * @param options Additional options for how the Activity should be started. |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 903 | * See {@link android.content.Context#startActivity(Intent, Bundle) |
| 904 | * Context.startActivity(Intent, Bundle)} for more details. |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 905 | * |
| 906 | * @throws ActivityNotFoundException |
| 907 | * |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 908 | * @see {@link #startActivities(Intent[])} |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 909 | * @see PackageManager#resolveActivity |
| 910 | */ |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 911 | public abstract void startActivities(Intent[] intents, Bundle options); |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 912 | |
| 913 | /** |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 914 | * Same as {@link #startIntentSender(IntentSender, Intent, int, int, int, Bundle)} |
| 915 | * with no options specified. |
| 916 | * |
| 917 | * @param intent The IntentSender to launch. |
| 918 | * @param fillInIntent If non-null, this will be provided as the |
| 919 | * intent parameter to {@link IntentSender#sendIntent}. |
| 920 | * @param flagsMask Intent flags in the original IntentSender that you |
| 921 | * would like to change. |
| 922 | * @param flagsValues Desired values for any bits set in |
| 923 | * <var>flagsMask</var> |
| 924 | * @param extraFlags Always set to 0. |
| 925 | * |
| 926 | * @see #startActivity(Intent) |
| 927 | * @see #startIntentSender(IntentSender, Intent, int, int, int, Bundle) |
| 928 | */ |
| 929 | public abstract void startIntentSender(IntentSender intent, |
| 930 | Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags) |
| 931 | throws IntentSender.SendIntentException; |
| 932 | |
| 933 | /** |
| 934 | * Like {@link #startActivity(Intent, Bundle)}, but taking a IntentSender |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 935 | * 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] | 936 | * as if you had called the regular {@link #startActivity(Intent)} |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 937 | * here; otherwise, its associated action will be executed (such as |
| 938 | * sending a broadcast) as if you had called |
| 939 | * {@link IntentSender#sendIntent IntentSender.sendIntent} on it. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 940 | * |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 941 | * @param intent The IntentSender to launch. |
| 942 | * @param fillInIntent If non-null, this will be provided as the |
| 943 | * intent parameter to {@link IntentSender#sendIntent}. |
| 944 | * @param flagsMask Intent flags in the original IntentSender that you |
| 945 | * would like to change. |
| 946 | * @param flagsValues Desired values for any bits set in |
| 947 | * <var>flagsMask</var> |
| 948 | * @param extraFlags Always set to 0. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 949 | * @param options Additional options for how the Activity should be started. |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 950 | * See {@link android.content.Context#startActivity(Intent, Bundle) |
| 951 | * Context.startActivity(Intent, Bundle)} for more details. If options |
| 952 | * have also been supplied by the IntentSender, options given here will |
| 953 | * override any that conflict with those given by the IntentSender. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 954 | * |
| 955 | * @see #startActivity(Intent, Bundle) |
| 956 | * @see #startIntentSender(IntentSender, Intent, int, int, int) |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 957 | */ |
| 958 | public abstract void startIntentSender(IntentSender intent, |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 959 | Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags, |
| 960 | Bundle options) throws IntentSender.SendIntentException; |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 961 | |
| 962 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 963 | * Broadcast the given intent to all interested BroadcastReceivers. This |
| 964 | * call is asynchronous; it returns immediately, and you will continue |
| 965 | * executing while the receivers are run. No results are propagated from |
| 966 | * receivers and receivers can not abort the broadcast. If you want |
| 967 | * to allow receivers to propagate results or abort the broadcast, you must |
| 968 | * send an ordered broadcast using |
| 969 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 970 | * |
| 971 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 972 | * |
| 973 | * @param intent The Intent to broadcast; all receivers matching this |
| 974 | * Intent will receive the broadcast. |
| 975 | * |
| 976 | * @see android.content.BroadcastReceiver |
| 977 | * @see #registerReceiver |
| 978 | * @see #sendBroadcast(Intent, String) |
| 979 | * @see #sendOrderedBroadcast(Intent, String) |
| 980 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 981 | */ |
| 982 | public abstract void sendBroadcast(Intent intent); |
| 983 | |
| 984 | /** |
Amith Yamasani | 67cf7d3 | 2012-02-16 14:31:23 -0800 | [diff] [blame] | 985 | * Same as #sendBroadcast(Intent intent), but for a specific user. Used by the system only. |
| 986 | * @param intent the intent to broadcast |
| 987 | * @param userId user to send the intent to |
| 988 | * @hide |
| 989 | */ |
| 990 | public void sendBroadcast(Intent intent, int userId) { |
| 991 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 992 | } |
| 993 | |
| 994 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 995 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
| 996 | * an optional required permission to be enforced. This |
| 997 | * call is asynchronous; it returns immediately, and you will continue |
| 998 | * executing while the receivers are run. No results are propagated from |
| 999 | * receivers and receivers can not abort the broadcast. If you want |
| 1000 | * to allow receivers to propagate results or abort the broadcast, you must |
| 1001 | * send an ordered broadcast using |
| 1002 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 1003 | * |
| 1004 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1005 | * |
| 1006 | * @param intent The Intent to broadcast; all receivers matching this |
| 1007 | * Intent will receive the broadcast. |
Brad Fitzpatrick | 26b71be | 2010-12-07 14:52:58 -0800 | [diff] [blame] | 1008 | * @param receiverPermission (optional) String naming a permission that |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1009 | * a receiver must hold in order to receive your broadcast. |
| 1010 | * If null, no permission is required. |
| 1011 | * |
| 1012 | * @see android.content.BroadcastReceiver |
| 1013 | * @see #registerReceiver |
| 1014 | * @see #sendBroadcast(Intent) |
| 1015 | * @see #sendOrderedBroadcast(Intent, String) |
| 1016 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 1017 | */ |
| 1018 | public abstract void sendBroadcast(Intent intent, |
| 1019 | String receiverPermission); |
| 1020 | |
| 1021 | /** |
| 1022 | * Broadcast the given intent to all interested BroadcastReceivers, delivering |
| 1023 | * them one at a time to allow more preferred receivers to consume the |
| 1024 | * broadcast before it is delivered to less preferred receivers. This |
| 1025 | * call is asynchronous; it returns immediately, and you will continue |
| 1026 | * executing while the receivers are run. |
| 1027 | * |
| 1028 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1029 | * |
| 1030 | * @param intent The Intent to broadcast; all receivers matching this |
| 1031 | * Intent will receive the broadcast. |
| 1032 | * @param receiverPermission (optional) String naming a permissions that |
| 1033 | * a receiver must hold in order to receive your broadcast. |
| 1034 | * If null, no permission is required. |
| 1035 | * |
| 1036 | * @see android.content.BroadcastReceiver |
| 1037 | * @see #registerReceiver |
| 1038 | * @see #sendBroadcast(Intent) |
| 1039 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 1040 | */ |
| 1041 | public abstract void sendOrderedBroadcast(Intent intent, |
| 1042 | String receiverPermission); |
| 1043 | |
| 1044 | /** |
| 1045 | * Version of {@link #sendBroadcast(Intent)} that allows you to |
| 1046 | * receive data back from the broadcast. This is accomplished by |
| 1047 | * supplying your own BroadcastReceiver when calling, which will be |
| 1048 | * treated as a final receiver at the end of the broadcast -- its |
| 1049 | * {@link BroadcastReceiver#onReceive} method will be called with |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 1050 | * 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] | 1051 | * be serialized in the same way as calling |
| 1052 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 1053 | * |
| 1054 | * <p>Like {@link #sendBroadcast(Intent)}, this method is |
| 1055 | * asynchronous; it will return before |
| 1056 | * resultReceiver.onReceive() is called. |
| 1057 | * |
| 1058 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1059 | * |
| 1060 | * @param intent The Intent to broadcast; all receivers matching this |
| 1061 | * Intent will receive the broadcast. |
| 1062 | * @param receiverPermission String naming a permissions that |
| 1063 | * a receiver must hold in order to receive your broadcast. |
| 1064 | * If null, no permission is required. |
| 1065 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 1066 | * receiver of the broadcast. |
| 1067 | * @param scheduler A custom Handler with which to schedule the |
| 1068 | * resultReceiver callback; if null it will be |
| 1069 | * scheduled in the Context's main thread. |
| 1070 | * @param initialCode An initial value for the result code. Often |
| 1071 | * Activity.RESULT_OK. |
| 1072 | * @param initialData An initial value for the result data. Often |
| 1073 | * null. |
| 1074 | * @param initialExtras An initial value for the result extras. Often |
| 1075 | * null. |
| 1076 | * |
| 1077 | * @see #sendBroadcast(Intent) |
| 1078 | * @see #sendBroadcast(Intent, String) |
| 1079 | * @see #sendOrderedBroadcast(Intent, String) |
| 1080 | * @see #sendStickyBroadcast(Intent) |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 1081 | * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1082 | * @see android.content.BroadcastReceiver |
| 1083 | * @see #registerReceiver |
| 1084 | * @see android.app.Activity#RESULT_OK |
| 1085 | */ |
| 1086 | public abstract void sendOrderedBroadcast(Intent intent, |
| 1087 | String receiverPermission, BroadcastReceiver resultReceiver, |
| 1088 | Handler scheduler, int initialCode, String initialData, |
| 1089 | Bundle initialExtras); |
| 1090 | |
| 1091 | /** |
| 1092 | * Perform a {@link #sendBroadcast(Intent)} that is "sticky," meaning the |
| 1093 | * Intent you are sending stays around after the broadcast is complete, |
| 1094 | * so that others can quickly retrieve that data through the return |
| 1095 | * value of {@link #registerReceiver(BroadcastReceiver, IntentFilter)}. In |
| 1096 | * all other ways, this behaves the same as |
| 1097 | * {@link #sendBroadcast(Intent)}. |
| 1098 | * |
| 1099 | * <p>You must hold the {@link android.Manifest.permission#BROADCAST_STICKY} |
| 1100 | * permission in order to use this API. If you do not hold that |
| 1101 | * permission, {@link SecurityException} will be thrown. |
| 1102 | * |
| 1103 | * @param intent The Intent to broadcast; all receivers matching this |
| 1104 | * Intent will receive the broadcast, and the Intent will be held to |
| 1105 | * be re-broadcast to future receivers. |
| 1106 | * |
| 1107 | * @see #sendBroadcast(Intent) |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 1108 | * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1109 | */ |
| 1110 | public abstract void sendStickyBroadcast(Intent intent); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1111 | |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 1112 | /** |
| 1113 | * Version of {@link #sendStickyBroadcast} that allows you to |
| 1114 | * receive data back from the broadcast. This is accomplished by |
| 1115 | * supplying your own BroadcastReceiver when calling, which will be |
| 1116 | * treated as a final receiver at the end of the broadcast -- its |
| 1117 | * {@link BroadcastReceiver#onReceive} method will be called with |
| 1118 | * the result values collected from the other receivers. The broadcast will |
| 1119 | * be serialized in the same way as calling |
| 1120 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 1121 | * |
| 1122 | * <p>Like {@link #sendBroadcast(Intent)}, this method is |
| 1123 | * asynchronous; it will return before |
| 1124 | * resultReceiver.onReceive() is called. Note that the sticky data |
| 1125 | * stored is only the data you initially supply to the broadcast, not |
| 1126 | * the result of any changes made by the receivers. |
| 1127 | * |
| 1128 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1129 | * |
| 1130 | * @param intent The Intent to broadcast; all receivers matching this |
| 1131 | * Intent will receive the broadcast. |
| 1132 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 1133 | * receiver of the broadcast. |
| 1134 | * @param scheduler A custom Handler with which to schedule the |
| 1135 | * resultReceiver callback; if null it will be |
| 1136 | * scheduled in the Context's main thread. |
| 1137 | * @param initialCode An initial value for the result code. Often |
| 1138 | * Activity.RESULT_OK. |
| 1139 | * @param initialData An initial value for the result data. Often |
| 1140 | * null. |
| 1141 | * @param initialExtras An initial value for the result extras. Often |
| 1142 | * null. |
| 1143 | * |
| 1144 | * @see #sendBroadcast(Intent) |
| 1145 | * @see #sendBroadcast(Intent, String) |
| 1146 | * @see #sendOrderedBroadcast(Intent, String) |
| 1147 | * @see #sendStickyBroadcast(Intent) |
| 1148 | * @see android.content.BroadcastReceiver |
| 1149 | * @see #registerReceiver |
| 1150 | * @see android.app.Activity#RESULT_OK |
| 1151 | */ |
| 1152 | public abstract void sendStickyOrderedBroadcast(Intent intent, |
| 1153 | BroadcastReceiver resultReceiver, |
| 1154 | Handler scheduler, int initialCode, String initialData, |
| 1155 | Bundle initialExtras); |
| 1156 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1157 | |
| 1158 | /** |
| 1159 | * Remove the data previously sent with {@link #sendStickyBroadcast}, |
| 1160 | * so that it is as if the sticky broadcast had never happened. |
| 1161 | * |
| 1162 | * <p>You must hold the {@link android.Manifest.permission#BROADCAST_STICKY} |
| 1163 | * permission in order to use this API. If you do not hold that |
| 1164 | * permission, {@link SecurityException} will be thrown. |
| 1165 | * |
| 1166 | * @param intent The Intent that was previously broadcast. |
| 1167 | * |
| 1168 | * @see #sendStickyBroadcast |
| 1169 | */ |
| 1170 | public abstract void removeStickyBroadcast(Intent intent); |
| 1171 | |
| 1172 | /** |
Chris Tate | a34df8a2 | 2009-04-02 23:15:58 -0700 | [diff] [blame] | 1173 | * 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] | 1174 | * <var>receiver</var> will be called with any broadcast Intent that |
| 1175 | * matches <var>filter</var>, in the main application thread. |
| 1176 | * |
| 1177 | * <p>The system may broadcast Intents that are "sticky" -- these stay |
| 1178 | * around after the broadcast as finished, to be sent to any later |
| 1179 | * registrations. If your IntentFilter matches one of these sticky |
| 1180 | * Intents, that Intent will be returned by this function |
| 1181 | * <strong>and</strong> sent to your <var>receiver</var> as if it had just |
| 1182 | * been broadcast. |
| 1183 | * |
| 1184 | * <p>There may be multiple sticky Intents that match <var>filter</var>, |
| 1185 | * in which case each of these will be sent to <var>receiver</var>. In |
| 1186 | * this case, only one of these can be returned directly by the function; |
| 1187 | * which of these that is returned is arbitrarily decided by the system. |
| 1188 | * |
| 1189 | * <p>If you know the Intent your are registering for is sticky, you can |
| 1190 | * supply null for your <var>receiver</var>. In this case, no receiver is |
| 1191 | * registered -- the function simply returns the sticky Intent that |
| 1192 | * matches <var>filter</var>. In the case of multiple matches, the same |
| 1193 | * rules as described above apply. |
| 1194 | * |
| 1195 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1196 | * |
Dianne Hackborn | 6c418d5 | 2011-06-29 14:05:33 -0700 | [diff] [blame] | 1197 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 1198 | * registered with this method will correctly respect the |
| 1199 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 1200 | * Prior to that, it would be ignored and delivered to all matching registered |
| 1201 | * receivers. Be careful if using this for security.</p> |
| 1202 | * |
Chris Tate | a34df8a2 | 2009-04-02 23:15:58 -0700 | [diff] [blame] | 1203 | * <p class="note">Note: this method <em>cannot be called from a |
| 1204 | * {@link BroadcastReceiver} component;</em> that is, from a BroadcastReceiver |
| 1205 | * that is declared in an application's manifest. It is okay, however, to call |
| 1206 | * this method from another BroadcastReceiver that has itself been registered |
| 1207 | * at run time with {@link #registerReceiver}, since the lifetime of such a |
| 1208 | * 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] | 1209 | * |
| 1210 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 1211 | * @param filter Selects the Intent broadcasts to be received. |
| 1212 | * |
| 1213 | * @return The first sticky intent found that matches <var>filter</var>, |
| 1214 | * or null if there are none. |
| 1215 | * |
| 1216 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
| 1217 | * @see #sendBroadcast |
| 1218 | * @see #unregisterReceiver |
| 1219 | */ |
| 1220 | public abstract Intent registerReceiver(BroadcastReceiver receiver, |
| 1221 | IntentFilter filter); |
| 1222 | |
| 1223 | /** |
| 1224 | * Register to receive intent broadcasts, to run in the context of |
| 1225 | * <var>scheduler</var>. See |
| 1226 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter)} for more |
| 1227 | * information. This allows you to enforce permissions on who can |
| 1228 | * broadcast intents to your receiver, or have the receiver run in |
| 1229 | * a different thread than the main application thread. |
| 1230 | * |
| 1231 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1232 | * |
Dianne Hackborn | 6c418d5 | 2011-06-29 14:05:33 -0700 | [diff] [blame] | 1233 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 1234 | * registered with this method will correctly respect the |
| 1235 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 1236 | * Prior to that, it would be ignored and delivered to all matching registered |
| 1237 | * receivers. Be careful if using this for security.</p> |
| 1238 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1239 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 1240 | * @param filter Selects the Intent broadcasts to be received. |
| 1241 | * @param broadcastPermission String naming a permissions that a |
| 1242 | * broadcaster must hold in order to send an Intent to you. If null, |
| 1243 | * no permission is required. |
| 1244 | * @param scheduler Handler identifying the thread that will receive |
| 1245 | * the Intent. If null, the main thread of the process will be used. |
| 1246 | * |
| 1247 | * @return The first sticky intent found that matches <var>filter</var>, |
| 1248 | * or null if there are none. |
| 1249 | * |
| 1250 | * @see #registerReceiver(BroadcastReceiver, IntentFilter) |
| 1251 | * @see #sendBroadcast |
| 1252 | * @see #unregisterReceiver |
| 1253 | */ |
| 1254 | public abstract Intent registerReceiver(BroadcastReceiver receiver, |
| 1255 | IntentFilter filter, |
| 1256 | String broadcastPermission, |
| 1257 | Handler scheduler); |
| 1258 | |
| 1259 | /** |
| 1260 | * Unregister a previously registered BroadcastReceiver. <em>All</em> |
| 1261 | * filters that have been registered for this BroadcastReceiver will be |
| 1262 | * removed. |
| 1263 | * |
| 1264 | * @param receiver The BroadcastReceiver to unregister. |
| 1265 | * |
| 1266 | * @see #registerReceiver |
| 1267 | */ |
| 1268 | public abstract void unregisterReceiver(BroadcastReceiver receiver); |
| 1269 | |
| 1270 | /** |
| 1271 | * Request that a given application service be started. The Intent |
| 1272 | * can either contain the complete class name of a specific service |
| 1273 | * implementation to start, or an abstract definition through the |
| 1274 | * action and other fields of the kind of service to start. If this service |
| 1275 | * is not already running, it will be instantiated and started (creating a |
| 1276 | * process for it if needed); if it is running then it remains running. |
| 1277 | * |
| 1278 | * <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] | 1279 | * 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] | 1280 | * with the <var>intent</var> given here. This provides a convenient way |
| 1281 | * to submit jobs to a service without having to bind and call on to its |
| 1282 | * interface. |
| 1283 | * |
| 1284 | * <p>Using startService() overrides the default service lifetime that is |
| 1285 | * managed by {@link #bindService}: it requires the service to remain |
| 1286 | * running until {@link #stopService} is called, regardless of whether |
| 1287 | * any clients are connected to it. Note that calls to startService() |
| 1288 | * are not nesting: no matter how many times you call startService(), |
| 1289 | * a single call to {@link #stopService} will stop it. |
| 1290 | * |
| 1291 | * <p>The system attempts to keep running services around as much as |
| 1292 | * possible. The only time they should be stopped is if the current |
| 1293 | * foreground application is using so many resources that the service needs |
| 1294 | * to be killed. If any errors happen in the service's process, it will |
| 1295 | * automatically be restarted. |
| 1296 | * |
| 1297 | * <p>This function will throw {@link SecurityException} if you do not |
| 1298 | * have permission to start the given service. |
| 1299 | * |
| 1300 | * @param service Identifies the service to be started. The Intent may |
| 1301 | * specify either an explicit component name to start, or a logical |
| 1302 | * description (action, category, etc) to match an |
| 1303 | * {@link IntentFilter} published by a service. Additional values |
| 1304 | * may be included in the Intent extras to supply arguments along with |
| 1305 | * this specific start call. |
| 1306 | * |
| 1307 | * @return If the service is being started or is already running, the |
| 1308 | * {@link ComponentName} of the actual service that was started is |
| 1309 | * returned; else if the service does not exist null is returned. |
| 1310 | * |
| 1311 | * @throws SecurityException |
| 1312 | * |
| 1313 | * @see #stopService |
| 1314 | * @see #bindService |
| 1315 | */ |
| 1316 | public abstract ComponentName startService(Intent service); |
| 1317 | |
| 1318 | /** |
| 1319 | * Request that a given application service be stopped. If the service is |
| 1320 | * not running, nothing happens. Otherwise it is stopped. Note that calls |
| 1321 | * to startService() are not counted -- this stops the service no matter |
| 1322 | * how many times it was started. |
| 1323 | * |
| 1324 | * <p>Note that if a stopped service still has {@link ServiceConnection} |
| 1325 | * objects bound to it with the {@link #BIND_AUTO_CREATE} set, it will |
| 1326 | * not be destroyed until all of these bindings are removed. See |
| 1327 | * the {@link android.app.Service} documentation for more details on a |
| 1328 | * service's lifecycle. |
| 1329 | * |
| 1330 | * <p>This function will throw {@link SecurityException} if you do not |
| 1331 | * have permission to stop the given service. |
| 1332 | * |
| 1333 | * @param service Description of the service to be stopped. The Intent may |
| 1334 | * specify either an explicit component name to start, or a logical |
| 1335 | * description (action, category, etc) to match an |
| 1336 | * {@link IntentFilter} published by a service. |
| 1337 | * |
| 1338 | * @return If there is a service matching the given Intent that is already |
| 1339 | * running, then it is stopped and true is returned; else false is returned. |
| 1340 | * |
| 1341 | * @throws SecurityException |
| 1342 | * |
| 1343 | * @see #startService |
| 1344 | */ |
| 1345 | public abstract boolean stopService(Intent service); |
| 1346 | |
| 1347 | /** |
| 1348 | * Connect to an application service, creating it if needed. This defines |
| 1349 | * a dependency between your application and the service. The given |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 1350 | * <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] | 1351 | * told if it dies and restarts. The service will be considered required |
| 1352 | * by the system only for as long as the calling context exists. For |
| 1353 | * example, if this Context is an Activity that is stopped, the service will |
| 1354 | * not be required to continue running until the Activity is resumed. |
| 1355 | * |
| 1356 | * <p>This function will throw {@link SecurityException} if you do not |
| 1357 | * have permission to bind to the given service. |
| 1358 | * |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 1359 | * <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] | 1360 | * {@link BroadcastReceiver} component</em>. A pattern you can use to |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 1361 | * 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] | 1362 | * {@link #startService} with the arguments containing the command to be |
| 1363 | * sent, with the service calling its |
| 1364 | * {@link android.app.Service#stopSelf(int)} method when done executing |
| 1365 | * that command. See the API demo App/Service/Service Start Arguments |
| 1366 | * Controller for an illustration of this. It is okay, however, to use |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 1367 | * 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] | 1368 | * {@link #registerReceiver}, since the lifetime of this BroadcastReceiver |
| 1369 | * is tied to another object (the one that registered it).</p> |
| 1370 | * |
| 1371 | * @param service Identifies the service to connect to. The Intent may |
| 1372 | * specify either an explicit component name, or a logical |
| 1373 | * description (action, category, etc) to match an |
| 1374 | * {@link IntentFilter} published by a service. |
| 1375 | * @param conn Receives information as the service is started and stopped. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1376 | * @param flags Operation options for the binding. May be 0, |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 1377 | * {@link #BIND_AUTO_CREATE}, {@link #BIND_DEBUG_UNBIND}, |
| 1378 | * {@link #BIND_NOT_FOREGROUND}, {@link #BIND_ABOVE_CLIENT}, |
| 1379 | * {@link #BIND_ALLOW_OOM_MANAGEMENT}, or |
| 1380 | * {@link #BIND_WAIVE_PRIORITY}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1381 | * @return If you have successfully bound to the service, true is returned; |
| 1382 | * false is returned if the connection is not made so you will not |
| 1383 | * receive the service object. |
| 1384 | * |
| 1385 | * @throws SecurityException |
| 1386 | * |
| 1387 | * @see #unbindService |
| 1388 | * @see #startService |
| 1389 | * @see #BIND_AUTO_CREATE |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1390 | * @see #BIND_DEBUG_UNBIND |
| 1391 | * @see #BIND_NOT_FOREGROUND |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1392 | */ |
| 1393 | public abstract boolean bindService(Intent service, ServiceConnection conn, |
| 1394 | int flags); |
| 1395 | |
| 1396 | /** |
Amith Yamasani | 37ce3a8 | 2012-02-06 12:04:42 -0800 | [diff] [blame] | 1397 | * Same as {@link #bindService(Intent, ServiceConnection, int)}, but with an explicit userId |
| 1398 | * argument for use by system server and other multi-user aware code. |
| 1399 | * @hide |
| 1400 | */ |
| 1401 | public boolean bindService(Intent service, ServiceConnection conn, int flags, int userId) { |
| 1402 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 1403 | } |
| 1404 | |
| 1405 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1406 | * Disconnect from an application service. You will no longer receive |
| 1407 | * calls as the service is restarted, and the service is now allowed to |
| 1408 | * stop at any time. |
| 1409 | * |
| 1410 | * @param conn The connection interface previously supplied to |
| 1411 | * bindService(). |
| 1412 | * |
| 1413 | * @see #bindService |
| 1414 | */ |
| 1415 | public abstract void unbindService(ServiceConnection conn); |
| 1416 | |
| 1417 | /** |
| 1418 | * Start executing an {@link android.app.Instrumentation} class. The given |
| 1419 | * Instrumentation component will be run by killing its target application |
| 1420 | * (if currently running), starting the target process, instantiating the |
| 1421 | * instrumentation component, and then letting it drive the application. |
| 1422 | * |
| 1423 | * <p>This function is not synchronous -- it returns as soon as the |
| 1424 | * instrumentation has started and while it is running. |
| 1425 | * |
| 1426 | * <p>Instrumentation is normally only allowed to run against a package |
| 1427 | * that is either unsigned or signed with a signature that the |
| 1428 | * the instrumentation package is also signed with (ensuring the target |
| 1429 | * trusts the instrumentation). |
| 1430 | * |
| 1431 | * @param className Name of the Instrumentation component to be run. |
| 1432 | * @param profileFile Optional path to write profiling data as the |
| 1433 | * instrumentation runs, or null for no profiling. |
| 1434 | * @param arguments Additional optional arguments to pass to the |
| 1435 | * instrumentation, or null. |
| 1436 | * |
| 1437 | * @return Returns true if the instrumentation was successfully started, |
| 1438 | * else false if it could not be found. |
| 1439 | */ |
| 1440 | public abstract boolean startInstrumentation(ComponentName className, |
| 1441 | String profileFile, Bundle arguments); |
| 1442 | |
| 1443 | /** |
| 1444 | * Return the handle to a system-level service by name. The class of the |
| 1445 | * returned object varies by the requested name. Currently available names |
| 1446 | * are: |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1447 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1448 | * <dl> |
| 1449 | * <dt> {@link #WINDOW_SERVICE} ("window") |
| 1450 | * <dd> The top-level window manager in which you can place custom |
| 1451 | * windows. The returned object is a {@link android.view.WindowManager}. |
| 1452 | * <dt> {@link #LAYOUT_INFLATER_SERVICE} ("layout_inflater") |
| 1453 | * <dd> A {@link android.view.LayoutInflater} for inflating layout resources |
| 1454 | * in this context. |
| 1455 | * <dt> {@link #ACTIVITY_SERVICE} ("activity") |
| 1456 | * <dd> A {@link android.app.ActivityManager} for interacting with the |
| 1457 | * global activity state of the system. |
| 1458 | * <dt> {@link #POWER_SERVICE} ("power") |
| 1459 | * <dd> A {@link android.os.PowerManager} for controlling power |
| 1460 | * management. |
| 1461 | * <dt> {@link #ALARM_SERVICE} ("alarm") |
| 1462 | * <dd> A {@link android.app.AlarmManager} for receiving intents at the |
| 1463 | * time of your choosing. |
| 1464 | * <dt> {@link #NOTIFICATION_SERVICE} ("notification") |
| 1465 | * <dd> A {@link android.app.NotificationManager} for informing the user |
| 1466 | * of background events. |
| 1467 | * <dt> {@link #KEYGUARD_SERVICE} ("keyguard") |
| 1468 | * <dd> A {@link android.app.KeyguardManager} for controlling keyguard. |
| 1469 | * <dt> {@link #LOCATION_SERVICE} ("location") |
| 1470 | * <dd> A {@link android.location.LocationManager} for controlling location |
| 1471 | * (e.g., GPS) updates. |
| 1472 | * <dt> {@link #SEARCH_SERVICE} ("search") |
| 1473 | * <dd> A {@link android.app.SearchManager} for handling search. |
| 1474 | * <dt> {@link #VIBRATOR_SERVICE} ("vibrator") |
| 1475 | * <dd> A {@link android.os.Vibrator} for interacting with the vibrator |
| 1476 | * hardware. |
| 1477 | * <dt> {@link #CONNECTIVITY_SERVICE} ("connection") |
| 1478 | * <dd> A {@link android.net.ConnectivityManager ConnectivityManager} for |
| 1479 | * handling management of network connections. |
| 1480 | * <dt> {@link #WIFI_SERVICE} ("wifi") |
| 1481 | * <dd> A {@link android.net.wifi.WifiManager WifiManager} for management of |
| 1482 | * Wi-Fi connectivity. |
| 1483 | * <dt> {@link #INPUT_METHOD_SERVICE} ("input_method") |
| 1484 | * <dd> An {@link android.view.inputmethod.InputMethodManager InputMethodManager} |
| 1485 | * for management of input methods. |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 1486 | * <dt> {@link #UI_MODE_SERVICE} ("uimode") |
| 1487 | * <dd> An {@link android.app.UiModeManager} for controlling UI modes. |
Steve Howard | 7083c42 | 2010-07-28 16:01:23 -0700 | [diff] [blame] | 1488 | * <dt> {@link #DOWNLOAD_SERVICE} ("download") |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 1489 | * <dd> A {@link android.app.DownloadManager} for requesting HTTP downloads |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1490 | * </dl> |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1491 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1492 | * <p>Note: System services obtained via this API may be closely associated with |
| 1493 | * the Context in which they are obtained from. In general, do not share the |
| 1494 | * service objects between various different contexts (Activities, Applications, |
| 1495 | * Services, Providers, etc.) |
| 1496 | * |
| 1497 | * @param name The name of the desired service. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1498 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1499 | * @return The service or null if the name does not exist. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1500 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1501 | * @see #WINDOW_SERVICE |
| 1502 | * @see android.view.WindowManager |
| 1503 | * @see #LAYOUT_INFLATER_SERVICE |
| 1504 | * @see android.view.LayoutInflater |
| 1505 | * @see #ACTIVITY_SERVICE |
| 1506 | * @see android.app.ActivityManager |
| 1507 | * @see #POWER_SERVICE |
| 1508 | * @see android.os.PowerManager |
| 1509 | * @see #ALARM_SERVICE |
| 1510 | * @see android.app.AlarmManager |
| 1511 | * @see #NOTIFICATION_SERVICE |
| 1512 | * @see android.app.NotificationManager |
| 1513 | * @see #KEYGUARD_SERVICE |
| 1514 | * @see android.app.KeyguardManager |
| 1515 | * @see #LOCATION_SERVICE |
| 1516 | * @see android.location.LocationManager |
| 1517 | * @see #SEARCH_SERVICE |
| 1518 | * @see android.app.SearchManager |
| 1519 | * @see #SENSOR_SERVICE |
| 1520 | * @see android.hardware.SensorManager |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 1521 | * @see #STORAGE_SERVICE |
San Mehat | b104340 | 2010-02-05 08:26:50 -0800 | [diff] [blame] | 1522 | * @see android.os.storage.StorageManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1523 | * @see #VIBRATOR_SERVICE |
| 1524 | * @see android.os.Vibrator |
| 1525 | * @see #CONNECTIVITY_SERVICE |
| 1526 | * @see android.net.ConnectivityManager |
| 1527 | * @see #WIFI_SERVICE |
| 1528 | * @see android.net.wifi.WifiManager |
| 1529 | * @see #AUDIO_SERVICE |
| 1530 | * @see android.media.AudioManager |
| 1531 | * @see #TELEPHONY_SERVICE |
| 1532 | * @see android.telephony.TelephonyManager |
| 1533 | * @see #INPUT_METHOD_SERVICE |
| 1534 | * @see android.view.inputmethod.InputMethodManager |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 1535 | * @see #UI_MODE_SERVICE |
| 1536 | * @see android.app.UiModeManager |
Steve Howard | 7083c42 | 2010-07-28 16:01:23 -0700 | [diff] [blame] | 1537 | * @see #DOWNLOAD_SERVICE |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 1538 | * @see android.app.DownloadManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1539 | */ |
| 1540 | public abstract Object getSystemService(String name); |
| 1541 | |
| 1542 | /** |
| 1543 | * Use with {@link #getSystemService} to retrieve a |
| 1544 | * {@link android.os.PowerManager} for controlling power management, |
| 1545 | * including "wake locks," which let you keep the device on while |
| 1546 | * you're running long tasks. |
| 1547 | */ |
| 1548 | public static final String POWER_SERVICE = "power"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1549 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1550 | /** |
| 1551 | * Use with {@link #getSystemService} to retrieve a |
| 1552 | * {@link android.view.WindowManager} for accessing the system's window |
| 1553 | * manager. |
| 1554 | * |
| 1555 | * @see #getSystemService |
| 1556 | * @see android.view.WindowManager |
| 1557 | */ |
| 1558 | public static final String WINDOW_SERVICE = "window"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1559 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1560 | /** |
| 1561 | * Use with {@link #getSystemService} to retrieve a |
| 1562 | * {@link android.view.LayoutInflater} for inflating layout resources in this |
| 1563 | * context. |
| 1564 | * |
| 1565 | * @see #getSystemService |
| 1566 | * @see android.view.LayoutInflater |
| 1567 | */ |
| 1568 | public static final String LAYOUT_INFLATER_SERVICE = "layout_inflater"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1569 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1570 | /** |
| 1571 | * Use with {@link #getSystemService} to retrieve a |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 1572 | * {@link android.accounts.AccountManager} for receiving intents at a |
| 1573 | * time of your choosing. |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 1574 | * |
| 1575 | * @see #getSystemService |
| 1576 | * @see android.accounts.AccountManager |
| 1577 | */ |
| 1578 | public static final String ACCOUNT_SERVICE = "account"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1579 | |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 1580 | /** |
| 1581 | * Use with {@link #getSystemService} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1582 | * {@link android.app.ActivityManager} for interacting with the global |
| 1583 | * system state. |
| 1584 | * |
| 1585 | * @see #getSystemService |
| 1586 | * @see android.app.ActivityManager |
| 1587 | */ |
| 1588 | public static final String ACTIVITY_SERVICE = "activity"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1589 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1590 | /** |
| 1591 | * Use with {@link #getSystemService} to retrieve a |
| 1592 | * {@link android.app.AlarmManager} for receiving intents at a |
| 1593 | * time of your choosing. |
| 1594 | * |
| 1595 | * @see #getSystemService |
| 1596 | * @see android.app.AlarmManager |
| 1597 | */ |
| 1598 | public static final String ALARM_SERVICE = "alarm"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1599 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1600 | /** |
| 1601 | * Use with {@link #getSystemService} to retrieve a |
| 1602 | * {@link android.app.NotificationManager} for informing the user of |
| 1603 | * background events. |
| 1604 | * |
| 1605 | * @see #getSystemService |
| 1606 | * @see android.app.NotificationManager |
| 1607 | */ |
| 1608 | public static final String NOTIFICATION_SERVICE = "notification"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1609 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1610 | /** |
| 1611 | * Use with {@link #getSystemService} to retrieve a |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1612 | * {@link android.view.accessibility.AccessibilityManager} for giving the user |
| 1613 | * feedback for UI events through the registered event listeners. |
| 1614 | * |
| 1615 | * @see #getSystemService |
| 1616 | * @see android.view.accessibility.AccessibilityManager |
| 1617 | */ |
| 1618 | public static final String ACCESSIBILITY_SERVICE = "accessibility"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1619 | |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 1620 | /** |
| 1621 | * Use with {@link #getSystemService} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1622 | * {@link android.app.NotificationManager} for controlling keyguard. |
| 1623 | * |
| 1624 | * @see #getSystemService |
| 1625 | * @see android.app.KeyguardManager |
| 1626 | */ |
| 1627 | public static final String KEYGUARD_SERVICE = "keyguard"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1628 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1629 | /** |
| 1630 | * Use with {@link #getSystemService} to retrieve a {@link |
| 1631 | * android.location.LocationManager} for controlling location |
| 1632 | * updates. |
| 1633 | * |
| 1634 | * @see #getSystemService |
| 1635 | * @see android.location.LocationManager |
| 1636 | */ |
| 1637 | public static final String LOCATION_SERVICE = "location"; |
Bai Tao | a58a875 | 2010-07-13 15:32:16 +0800 | [diff] [blame] | 1638 | |
| 1639 | /** |
| 1640 | * Use with {@link #getSystemService} to retrieve a |
| 1641 | * {@link android.location.CountryDetector} for detecting the country that |
| 1642 | * the user is in. |
| 1643 | * |
| 1644 | * @hide |
| 1645 | */ |
| 1646 | public static final String COUNTRY_DETECTOR = "country_detector"; |
| 1647 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1648 | /** |
| 1649 | * Use with {@link #getSystemService} to retrieve a {@link |
| 1650 | * android.app.SearchManager} for handling searches. |
| 1651 | * |
| 1652 | * @see #getSystemService |
| 1653 | * @see android.app.SearchManager |
| 1654 | */ |
| 1655 | public static final String SEARCH_SERVICE = "search"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1656 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1657 | /** |
| 1658 | * Use with {@link #getSystemService} to retrieve a {@link |
| 1659 | * android.hardware.SensorManager} for accessing sensors. |
| 1660 | * |
| 1661 | * @see #getSystemService |
| 1662 | * @see android.hardware.SensorManager |
| 1663 | */ |
| 1664 | public static final String SENSOR_SERVICE = "sensor"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1665 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1666 | /** |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 1667 | * Use with {@link #getSystemService} to retrieve a {@link |
Kenny Root | 02c8730 | 2010-07-01 08:10:18 -0700 | [diff] [blame] | 1668 | * android.os.storage.StorageManager} for accessing system storage |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 1669 | * functions. |
| 1670 | * |
| 1671 | * @see #getSystemService |
San Mehat | b104340 | 2010-02-05 08:26:50 -0800 | [diff] [blame] | 1672 | * @see android.os.storage.StorageManager |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 1673 | */ |
| 1674 | public static final String STORAGE_SERVICE = "storage"; |
| 1675 | |
| 1676 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1677 | * Use with {@link #getSystemService} to retrieve a |
| 1678 | * com.android.server.WallpaperService for accessing wallpapers. |
| 1679 | * |
| 1680 | * @see #getSystemService |
| 1681 | */ |
| 1682 | public static final String WALLPAPER_SERVICE = "wallpaper"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1683 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1684 | /** |
| 1685 | * Use with {@link #getSystemService} to retrieve a {@link |
| 1686 | * android.os.Vibrator} for interacting with the vibration hardware. |
| 1687 | * |
| 1688 | * @see #getSystemService |
| 1689 | * @see android.os.Vibrator |
| 1690 | */ |
| 1691 | public static final String VIBRATOR_SERVICE = "vibrator"; |
Robert Greenwalt | 9e696c2 | 2010-04-01 14:45:18 -0700 | [diff] [blame] | 1692 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1693 | /** |
| 1694 | * Use with {@link #getSystemService} to retrieve a {@link |
| 1695 | * android.app.StatusBarManager} for interacting with the status bar. |
| 1696 | * |
| 1697 | * @see #getSystemService |
| 1698 | * @see android.app.StatusBarManager |
| 1699 | * @hide |
| 1700 | */ |
| 1701 | public static final String STATUS_BAR_SERVICE = "statusbar"; |
| 1702 | |
| 1703 | /** |
| 1704 | * Use with {@link #getSystemService} to retrieve a {@link |
| 1705 | * android.net.ConnectivityManager} for handling management of |
| 1706 | * network connections. |
| 1707 | * |
| 1708 | * @see #getSystemService |
| 1709 | * @see android.net.ConnectivityManager |
| 1710 | */ |
| 1711 | public static final String CONNECTIVITY_SERVICE = "connectivity"; |
| 1712 | |
| 1713 | /** |
| 1714 | * Use with {@link #getSystemService} to retrieve a {@link |
Robert Greenwalt | 9e696c2 | 2010-04-01 14:45:18 -0700 | [diff] [blame] | 1715 | * android.net.ThrottleManager} for handling management of |
| 1716 | * throttling. |
| 1717 | * |
| 1718 | * @hide |
| 1719 | * @see #getSystemService |
| 1720 | * @see android.net.ThrottleManager |
| 1721 | */ |
| 1722 | public static final String THROTTLE_SERVICE = "throttle"; |
| 1723 | |
| 1724 | /** |
| 1725 | * Use with {@link #getSystemService} to retrieve a {@link |
Christopher Tate | 8662cab5 | 2012-02-23 14:59:36 -0800 | [diff] [blame] | 1726 | * android.os.IUpdateLock} for managing runtime sequences that |
| 1727 | * must not be interrupted by headless OTA application or similar. |
| 1728 | * |
| 1729 | * @hide |
| 1730 | * @see #getSystemService |
| 1731 | * @see android.os.UpdateLock |
| 1732 | */ |
| 1733 | public static final String UPDATE_LOCK_SERVICE = "updatelock"; |
| 1734 | |
| 1735 | /** |
| 1736 | * Use with {@link #getSystemService} to retrieve a {@link |
San Mehat | d1df8ac | 2010-01-26 06:17:26 -0800 | [diff] [blame] | 1737 | * android.net.NetworkManagementService} for handling management of |
| 1738 | * system network services |
| 1739 | * |
| 1740 | * @hide |
| 1741 | * @see #getSystemService |
| 1742 | * @see android.net.NetworkManagementService |
| 1743 | */ |
| 1744 | public static final String NETWORKMANAGEMENT_SERVICE = "network_management"; |
| 1745 | |
Jeff Sharkey | eedcb95 | 2011-05-17 14:55:15 -0700 | [diff] [blame] | 1746 | /** {@hide} */ |
Jeff Sharkey | 7527990 | 2011-05-24 18:39:45 -0700 | [diff] [blame] | 1747 | public static final String NETWORK_STATS_SERVICE = "netstats"; |
| 1748 | /** {@hide} */ |
Jeff Sharkey | eedcb95 | 2011-05-17 14:55:15 -0700 | [diff] [blame] | 1749 | public static final String NETWORK_POLICY_SERVICE = "netpolicy"; |
| 1750 | |
San Mehat | d1df8ac | 2010-01-26 06:17:26 -0800 | [diff] [blame] | 1751 | /** |
| 1752 | * Use with {@link #getSystemService} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1753 | * android.net.wifi.WifiManager} for handling management of |
| 1754 | * Wi-Fi access. |
| 1755 | * |
| 1756 | * @see #getSystemService |
| 1757 | * @see android.net.wifi.WifiManager |
| 1758 | */ |
| 1759 | public static final String WIFI_SERVICE = "wifi"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1760 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1761 | /** |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 1762 | * Use with {@link #getSystemService} to retrieve a {@link |
| 1763 | * android.net.wifi.p2p.WifiP2pManager} for handling management of |
Irfan Sheriff | 651cdfc | 2011-09-07 00:31:20 -0700 | [diff] [blame] | 1764 | * Wi-Fi peer-to-peer connections. |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 1765 | * |
| 1766 | * @see #getSystemService |
| 1767 | * @see android.net.wifi.p2p.WifiP2pManager |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 1768 | */ |
| 1769 | public static final String WIFI_P2P_SERVICE = "wifip2p"; |
| 1770 | |
| 1771 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1772 | * Use with {@link #getSystemService} to retrieve a |
| 1773 | * {@link android.media.AudioManager} for handling management of volume, |
| 1774 | * ringer modes and audio routing. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1775 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1776 | * @see #getSystemService |
| 1777 | * @see android.media.AudioManager |
| 1778 | */ |
| 1779 | public static final String AUDIO_SERVICE = "audio"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1780 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1781 | /** |
| 1782 | * Use with {@link #getSystemService} to retrieve a |
| 1783 | * {@link android.telephony.TelephonyManager} for handling management the |
| 1784 | * telephony features of the device. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1785 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1786 | * @see #getSystemService |
| 1787 | * @see android.telephony.TelephonyManager |
| 1788 | */ |
| 1789 | public static final String TELEPHONY_SERVICE = "phone"; |
| 1790 | |
| 1791 | /** |
| 1792 | * Use with {@link #getSystemService} to retrieve a |
| 1793 | * {@link android.text.ClipboardManager} for accessing and modifying |
| 1794 | * the contents of the global clipboard. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1795 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1796 | * @see #getSystemService |
| 1797 | * @see android.text.ClipboardManager |
| 1798 | */ |
| 1799 | public static final String CLIPBOARD_SERVICE = "clipboard"; |
| 1800 | |
| 1801 | /** |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1802 | * Use with {@link #getSystemService} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1803 | * {@link android.view.inputmethod.InputMethodManager} for accessing input |
| 1804 | * methods. |
| 1805 | * |
| 1806 | * @see #getSystemService |
| 1807 | */ |
| 1808 | public static final String INPUT_METHOD_SERVICE = "input_method"; |
| 1809 | |
| 1810 | /** |
| 1811 | * Use with {@link #getSystemService} to retrieve a |
satok | 988323c | 2011-06-22 16:38:13 +0900 | [diff] [blame] | 1812 | * {@link android.view.textservice.TextServicesManager} for accessing |
| 1813 | * text services. |
| 1814 | * |
| 1815 | * @see #getSystemService |
| 1816 | */ |
| 1817 | public static final String TEXT_SERVICES_MANAGER_SERVICE = "textservices"; |
| 1818 | |
| 1819 | /** |
| 1820 | * Use with {@link #getSystemService} to retrieve a |
Dan Egnor | e38d58b | 2009-12-30 19:29:03 -0800 | [diff] [blame] | 1821 | * {@link android.appwidget.AppWidgetManager} for accessing AppWidgets. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1822 | * |
| 1823 | * @hide |
| 1824 | * @see #getSystemService |
| 1825 | */ |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 1826 | public static final String APPWIDGET_SERVICE = "appwidget"; |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 1827 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1828 | /** |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 1829 | * Use with {@link #getSystemService} to retrieve an |
Christopher Tate | 4528186 | 2010-03-05 15:46:30 -0800 | [diff] [blame] | 1830 | * {@link android.app.backup.IBackupManager IBackupManager} for communicating |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 1831 | * with the backup mechanism. |
Dianne Hackborn | 7f20543 | 2009-07-28 00:13:47 -0700 | [diff] [blame] | 1832 | * @hide |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1833 | * |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 1834 | * @see #getSystemService |
| 1835 | */ |
| 1836 | public static final String BACKUP_SERVICE = "backup"; |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 1837 | |
| 1838 | /** |
| 1839 | * Use with {@link #getSystemService} to retrieve a |
Dan Egnor | 1337b01 | 2010-01-04 11:01:44 -0800 | [diff] [blame] | 1840 | * {@link android.os.DropBoxManager} instance for recording |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 1841 | * diagnostic logs. |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 1842 | * @see #getSystemService |
| 1843 | */ |
| 1844 | public static final String DROPBOX_SERVICE = "dropbox"; |
| 1845 | |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 1846 | /** |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1847 | * Use with {@link #getSystemService} to retrieve a |
Dianne Hackborn | 87bba1e | 2010-02-26 17:25:54 -0800 | [diff] [blame] | 1848 | * {@link android.app.admin.DevicePolicyManager} for working with global |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 1849 | * device policy management. |
| 1850 | * |
| 1851 | * @see #getSystemService |
| 1852 | */ |
| 1853 | public static final String DEVICE_POLICY_SERVICE = "device_policy"; |
| 1854 | |
| 1855 | /** |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 1856 | * Use with {@link #getSystemService} to retrieve a |
| 1857 | * {@link android.app.UiModeManager} for controlling UI modes. |
| 1858 | * |
| 1859 | * @see #getSystemService |
| 1860 | */ |
| 1861 | public static final String UI_MODE_SERVICE = "uimode"; |
| 1862 | |
| 1863 | /** |
Steve Howard | a270936 | 2010-07-02 17:12:48 -0700 | [diff] [blame] | 1864 | * Use with {@link #getSystemService} to retrieve a |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 1865 | * {@link android.app.DownloadManager} for requesting HTTP downloads. |
Steve Howard | a270936 | 2010-07-02 17:12:48 -0700 | [diff] [blame] | 1866 | * |
| 1867 | * @see #getSystemService |
Steve Howard | a270936 | 2010-07-02 17:12:48 -0700 | [diff] [blame] | 1868 | */ |
| 1869 | public static final String DOWNLOAD_SERVICE = "download"; |
| 1870 | |
| 1871 | /** |
Chung-yih Wang | 2d94231 | 2010-08-05 12:17:37 +0800 | [diff] [blame] | 1872 | * Use with {@link #getSystemService} to retrieve a |
Nick Pelly | 50b4d8f | 2010-12-07 22:40:28 -0800 | [diff] [blame] | 1873 | * {@link android.nfc.NfcManager} for using NFC. |
| 1874 | * |
| 1875 | * @see #getSystemService |
| 1876 | */ |
| 1877 | public static final String NFC_SERVICE = "nfc"; |
| 1878 | |
| 1879 | /** |
| 1880 | * Use with {@link #getSystemService} to retrieve a |
Chung-yih Wang | 2d94231 | 2010-08-05 12:17:37 +0800 | [diff] [blame] | 1881 | * {@link android.net.sip.SipManager} for accessing the SIP related service. |
| 1882 | * |
| 1883 | * @see #getSystemService |
| 1884 | */ |
| 1885 | /** @hide */ |
| 1886 | public static final String SIP_SERVICE = "sip"; |
| 1887 | |
| 1888 | /** |
Mike Lockwood | e7d511e | 2010-12-30 13:39:37 -0500 | [diff] [blame] | 1889 | * Use with {@link #getSystemService} to retrieve a {@link |
Mike Lockwood | c4308f0 | 2011-03-01 08:04:54 -0800 | [diff] [blame] | 1890 | * 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] | 1891 | * and for controlling this device's behavior as a USB device. |
| 1892 | * |
| 1893 | * @see #getSystemService |
Mike Lockwood | c4308f0 | 2011-03-01 08:04:54 -0800 | [diff] [blame] | 1894 | * @see android.harware.usb.UsbManager |
Mike Lockwood | e7d511e | 2010-12-30 13:39:37 -0500 | [diff] [blame] | 1895 | */ |
| 1896 | public static final String USB_SERVICE = "usb"; |
| 1897 | |
| 1898 | /** |
Mike Lockwood | b01e8bf | 2011-08-29 20:11:07 -0400 | [diff] [blame] | 1899 | * Use with {@link #getSystemService} to retrieve a {@link |
| 1900 | * android.hardware.SerialManager} for access to serial ports. |
| 1901 | * |
| 1902 | * @see #getSystemService |
| 1903 | * @see android.harware.SerialManager |
| 1904 | * |
| 1905 | * @hide |
| 1906 | */ |
| 1907 | public static final String SERIAL_SERVICE = "serial"; |
| 1908 | |
| 1909 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1910 | * Determine whether the given permission is allowed for a particular |
| 1911 | * process and user ID running in the system. |
| 1912 | * |
| 1913 | * @param permission The name of the permission being checked. |
| 1914 | * @param pid The process ID being checked against. Must be > 0. |
| 1915 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 1916 | * user, which will pass every permission check. |
| 1917 | * |
| 1918 | * @return Returns {@link PackageManager#PERMISSION_GRANTED} if the given |
| 1919 | * pid/uid is allowed that permission, or |
| 1920 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 1921 | * |
| 1922 | * @see PackageManager#checkPermission(String, String) |
| 1923 | * @see #checkCallingPermission |
| 1924 | */ |
| 1925 | public abstract int checkPermission(String permission, int pid, int uid); |
| 1926 | |
| 1927 | /** |
| 1928 | * Determine whether the calling process of an IPC you are handling has been |
| 1929 | * granted a particular permission. This is basically the same as calling |
| 1930 | * {@link #checkPermission(String, int, int)} with the pid and uid returned |
| 1931 | * by {@link android.os.Binder#getCallingPid} and |
| 1932 | * {@link android.os.Binder#getCallingUid}. One important difference |
| 1933 | * is that if you are not currently processing an IPC, this function |
| 1934 | * will always fail. This is done to protect against accidentally |
| 1935 | * leaking permissions; you can use {@link #checkCallingOrSelfPermission} |
| 1936 | * to avoid this protection. |
| 1937 | * |
| 1938 | * @param permission The name of the permission being checked. |
| 1939 | * |
| 1940 | * @return Returns {@link PackageManager#PERMISSION_GRANTED} if the calling |
| 1941 | * pid/uid is allowed that permission, or |
| 1942 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 1943 | * |
| 1944 | * @see PackageManager#checkPermission(String, String) |
| 1945 | * @see #checkPermission |
| 1946 | * @see #checkCallingOrSelfPermission |
| 1947 | */ |
| 1948 | public abstract int checkCallingPermission(String permission); |
| 1949 | |
| 1950 | /** |
| 1951 | * Determine whether the calling process of an IPC <em>or you</em> have been |
| 1952 | * granted a particular permission. This is the same as |
| 1953 | * {@link #checkCallingPermission}, except it grants your own permissions |
| 1954 | * if you are not currently processing an IPC. Use with care! |
| 1955 | * |
| 1956 | * @param permission The name of the permission being checked. |
| 1957 | * |
| 1958 | * @return Returns {@link PackageManager#PERMISSION_GRANTED} if the calling |
| 1959 | * pid/uid is allowed that permission, or |
| 1960 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 1961 | * |
| 1962 | * @see PackageManager#checkPermission(String, String) |
| 1963 | * @see #checkPermission |
| 1964 | * @see #checkCallingPermission |
| 1965 | */ |
| 1966 | public abstract int checkCallingOrSelfPermission(String permission); |
| 1967 | |
| 1968 | /** |
| 1969 | * If the given permission is not allowed for a particular process |
| 1970 | * and user ID running in the system, throw a {@link SecurityException}. |
| 1971 | * |
| 1972 | * @param permission The name of the permission being checked. |
| 1973 | * @param pid The process ID being checked against. Must be > 0. |
| 1974 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 1975 | * user, which will pass every permission check. |
| 1976 | * @param message A message to include in the exception if it is thrown. |
| 1977 | * |
| 1978 | * @see #checkPermission(String, int, int) |
| 1979 | */ |
| 1980 | public abstract void enforcePermission( |
| 1981 | String permission, int pid, int uid, String message); |
| 1982 | |
| 1983 | /** |
| 1984 | * If the calling process of an IPC you are handling has not been |
| 1985 | * granted a particular permission, throw a {@link |
| 1986 | * SecurityException}. This is basically the same as calling |
| 1987 | * {@link #enforcePermission(String, int, int, String)} with the |
| 1988 | * pid and uid returned by {@link android.os.Binder#getCallingPid} |
| 1989 | * and {@link android.os.Binder#getCallingUid}. One important |
| 1990 | * difference is that if you are not currently processing an IPC, |
| 1991 | * this function will always throw the SecurityException. This is |
| 1992 | * done to protect against accidentally leaking permissions; you |
| 1993 | * can use {@link #enforceCallingOrSelfPermission} to avoid this |
| 1994 | * protection. |
| 1995 | * |
| 1996 | * @param permission The name of the permission being checked. |
| 1997 | * @param message A message to include in the exception if it is thrown. |
| 1998 | * |
| 1999 | * @see #checkCallingPermission(String) |
| 2000 | */ |
| 2001 | public abstract void enforceCallingPermission( |
| 2002 | String permission, String message); |
| 2003 | |
| 2004 | /** |
| 2005 | * If neither you nor the calling process of an IPC you are |
| 2006 | * handling has been granted a particular permission, throw a |
| 2007 | * {@link SecurityException}. This is the same as {@link |
| 2008 | * #enforceCallingPermission}, except it grants your own |
| 2009 | * permissions if you are not currently processing an IPC. Use |
| 2010 | * with care! |
| 2011 | * |
| 2012 | * @param permission The name of the permission being checked. |
| 2013 | * @param message A message to include in the exception if it is thrown. |
| 2014 | * |
| 2015 | * @see #checkCallingOrSelfPermission(String) |
| 2016 | */ |
| 2017 | public abstract void enforceCallingOrSelfPermission( |
| 2018 | String permission, String message); |
| 2019 | |
| 2020 | /** |
| 2021 | * Grant permission to access a specific Uri to another package, regardless |
| 2022 | * of whether that package has general permission to access the Uri's |
| 2023 | * content provider. This can be used to grant specific, temporary |
| 2024 | * permissions, typically in response to user interaction (such as the |
| 2025 | * user opening an attachment that you would like someone else to |
| 2026 | * display). |
| 2027 | * |
| 2028 | * <p>Normally you should use {@link Intent#FLAG_GRANT_READ_URI_PERMISSION |
| 2029 | * Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 2030 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
| 2031 | * Intent.FLAG_GRANT_WRITE_URI_PERMISSION} with the Intent being used to |
| 2032 | * start an activity instead of this function directly. If you use this |
| 2033 | * function directly, you should be sure to call |
| 2034 | * {@link #revokeUriPermission} when the target should no longer be allowed |
| 2035 | * to access it. |
| 2036 | * |
| 2037 | * <p>To succeed, the content provider owning the Uri must have set the |
| 2038 | * {@link android.R.styleable#AndroidManifestProvider_grantUriPermissions |
| 2039 | * grantUriPermissions} attribute in its manifest or included the |
| 2040 | * {@link android.R.styleable#AndroidManifestGrantUriPermission |
| 2041 | * <grant-uri-permissions>} tag. |
| 2042 | * |
| 2043 | * @param toPackage The package you would like to allow to access the Uri. |
| 2044 | * @param uri The Uri you would like to grant access to. |
| 2045 | * @param modeFlags The desired access modes. Any combination of |
| 2046 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION |
| 2047 | * Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 2048 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
| 2049 | * Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 2050 | * |
| 2051 | * @see #revokeUriPermission |
| 2052 | */ |
| 2053 | public abstract void grantUriPermission(String toPackage, Uri uri, |
| 2054 | int modeFlags); |
| 2055 | |
| 2056 | /** |
| 2057 | * Remove all permissions to access a particular content provider Uri |
| 2058 | * that were previously added with {@link #grantUriPermission}. The given |
| 2059 | * Uri will match all previously granted Uris that are the same or a |
| 2060 | * sub-path of the given Uri. That is, revoking "content://foo/one" will |
| 2061 | * revoke both "content://foo/target" and "content://foo/target/sub", but not |
| 2062 | * "content://foo". |
| 2063 | * |
| 2064 | * @param uri The Uri you would like to revoke access to. |
| 2065 | * @param modeFlags The desired access modes. Any combination of |
| 2066 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION |
| 2067 | * Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 2068 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
| 2069 | * Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 2070 | * |
| 2071 | * @see #grantUriPermission |
| 2072 | */ |
| 2073 | public abstract void revokeUriPermission(Uri uri, int modeFlags); |
| 2074 | |
| 2075 | /** |
| 2076 | * Determine whether a particular process and user ID has been granted |
| 2077 | * permission to access a specific URI. This only checks for permissions |
| 2078 | * that have been explicitly granted -- if the given process/uid has |
| 2079 | * more general access to the URI's content provider then this check will |
| 2080 | * always fail. |
| 2081 | * |
| 2082 | * @param uri The uri that is being checked. |
| 2083 | * @param pid The process ID being checked against. Must be > 0. |
| 2084 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 2085 | * user, which will pass every permission check. |
| 2086 | * @param modeFlags The type of access to grant. May be one or both of |
| 2087 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 2088 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 2089 | * |
| 2090 | * @return Returns {@link PackageManager#PERMISSION_GRANTED} if the given |
| 2091 | * pid/uid is allowed to access that uri, or |
| 2092 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 2093 | * |
| 2094 | * @see #checkCallingUriPermission |
| 2095 | */ |
| 2096 | public abstract int checkUriPermission(Uri uri, int pid, int uid, int modeFlags); |
| 2097 | |
| 2098 | /** |
| 2099 | * Determine whether the calling process and user ID has been |
| 2100 | * granted permission to access a specific URI. This is basically |
| 2101 | * the same as calling {@link #checkUriPermission(Uri, int, int, |
| 2102 | * int)} with the pid and uid returned by {@link |
| 2103 | * android.os.Binder#getCallingPid} and {@link |
| 2104 | * android.os.Binder#getCallingUid}. One important difference is |
| 2105 | * that if you are not currently processing an IPC, this function |
| 2106 | * will always fail. |
| 2107 | * |
| 2108 | * @param uri The uri that is being checked. |
| 2109 | * @param modeFlags The type of access to grant. May be one or both of |
| 2110 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 2111 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 2112 | * |
| 2113 | * @return Returns {@link PackageManager#PERMISSION_GRANTED} if the caller |
| 2114 | * is allowed to access that uri, or |
| 2115 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 2116 | * |
| 2117 | * @see #checkUriPermission(Uri, int, int, int) |
| 2118 | */ |
| 2119 | public abstract int checkCallingUriPermission(Uri uri, int modeFlags); |
| 2120 | |
| 2121 | /** |
| 2122 | * Determine whether the calling process of an IPC <em>or you</em> has been granted |
| 2123 | * permission to access a specific URI. This is the same as |
| 2124 | * {@link #checkCallingUriPermission}, except it grants your own permissions |
| 2125 | * if you are not currently processing an IPC. Use with care! |
| 2126 | * |
| 2127 | * @param uri The uri that is being checked. |
| 2128 | * @param modeFlags The type of access to grant. May be one or both of |
| 2129 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 2130 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 2131 | * |
| 2132 | * @return Returns {@link PackageManager#PERMISSION_GRANTED} if the caller |
| 2133 | * is allowed to access that uri, or |
| 2134 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 2135 | * |
| 2136 | * @see #checkCallingUriPermission |
| 2137 | */ |
| 2138 | public abstract int checkCallingOrSelfUriPermission(Uri uri, int modeFlags); |
| 2139 | |
| 2140 | /** |
| 2141 | * Check both a Uri and normal permission. This allows you to perform |
| 2142 | * both {@link #checkPermission} and {@link #checkUriPermission} in one |
| 2143 | * call. |
| 2144 | * |
| 2145 | * @param uri The Uri whose permission is to be checked, or null to not |
| 2146 | * do this check. |
| 2147 | * @param readPermission The permission that provides overall read access, |
| 2148 | * or null to not do this check. |
| 2149 | * @param writePermission The permission that provides overall write |
| 2150 | * acess, or null to not do this check. |
| 2151 | * @param pid The process ID being checked against. Must be > 0. |
| 2152 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 2153 | * user, which will pass every permission check. |
| 2154 | * @param modeFlags The type of access to grant. May be one or both of |
| 2155 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 2156 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 2157 | * |
| 2158 | * @return Returns {@link PackageManager#PERMISSION_GRANTED} if the caller |
| 2159 | * is allowed to access that uri or holds one of the given permissions, or |
| 2160 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 2161 | */ |
| 2162 | public abstract int checkUriPermission(Uri uri, String readPermission, |
| 2163 | String writePermission, int pid, int uid, int modeFlags); |
| 2164 | |
| 2165 | /** |
| 2166 | * If a particular process and user ID has not been granted |
| 2167 | * permission to access a specific URI, throw {@link |
| 2168 | * SecurityException}. This only checks for permissions that have |
| 2169 | * been explicitly granted -- if the given process/uid has more |
| 2170 | * general access to the URI's content provider then this check |
| 2171 | * will always fail. |
| 2172 | * |
| 2173 | * @param uri The uri that is being checked. |
| 2174 | * @param pid The process ID being checked against. Must be > 0. |
| 2175 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 2176 | * user, which will pass every permission check. |
| 2177 | * @param modeFlags The type of access to grant. May be one or both of |
| 2178 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 2179 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 2180 | * @param message A message to include in the exception if it is thrown. |
| 2181 | * |
| 2182 | * @see #checkUriPermission(Uri, int, int, int) |
| 2183 | */ |
| 2184 | public abstract void enforceUriPermission( |
| 2185 | Uri uri, int pid, int uid, int modeFlags, String message); |
| 2186 | |
| 2187 | /** |
| 2188 | * If the calling process and user ID has not been granted |
| 2189 | * permission to access a specific URI, throw {@link |
| 2190 | * SecurityException}. This is basically the same as calling |
| 2191 | * {@link #enforceUriPermission(Uri, int, int, int, String)} with |
| 2192 | * the pid and uid returned by {@link |
| 2193 | * android.os.Binder#getCallingPid} and {@link |
| 2194 | * android.os.Binder#getCallingUid}. One important difference is |
| 2195 | * that if you are not currently processing an IPC, this function |
| 2196 | * will always throw a SecurityException. |
| 2197 | * |
| 2198 | * @param uri The uri that is being checked. |
| 2199 | * @param modeFlags The type of access to grant. May be one or both of |
| 2200 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 2201 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 2202 | * @param message A message to include in the exception if it is thrown. |
| 2203 | * |
| 2204 | * @see #checkCallingUriPermission(Uri, int) |
| 2205 | */ |
| 2206 | public abstract void enforceCallingUriPermission( |
| 2207 | Uri uri, int modeFlags, String message); |
| 2208 | |
| 2209 | /** |
| 2210 | * If the calling process of an IPC <em>or you</em> has not been |
| 2211 | * granted permission to access a specific URI, throw {@link |
| 2212 | * SecurityException}. This is the same as {@link |
| 2213 | * #enforceCallingUriPermission}, except it grants your own |
| 2214 | * permissions if you are not currently processing an IPC. Use |
| 2215 | * with care! |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2216 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2217 | * @param uri The uri that is being checked. |
| 2218 | * @param modeFlags The type of access to grant. May be one or both of |
| 2219 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 2220 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 2221 | * @param message A message to include in the exception if it is thrown. |
| 2222 | * |
| 2223 | * @see #checkCallingOrSelfUriPermission(Uri, int) |
| 2224 | */ |
| 2225 | public abstract void enforceCallingOrSelfUriPermission( |
| 2226 | Uri uri, int modeFlags, String message); |
| 2227 | |
| 2228 | /** |
| 2229 | * Enforce both a Uri and normal permission. This allows you to perform |
| 2230 | * both {@link #enforcePermission} and {@link #enforceUriPermission} in one |
| 2231 | * call. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2232 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2233 | * @param uri The Uri whose permission is to be checked, or null to not |
| 2234 | * do this check. |
| 2235 | * @param readPermission The permission that provides overall read access, |
| 2236 | * or null to not do this check. |
| 2237 | * @param writePermission The permission that provides overall write |
| 2238 | * acess, or null to not do this check. |
| 2239 | * @param pid The process ID being checked against. Must be > 0. |
| 2240 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 2241 | * user, which will pass every permission check. |
| 2242 | * @param modeFlags The type of access to grant. May be one or both of |
| 2243 | * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 2244 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. |
| 2245 | * @param message A message to include in the exception if it is thrown. |
| 2246 | * |
| 2247 | * @see #checkUriPermission(Uri, String, String, int, int, int) |
| 2248 | */ |
| 2249 | public abstract void enforceUriPermission( |
| 2250 | Uri uri, String readPermission, String writePermission, |
| 2251 | int pid, int uid, int modeFlags, String message); |
| 2252 | |
| 2253 | /** |
| 2254 | * Flag for use with {@link #createPackageContext}: include the application |
| 2255 | * code with the context. This means loading code into the caller's |
| 2256 | * process, so that {@link #getClassLoader()} can be used to instantiate |
| 2257 | * the application's classes. Setting this flags imposes security |
| 2258 | * restrictions on what application context you can access; if the |
| 2259 | * requested application can not be safely loaded into your process, |
| 2260 | * java.lang.SecurityException will be thrown. If this flag is not set, |
| 2261 | * there will be no restrictions on the packages that can be loaded, |
| 2262 | * but {@link #getClassLoader} will always return the default system |
| 2263 | * class loader. |
| 2264 | */ |
| 2265 | public static final int CONTEXT_INCLUDE_CODE = 0x00000001; |
| 2266 | |
| 2267 | /** |
| 2268 | * Flag for use with {@link #createPackageContext}: ignore any security |
| 2269 | * restrictions on the Context being requested, allowing it to always |
| 2270 | * be loaded. For use with {@link #CONTEXT_INCLUDE_CODE} to allow code |
| 2271 | * to be loaded into a process even when it isn't safe to do so. Use |
| 2272 | * with extreme care! |
| 2273 | */ |
| 2274 | public static final int CONTEXT_IGNORE_SECURITY = 0x00000002; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2275 | |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 2276 | /** |
| 2277 | * Flag for use with {@link #createPackageContext}: a restricted context may |
| 2278 | * disable specific features. For instance, a View associated with a restricted |
| 2279 | * context would ignore particular XML attributes. |
| 2280 | */ |
| 2281 | public static final int CONTEXT_RESTRICTED = 0x00000004; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2282 | |
| 2283 | /** |
| 2284 | * Return a new Context object for the given application name. This |
| 2285 | * Context is the same as what the named application gets when it is |
| 2286 | * launched, containing the same resources and class loader. Each call to |
| 2287 | * this method returns a new instance of a Context object; Context objects |
| 2288 | * are not shared, however they share common state (Resources, ClassLoader, |
| 2289 | * etc) so the Context instance itself is fairly lightweight. |
| 2290 | * |
| 2291 | * <p>Throws {@link PackageManager.NameNotFoundException} if there is no |
| 2292 | * application with the given package name. |
| 2293 | * |
| 2294 | * <p>Throws {@link java.lang.SecurityException} if the Context requested |
| 2295 | * can not be loaded into the caller's process for security reasons (see |
| 2296 | * {@link #CONTEXT_INCLUDE_CODE} for more information}. |
| 2297 | * |
| 2298 | * @param packageName Name of the application's package. |
| 2299 | * @param flags Option flags, one of {@link #CONTEXT_INCLUDE_CODE} |
| 2300 | * or {@link #CONTEXT_IGNORE_SECURITY}. |
| 2301 | * |
| 2302 | * @return A Context for the application. |
| 2303 | * |
| 2304 | * @throws java.lang.SecurityException |
| 2305 | * @throws PackageManager.NameNotFoundException if there is no application with |
| 2306 | * the given package name |
| 2307 | */ |
| 2308 | public abstract Context createPackageContext(String packageName, |
| 2309 | int flags) throws PackageManager.NameNotFoundException; |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 2310 | |
| 2311 | /** |
| 2312 | * Indicates whether this Context is restricted. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2313 | * |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 2314 | * @return True if this Context is restricted, false otherwise. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2315 | * |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 2316 | * @see #CONTEXT_RESTRICTED |
| 2317 | */ |
| 2318 | public boolean isRestricted() { |
| 2319 | return false; |
| 2320 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2321 | } |