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