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; |
Mathew Inwood | 1c77a11 | 2018-08-14 14:06:26 +0100 | [diff] [blame] | 34 | import android.annotation.UnsupportedAppUsage; |
Jeff Sharkey | 8588bc1 | 2016-01-06 16:47:42 -0700 | [diff] [blame] | 35 | import android.annotation.UserIdInt; |
Selim Cinek | 7fa385a | 2018-01-24 08:35:28 -0800 | [diff] [blame] | 36 | import android.app.ActivityManager; |
Tony Mak | 46aabe5 | 2016-11-14 12:53:06 +0000 | [diff] [blame] | 37 | import android.app.IApplicationThread; |
| 38 | import android.app.IServiceConnection; |
Zak Cohen | 56345f4 | 2017-01-26 13:54:28 -0800 | [diff] [blame] | 39 | import android.app.VrManager; |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 40 | import android.content.pm.ApplicationInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | import android.content.pm.PackageManager; |
| 42 | import android.content.res.AssetManager; |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 43 | import android.content.res.ColorStateList; |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 44 | import android.content.res.Configuration; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 45 | import android.content.res.Resources; |
| 46 | import android.content.res.TypedArray; |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 47 | import android.database.DatabaseErrorHandler; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 48 | import android.database.sqlite.SQLiteDatabase; |
| 49 | import android.database.sqlite.SQLiteDatabase.CursorFactory; |
| 50 | import android.graphics.Bitmap; |
| 51 | import android.graphics.drawable.Drawable; |
Remi NGUYEN VAN | c094a54 | 2018-12-07 16:52:24 +0900 | [diff] [blame] | 52 | import android.net.NetworkStack; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | import android.net.Uri; |
Patrick Baumann | ef4c407 | 2018-02-01 08:54:05 -0800 | [diff] [blame] | 54 | import android.os.Build; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | import android.os.Bundle; |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 56 | import android.os.Environment; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | import android.os.Handler; |
Jeff Sharkey | 8439ac0 | 2017-12-12 17:26:23 -0700 | [diff] [blame] | 58 | import android.os.HandlerExecutor; |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 59 | import android.os.IBinder; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 60 | import android.os.Looper; |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 61 | import android.os.StatFs; |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 62 | import android.os.UserHandle; |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 63 | import android.os.UserManager; |
Jeff Sharkey | 60a82cd | 2017-04-18 18:19:16 -0600 | [diff] [blame] | 64 | import android.os.storage.StorageManager; |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 65 | import android.provider.MediaStore; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 66 | import android.util.AttributeSet; |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 67 | import android.view.Display; |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 68 | import android.view.DisplayAdjustments; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 69 | import android.view.View; |
Jon Miranda | 836c0a8 | 2014-08-11 12:32:26 -0700 | [diff] [blame] | 70 | import android.view.ViewDebug; |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 71 | import android.view.WindowManager; |
Felipe Leme | bb567ae | 2017-10-04 09:56:21 -0700 | [diff] [blame] | 72 | import android.view.autofill.AutofillManager.AutofillClient; |
Abodunrinwa Toki | f001fef | 2017-01-04 23:51:42 +0000 | [diff] [blame] | 73 | import android.view.textclassifier.TextClassificationManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 74 | |
| 75 | import java.io.File; |
| 76 | import java.io.FileInputStream; |
| 77 | import java.io.FileNotFoundException; |
| 78 | import java.io.FileOutputStream; |
| 79 | import java.io.IOException; |
| 80 | import java.io.InputStream; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 81 | import java.lang.annotation.Retention; |
| 82 | import java.lang.annotation.RetentionPolicy; |
Jeff Sharkey | 8439ac0 | 2017-12-12 17:26:23 -0700 | [diff] [blame] | 83 | import java.util.concurrent.Executor; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 84 | |
| 85 | /** |
| 86 | * Interface to global information about an application environment. This is |
| 87 | * an abstract class whose implementation is provided by |
| 88 | * the Android system. It |
| 89 | * allows access to application-specific resources and classes, as well as |
| 90 | * up-calls for application-level operations such as launching activities, |
| 91 | * broadcasting and receiving intents, etc. |
| 92 | */ |
| 93 | public abstract class Context { |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 94 | /** @hide */ |
| 95 | @IntDef(flag = true, prefix = { "MODE_" }, value = { |
| 96 | MODE_PRIVATE, |
| 97 | MODE_WORLD_READABLE, |
| 98 | MODE_WORLD_WRITEABLE, |
| 99 | MODE_APPEND, |
| 100 | }) |
| 101 | @Retention(RetentionPolicy.SOURCE) |
| 102 | public @interface FileMode {} |
| 103 | |
| 104 | /** @hide */ |
| 105 | @IntDef(flag = true, prefix = { "MODE_" }, value = { |
| 106 | MODE_PRIVATE, |
| 107 | MODE_WORLD_READABLE, |
| 108 | MODE_WORLD_WRITEABLE, |
| 109 | MODE_MULTI_PROCESS, |
| 110 | }) |
| 111 | @Retention(RetentionPolicy.SOURCE) |
| 112 | public @interface PreferencesMode {} |
| 113 | |
| 114 | /** @hide */ |
| 115 | @IntDef(flag = true, prefix = { "MODE_" }, value = { |
| 116 | MODE_PRIVATE, |
| 117 | MODE_WORLD_READABLE, |
| 118 | MODE_WORLD_WRITEABLE, |
| 119 | MODE_ENABLE_WRITE_AHEAD_LOGGING, |
| 120 | MODE_NO_LOCALIZED_COLLATORS, |
| 121 | }) |
| 122 | @Retention(RetentionPolicy.SOURCE) |
| 123 | public @interface DatabaseMode {} |
| 124 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 125 | /** |
| 126 | * File creation mode: the default mode, where the created file can only |
| 127 | * be accessed by the calling application (or all applications sharing the |
| 128 | * same user ID). |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 129 | */ |
| 130 | public static final int MODE_PRIVATE = 0x0000; |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 131 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 132 | /** |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 133 | * File creation mode: allow all other applications to have read access to |
| 134 | * the created file. |
| 135 | * <p> |
Dave Friedman | cfe5088 | 2017-07-05 00:40:07 -0700 | [diff] [blame] | 136 | * Starting from {@link android.os.Build.VERSION_CODES#N}, attempting to use this |
| 137 | * mode throws a {@link SecurityException}. |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 138 | * |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 139 | * @deprecated Creating world-readable files is very dangerous, and likely |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 140 | * to cause security holes in applications. It is strongly |
| 141 | * discouraged; instead, applications should use more formal |
| 142 | * mechanism for interactions such as {@link ContentProvider}, |
| 143 | * {@link BroadcastReceiver}, and {@link android.app.Service}. |
| 144 | * There are no guarantees that this access mode will remain on |
| 145 | * a file, such as when it goes through a backup and restore. |
| 146 | * @see android.support.v4.content.FileProvider |
| 147 | * @see Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 148 | */ |
Dianne Hackborn | 556b09e | 2012-09-23 17:46:53 -0700 | [diff] [blame] | 149 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 150 | public static final int MODE_WORLD_READABLE = 0x0001; |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 151 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 152 | /** |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 153 | * File creation mode: allow all other applications to have write access to |
| 154 | * the created file. |
| 155 | * <p> |
Dave Friedman | cfe5088 | 2017-07-05 00:40:07 -0700 | [diff] [blame] | 156 | * 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] | 157 | * mode will throw a {@link SecurityException}. |
| 158 | * |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 159 | * @deprecated Creating world-writable files is very dangerous, and likely |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 160 | * to cause security holes in applications. It is strongly |
| 161 | * discouraged; instead, applications should use more formal |
| 162 | * mechanism for interactions such as {@link ContentProvider}, |
| 163 | * {@link BroadcastReceiver}, and {@link android.app.Service}. |
| 164 | * There are no guarantees that this access mode will remain on |
| 165 | * a file, such as when it goes through a backup and restore. |
| 166 | * @see android.support.v4.content.FileProvider |
| 167 | * @see Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 168 | */ |
Dianne Hackborn | 556b09e | 2012-09-23 17:46:53 -0700 | [diff] [blame] | 169 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 170 | public static final int MODE_WORLD_WRITEABLE = 0x0002; |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 171 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 172 | /** |
| 173 | * File creation mode: for use with {@link #openFileOutput}, if the file |
| 174 | * already exists then write data to the end of the existing file |
| 175 | * instead of erasing it. |
| 176 | * @see #openFileOutput |
| 177 | */ |
| 178 | public static final int MODE_APPEND = 0x8000; |
| 179 | |
| 180 | /** |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 181 | * SharedPreference loading flag: when set, the file on disk will |
| 182 | * be checked for modification even if the shared preferences |
| 183 | * instance is already loaded in this process. This behavior is |
| 184 | * sometimes desired in cases where the application has multiple |
| 185 | * processes, all writing to the same SharedPreferences file. |
| 186 | * Generally there are better forms of communication between |
| 187 | * processes, though. |
| 188 | * |
| 189 | * <p>This was the legacy (but undocumented) behavior in and |
| 190 | * before Gingerbread (Android 2.3) and this flag is implied when |
kopriva | 219f7dc | 2018-10-09 13:42:28 -0700 | [diff] [blame] | 191 | * targeting such releases. For applications targeting SDK |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 192 | * versions <em>greater than</em> Android 2.3, this flag must be |
| 193 | * explicitly set if desired. |
| 194 | * |
| 195 | * @see #getSharedPreferences |
Christopher Tate | d5748b8 | 2015-05-08 18:14:01 -0700 | [diff] [blame] | 196 | * |
| 197 | * @deprecated MODE_MULTI_PROCESS does not work reliably in |
| 198 | * some versions of Android, and furthermore does not provide any |
| 199 | * mechanism for reconciling concurrent modifications across |
| 200 | * processes. Applications should not attempt to use it. Instead, |
| 201 | * they should use an explicit cross-process data management |
| 202 | * approach such as {@link android.content.ContentProvider ContentProvider}. |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 203 | */ |
Christopher Tate | d5748b8 | 2015-05-08 18:14:01 -0700 | [diff] [blame] | 204 | @Deprecated |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 205 | public static final int MODE_MULTI_PROCESS = 0x0004; |
| 206 | |
| 207 | /** |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 208 | * Database open flag: when set, the database is opened with write-ahead |
| 209 | * logging enabled by default. |
| 210 | * |
| 211 | * @see #openOrCreateDatabase(String, int, CursorFactory) |
| 212 | * @see #openOrCreateDatabase(String, int, CursorFactory, DatabaseErrorHandler) |
| 213 | * @see SQLiteDatabase#enableWriteAheadLogging |
| 214 | */ |
| 215 | public static final int MODE_ENABLE_WRITE_AHEAD_LOGGING = 0x0008; |
| 216 | |
Sunny Goyal | a21e6b2 | 2015-12-02 09:51:02 -0800 | [diff] [blame] | 217 | /** |
| 218 | * Database open flag: when set, the database is opened without support for |
| 219 | * localized collators. |
| 220 | * |
| 221 | * @see #openOrCreateDatabase(String, int, CursorFactory) |
| 222 | * @see #openOrCreateDatabase(String, int, CursorFactory, DatabaseErrorHandler) |
| 223 | * @see SQLiteDatabase#NO_LOCALIZED_COLLATORS |
| 224 | */ |
| 225 | public static final int MODE_NO_LOCALIZED_COLLATORS = 0x0010; |
| 226 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 227 | /** @hide */ |
Jeff Sharkey | ce8db99 | 2017-12-13 20:05:05 -0700 | [diff] [blame] | 228 | @IntDef(flag = true, prefix = { "BIND_" }, value = { |
| 229 | BIND_AUTO_CREATE, |
| 230 | BIND_DEBUG_UNBIND, |
| 231 | BIND_NOT_FOREGROUND, |
| 232 | BIND_ABOVE_CLIENT, |
| 233 | BIND_ALLOW_OOM_MANAGEMENT, |
| 234 | BIND_WAIVE_PRIORITY, |
| 235 | BIND_IMPORTANT, |
| 236 | BIND_ADJUST_WITH_ACTIVITY |
| 237 | }) |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 238 | @Retention(RetentionPolicy.SOURCE) |
| 239 | public @interface BindServiceFlags {} |
| 240 | |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 241 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 242 | * Flag for {@link #bindService}: automatically create the service as long |
| 243 | * as the binding exists. Note that while this will create the service, |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 244 | * its {@link android.app.Service#onStartCommand} |
| 245 | * method will still only be called due to an |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 246 | * explicit call to {@link #startService}. Even without that, though, |
| 247 | * this still provides you with access to the service object while the |
| 248 | * service is created. |
| 249 | * |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 250 | * <p>Note that prior to {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, |
| 251 | * not supplying this flag would also impact how important the system |
| 252 | * consider's the target service's process to be. When set, the only way |
| 253 | * for it to be raised was by binding from a service in which case it will |
| 254 | * only be important when that activity is in the foreground. Now to |
| 255 | * achieve this behavior you must explicitly supply the new flag |
| 256 | * {@link #BIND_ADJUST_WITH_ACTIVITY}. For compatibility, old applications |
| 257 | * that don't specify {@link #BIND_AUTO_CREATE} will automatically have |
| 258 | * the flags {@link #BIND_WAIVE_PRIORITY} and |
| 259 | * {@link #BIND_ADJUST_WITH_ACTIVITY} set for them in order to achieve |
| 260 | * the same result. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 261 | */ |
| 262 | public static final int BIND_AUTO_CREATE = 0x0001; |
| 263 | |
| 264 | /** |
| 265 | * Flag for {@link #bindService}: include debugging help for mismatched |
| 266 | * calls to unbind. When this flag is set, the callstack of the following |
| 267 | * {@link #unbindService} call is retained, to be printed if a later |
| 268 | * incorrect unbind call is made. Note that doing this requires retaining |
| 269 | * information about the binding that was made for the lifetime of the app, |
| 270 | * resulting in a leak -- this should only be used for debugging. |
| 271 | */ |
| 272 | public static final int BIND_DEBUG_UNBIND = 0x0002; |
| 273 | |
Dianne Hackborn | 09c916b | 2009-12-08 14:50:51 -0800 | [diff] [blame] | 274 | /** |
| 275 | * Flag for {@link #bindService}: don't allow this binding to raise |
| 276 | * the target service's process to the foreground scheduling priority. |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 277 | * It will still be raised to at least the same memory priority |
Dianne Hackborn | 09c916b | 2009-12-08 14:50:51 -0800 | [diff] [blame] | 278 | * as the client (so that its process will not be killable in any |
| 279 | * situation where the client is not killable), but for CPU scheduling |
| 280 | * purposes it may be left in the background. This only has an impact |
| 281 | * in the situation where the binding client is a foreground process |
| 282 | * and the target service is in a background process. |
| 283 | */ |
| 284 | public static final int BIND_NOT_FOREGROUND = 0x0004; |
| 285 | |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 286 | /** |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 287 | * Flag for {@link #bindService}: indicates that the client application |
| 288 | * binding to this service considers the service to be more important than |
| 289 | * 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] | 290 | * 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] | 291 | * this is not guaranteed to be the case. |
| 292 | */ |
| 293 | public static final int BIND_ABOVE_CLIENT = 0x0008; |
| 294 | |
| 295 | /** |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 296 | * Flag for {@link #bindService}: allow the process hosting the bound |
| 297 | * service to go through its normal memory management. It will be |
| 298 | * treated more like a running service, allowing the system to |
| 299 | * (temporarily) expunge the process if low on memory or for some other |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 300 | * whim it may have, and being more aggressive about making it a candidate |
| 301 | * to be killed (and restarted) if running for a long time. |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 302 | */ |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 303 | public static final int BIND_ALLOW_OOM_MANAGEMENT = 0x0010; |
| 304 | |
| 305 | /** |
| 306 | * Flag for {@link #bindService}: don't impact the scheduling or |
| 307 | * memory management priority of the target service's hosting process. |
| 308 | * Allows the service's process to be managed on the background LRU list |
| 309 | * just like a regular application process in the background. |
| 310 | */ |
| 311 | public static final int BIND_WAIVE_PRIORITY = 0x0020; |
| 312 | |
| 313 | /** |
| 314 | * Flag for {@link #bindService}: this service is very important to |
| 315 | * the client, so should be brought to the foreground process level |
| 316 | * when the client is. Normally a process can only be raised to the |
| 317 | * visibility level by a client, even if that client is in the foreground. |
| 318 | */ |
| 319 | public static final int BIND_IMPORTANT = 0x0040; |
| 320 | |
| 321 | /** |
| 322 | * Flag for {@link #bindService}: If binding from an activity, allow the |
| 323 | * target service's process importance to be raised based on whether the |
| 324 | * activity is visible to the user, regardless whether another flag is |
| 325 | * used to reduce the amount that the client process's overall importance |
| 326 | * is used to impact it. |
| 327 | */ |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 328 | public static final int BIND_ADJUST_WITH_ACTIVITY = 0x0080; |
| 329 | |
| 330 | /** |
Amith Yamasani | b735830 | 2018-09-05 18:52:35 -0700 | [diff] [blame] | 331 | * Flag for {@link #bindService}: If binding from something better than perceptible, |
| 332 | * still set the adjust below perceptible. This would be used for bound services that can |
| 333 | * afford to be evicted when under extreme memory pressure, but should be restarted as soon |
| 334 | * as possible. |
| 335 | * @hide |
| 336 | */ |
| 337 | public static final int BIND_ADJUST_BELOW_PERCEPTIBLE = 0x0100; |
| 338 | |
| 339 | /** |
Svet Ganov | d223db3 | 2017-12-22 09:43:48 -0800 | [diff] [blame] | 340 | * @hide Flag for {@link #bindService}: allows binding to a service provided |
| 341 | * by an instant app. Note that the caller may not have access to the instant |
| 342 | * app providing the service which is a violation of the instant app sandbox. |
| 343 | * This flag is intended ONLY for development/testing and should be used with |
| 344 | * great care. Only the system is allowed to use this flag. |
| 345 | */ |
| 346 | public static final int BIND_ALLOW_INSTANT = 0x00400000; |
| 347 | |
| 348 | /** |
Dianne Hackborn | 83b40f6 | 2017-04-26 13:59:47 -0700 | [diff] [blame] | 349 | * @hide Flag for {@link #bindService}: like {@link #BIND_NOT_FOREGROUND}, but puts it |
| 350 | * up in to the important background state (instead of transient). |
| 351 | */ |
| 352 | public static final int BIND_IMPORTANT_BACKGROUND = 0x00800000; |
| 353 | |
| 354 | /** |
Felipe Leme | a1b79bf | 2016-05-24 13:06:54 -0700 | [diff] [blame] | 355 | * @hide Flag for {@link #bindService}: allows application hosting service to manage whitelists |
| 356 | * such as temporary allowing a {@code PendingIntent} to bypass Power Save mode. |
| 357 | */ |
| 358 | public static final int BIND_ALLOW_WHITELIST_MANAGEMENT = 0x01000000; |
| 359 | |
| 360 | /** |
Dianne Hackborn | d69e4c1 | 2015-04-24 09:54:54 -0700 | [diff] [blame] | 361 | * @hide Flag for {@link #bindService}: Like {@link #BIND_FOREGROUND_SERVICE}, |
| 362 | * but only applies while the device is awake. |
| 363 | */ |
| 364 | public static final int BIND_FOREGROUND_SERVICE_WHILE_AWAKE = 0x02000000; |
| 365 | |
| 366 | /** |
| 367 | * @hide Flag for {@link #bindService}: For only the case where the binding |
| 368 | * is coming from the system, set the process state to FOREGROUND_SERVICE |
| 369 | * instead of the normal maximum of IMPORTANT_FOREGROUND. That is, this is |
| 370 | * saying that the process shouldn't participate in the normal power reduction |
| 371 | * modes (removing network access etc). |
| 372 | */ |
| 373 | public static final int BIND_FOREGROUND_SERVICE = 0x04000000; |
| 374 | |
| 375 | /** |
Dianne Hackborn | f0f94d1 | 2014-03-17 16:04:21 -0700 | [diff] [blame] | 376 | * @hide Flag for {@link #bindService}: Treat the binding as hosting |
| 377 | * an activity, an unbinding as the activity going in the background. |
| 378 | * That is, when unbinding, the process when empty will go on the activity |
| 379 | * LRU list instead of the regular one, keeping it around more aggressively |
| 380 | * than it otherwise would be. This is intended for use with IMEs to try |
| 381 | * to keep IME processes around for faster keyboard switching. |
| 382 | */ |
| 383 | public static final int BIND_TREAT_LIKE_ACTIVITY = 0x08000000; |
| 384 | |
| 385 | /** |
Dianne Hackborn | b12e135 | 2012-09-26 11:39:20 -0700 | [diff] [blame] | 386 | * @hide An idea that is not yet implemented. |
| 387 | * Flag for {@link #bindService}: If binding from an activity, consider |
| 388 | * this service to be visible like the binding activity is. That is, |
| 389 | * it will be treated as something more important to keep around than |
| 390 | * invisible background activities. This will impact the number of |
| 391 | * recent activities the user can switch between without having them |
| 392 | * restart. There is no guarantee this will be respected, as the system |
| 393 | * tries to balance such requests from one app vs. the importantance of |
| 394 | * keeping other apps around. |
| 395 | */ |
Dianne Hackborn | c823051 | 2013-07-13 21:32:12 -0700 | [diff] [blame] | 396 | public static final int BIND_VISIBLE = 0x10000000; |
| 397 | |
| 398 | /** |
| 399 | * @hide |
| 400 | * Flag for {@link #bindService}: Consider this binding to be causing the target |
| 401 | * process to be showing UI, so it will be do a UI_HIDDEN memory trim when it goes |
| 402 | * away. |
| 403 | */ |
| 404 | public static final int BIND_SHOWING_UI = 0x20000000; |
Dianne Hackborn | b12e135 | 2012-09-26 11:39:20 -0700 | [diff] [blame] | 405 | |
| 406 | /** |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 407 | * Flag for {@link #bindService}: Don't consider the bound service to be |
| 408 | * visible, even if the caller is visible. |
| 409 | * @hide |
| 410 | */ |
| 411 | public static final int BIND_NOT_VISIBLE = 0x40000000; |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 412 | |
Alan Viverette | 713a5cd | 2015-12-16 15:46:32 -0500 | [diff] [blame] | 413 | /** |
Robert Sesek | b9a8666 | 2015-12-09 16:22:45 -0500 | [diff] [blame] | 414 | * Flag for {@link #bindService}: The service being bound is an |
| 415 | * {@link android.R.attr#isolatedProcess isolated}, |
| 416 | * {@link android.R.attr#externalService external} service. This binds the service into the |
| 417 | * 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] | 418 | * <p> |
| 419 | * When using this flag, the code for the service being bound will execute under the calling |
| 420 | * application's package name and user ID. Because the service must be an isolated process, |
| 421 | * it will not have direct access to the application's data, though. |
| 422 | * |
| 423 | * The purpose of this flag is to allow applications to provide services that are attributed |
| 424 | * to the app using the service, rather than the application providing the service. |
| 425 | * </p> |
Robert Sesek | b9a8666 | 2015-12-09 16:22:45 -0500 | [diff] [blame] | 426 | */ |
| 427 | public static final int BIND_EXTERNAL_SERVICE = 0x80000000; |
| 428 | |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 429 | /** @hide */ |
Jeff Sharkey | ce8db99 | 2017-12-13 20:05:05 -0700 | [diff] [blame] | 430 | @IntDef(flag = true, prefix = { "RECEIVER_VISIBLE_" }, value = { |
| 431 | RECEIVER_VISIBLE_TO_INSTANT_APPS |
| 432 | }) |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 433 | @Retention(RetentionPolicy.SOURCE) |
| 434 | public @interface RegisterReceiverFlags {} |
| 435 | |
| 436 | /** |
| 437 | * Flag for {@link #registerReceiver}: The receiver can receive broadcasts from Instant Apps. |
| 438 | */ |
| 439 | public static final int RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x1; |
| 440 | |
Robert Sesek | b9a8666 | 2015-12-09 16:22:45 -0500 | [diff] [blame] | 441 | /** |
Alan Viverette | 713a5cd | 2015-12-16 15:46:32 -0500 | [diff] [blame] | 442 | * Returns an AssetManager instance for the application's package. |
| 443 | * <p> |
| 444 | * <strong>Note:</strong> Implementations of this method should return |
| 445 | * an AssetManager instance that is consistent with the Resources instance |
| 446 | * returned by {@link #getResources()}. For example, they should share the |
| 447 | * same {@link Configuration} object. |
| 448 | * |
| 449 | * @return an AssetManager instance for the application's package |
| 450 | * @see #getResources() |
| 451 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 452 | public abstract AssetManager getAssets(); |
| 453 | |
Alan Viverette | 713a5cd | 2015-12-16 15:46:32 -0500 | [diff] [blame] | 454 | /** |
| 455 | * Returns a Resources instance for the application's package. |
| 456 | * <p> |
| 457 | * <strong>Note:</strong> Implementations of this method should return |
| 458 | * a Resources instance that is consistent with the AssetManager instance |
| 459 | * returned by {@link #getAssets()}. For example, they should share the |
| 460 | * same {@link Configuration} object. |
| 461 | * |
| 462 | * @return a Resources instance for the application's package |
| 463 | * @see #getAssets() |
| 464 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 465 | public abstract Resources getResources(); |
| 466 | |
| 467 | /** Return PackageManager instance to find global package information. */ |
| 468 | public abstract PackageManager getPackageManager(); |
| 469 | |
| 470 | /** Return a ContentResolver instance for your application's package. */ |
| 471 | public abstract ContentResolver getContentResolver(); |
| 472 | |
| 473 | /** |
| 474 | * Return the Looper for the main thread of the current process. This is |
| 475 | * the thread used to dispatch calls to application components (activities, |
| 476 | * services, etc). |
Jeff Brown | f9e989d | 2013-04-04 23:04:03 -0700 | [diff] [blame] | 477 | * <p> |
| 478 | * By definition, this method returns the same result as would be obtained |
| 479 | * by calling {@link Looper#getMainLooper() Looper.getMainLooper()}. |
| 480 | * </p> |
| 481 | * |
| 482 | * @return The main looper. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 483 | */ |
| 484 | public abstract Looper getMainLooper(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 485 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 486 | /** |
Jeff Sharkey | 8439ac0 | 2017-12-12 17:26:23 -0700 | [diff] [blame] | 487 | * Return an {@link Executor} that will run enqueued tasks on the main |
| 488 | * thread associated with this context. This is the thread used to dispatch |
| 489 | * calls to application components (activities, services, etc). |
| 490 | */ |
| 491 | public Executor getMainExecutor() { |
| 492 | // This is pretty inefficient, which is why ContextImpl overrides it |
| 493 | return new HandlerExecutor(new Handler(getMainLooper())); |
| 494 | } |
| 495 | |
| 496 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 497 | * Return the context of the single, global Application object of the |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 498 | * current process. This generally should only be used if you need a |
| 499 | * Context whose lifecycle is separate from the current context, that is |
| 500 | * tied to the lifetime of the process rather than the current component. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 501 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 502 | * <p>Consider for example how this interacts with |
Brad Fitzpatrick | 36af794 | 2010-12-08 11:31:07 -0800 | [diff] [blame] | 503 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter)}: |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 504 | * <ul> |
| 505 | * <li> <p>If used from an Activity context, the receiver is being registered |
| 506 | * within that activity. This means that you are expected to unregister |
| 507 | * before the activity is done being destroyed; in fact if you do not do |
| 508 | * so, the framework will clean up your leaked registration as it removes |
| 509 | * the activity and log an error. Thus, if you use the Activity context |
| 510 | * to register a receiver that is static (global to the process, not |
| 511 | * associated with an Activity instance) then that registration will be |
| 512 | * removed on you at whatever point the activity you used is destroyed. |
| 513 | * <li> <p>If used from the Context returned here, the receiver is being |
| 514 | * registered with the global state associated with your application. Thus |
| 515 | * it will never be unregistered for you. This is necessary if the receiver |
| 516 | * is associated with static data, not a particular component. However |
| 517 | * using the ApplicationContext elsewhere can easily lead to serious leaks |
| 518 | * if you forget to unregister, unbind, etc. |
| 519 | * </ul> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 520 | */ |
| 521 | public abstract Context getApplicationContext(); |
| 522 | |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 523 | /** Non-activity related autofill ids are unique in the app */ |
| 524 | private static int sLastAutofillId = View.NO_ID; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 525 | |
| 526 | /** |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 527 | * Gets the next autofill ID. |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 528 | * |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 529 | * <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] | 530 | * returned will be unique. |
| 531 | * |
| 532 | * @return A ID that is unique in the process |
| 533 | * |
| 534 | * {@hide} |
| 535 | */ |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 536 | public int getNextAutofillId() { |
| 537 | if (sLastAutofillId == View.LAST_APP_AUTOFILL_ID - 1) { |
| 538 | sLastAutofillId = View.NO_ID; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 539 | } |
| 540 | |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 541 | sLastAutofillId++; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 542 | |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 543 | return sLastAutofillId; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 544 | } |
| 545 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 546 | /** |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 547 | * Add a new {@link ComponentCallbacks} to the base application of the |
| 548 | * Context, which will be called at the same times as the ComponentCallbacks |
| 549 | * methods of activities and other components are called. Note that you |
| 550 | * <em>must</em> be sure to use {@link #unregisterComponentCallbacks} when |
| 551 | * appropriate in the future; this will not be removed for you. |
Dianne Hackborn | 905577f | 2011-09-07 18:31:28 -0700 | [diff] [blame] | 552 | * |
| 553 | * @param callback The interface to call. This can be either a |
| 554 | * {@link ComponentCallbacks} or {@link ComponentCallbacks2} interface. |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 555 | */ |
| 556 | public void registerComponentCallbacks(ComponentCallbacks callback) { |
| 557 | getApplicationContext().registerComponentCallbacks(callback); |
| 558 | } |
| 559 | |
| 560 | /** |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 561 | * Remove a {@link ComponentCallbacks} object that was previously registered |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 562 | * with {@link #registerComponentCallbacks(ComponentCallbacks)}. |
| 563 | */ |
| 564 | public void unregisterComponentCallbacks(ComponentCallbacks callback) { |
| 565 | getApplicationContext().unregisterComponentCallbacks(callback); |
| 566 | } |
| 567 | |
| 568 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 569 | * Return a localized, styled CharSequence from the application's package's |
| 570 | * default string table. |
| 571 | * |
| 572 | * @param resId Resource id for the CharSequence text |
| 573 | */ |
Chris Craik | ceb2693 | 2018-02-01 15:51:34 -0800 | [diff] [blame] | 574 | @NonNull |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 575 | public final CharSequence getText(@StringRes int resId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 576 | return getResources().getText(resId); |
| 577 | } |
| 578 | |
| 579 | /** |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 580 | * 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] | 581 | * default string table. |
| 582 | * |
| 583 | * @param resId Resource id for the string |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 584 | * @return The string data associated with the resource, stripped of styled |
| 585 | * text information. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 586 | */ |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 587 | @NonNull |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 588 | public final String getString(@StringRes int resId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 589 | return getResources().getString(resId); |
| 590 | } |
| 591 | |
| 592 | /** |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 593 | * 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] | 594 | * default string table, substituting the format arguments as defined in |
| 595 | * {@link java.util.Formatter} and {@link java.lang.String#format}. |
| 596 | * |
| 597 | * @param resId Resource id for the format string |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 598 | * @param formatArgs The format arguments that will be used for |
| 599 | * substitution. |
| 600 | * @return The string data associated with the resource, formatted and |
| 601 | * stripped of styled text information. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 602 | */ |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 603 | @NonNull |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 604 | public final String getString(@StringRes int resId, Object... formatArgs) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 605 | return getResources().getString(resId, formatArgs); |
| 606 | } |
| 607 | |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 608 | /** |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 609 | * Returns a color associated with a particular resource ID and styled for |
| 610 | * 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 single color value in the form 0xAARRGGBB. |
| 616 | * @throws android.content.res.Resources.NotFoundException if the given ID |
| 617 | * does not exist. |
| 618 | */ |
Tor Norbye | 3e4cda7 | 2015-06-10 08:14:31 -0700 | [diff] [blame] | 619 | @ColorInt |
| 620 | public final int getColor(@ColorRes int id) { |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 621 | return getResources().getColor(id, getTheme()); |
| 622 | } |
| 623 | |
| 624 | /** |
| 625 | * Returns a drawable object associated with a particular resource ID and |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 626 | * styled for the current theme. |
| 627 | * |
| 628 | * @param id The desired resource identifier, as generated by the aapt |
| 629 | * tool. This integer encodes the package, type, and resource |
| 630 | * entry. The value 0 is an invalid identifier. |
Chris Craik | ceb2693 | 2018-02-01 15:51:34 -0800 | [diff] [blame] | 631 | * @return An object that can be used to draw this resource. |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 632 | * @throws android.content.res.Resources.NotFoundException if the given ID |
| 633 | * does not exist. |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 634 | */ |
Chris Craik | 1194b0b | 2018-03-23 13:36:24 -0700 | [diff] [blame] | 635 | @Nullable |
Tor Norbye | 3e4cda7 | 2015-06-10 08:14:31 -0700 | [diff] [blame] | 636 | public final Drawable getDrawable(@DrawableRes int id) { |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 637 | return getResources().getDrawable(id, getTheme()); |
| 638 | } |
| 639 | |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 640 | /** |
| 641 | * Returns a color state list associated with a particular resource ID and |
| 642 | * styled for the current theme. |
| 643 | * |
| 644 | * @param id The desired resource identifier, as generated by the aapt |
| 645 | * tool. This integer encodes the package, type, and resource |
| 646 | * entry. The value 0 is an invalid identifier. |
Chris Craik | ceb2693 | 2018-02-01 15:51:34 -0800 | [diff] [blame] | 647 | * @return A color state list. |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 648 | * @throws android.content.res.Resources.NotFoundException if the given ID |
| 649 | * does not exist. |
| 650 | */ |
Chris Craik | ceb2693 | 2018-02-01 15:51:34 -0800 | [diff] [blame] | 651 | @NonNull |
Tor Norbye | 3e4cda7 | 2015-06-10 08:14:31 -0700 | [diff] [blame] | 652 | public final ColorStateList getColorStateList(@ColorRes int id) { |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 653 | return getResources().getColorStateList(id, getTheme()); |
| 654 | } |
| 655 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 656 | /** |
| 657 | * Set the base theme for this context. Note that this should be called |
| 658 | * before any views are instantiated in the Context (for example before |
| 659 | * calling {@link android.app.Activity#setContentView} or |
| 660 | * {@link android.view.LayoutInflater#inflate}). |
| 661 | * |
| 662 | * @param resid The style resource describing the theme. |
| 663 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 664 | public abstract void setTheme(@StyleRes int resid); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 665 | |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 666 | /** @hide Needed for some internal implementation... not public because |
| 667 | * you can't assume this actually means anything. */ |
Mathew Inwood | 1c77a11 | 2018-08-14 14:06:26 +0100 | [diff] [blame] | 668 | @UnsupportedAppUsage |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 669 | public int getThemeResId() { |
| 670 | return 0; |
| 671 | } |
| 672 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 673 | /** |
| 674 | * Return the Theme object associated with this Context. |
| 675 | */ |
Jon Miranda | 836c0a8 | 2014-08-11 12:32:26 -0700 | [diff] [blame] | 676 | @ViewDebug.ExportedProperty(deepExport = true) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 677 | public abstract Resources.Theme getTheme(); |
| 678 | |
| 679 | /** |
| 680 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 681 | * {@link android.content.res.Resources.Theme#obtainStyledAttributes(int[])} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 682 | * for more information. |
| 683 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 684 | * @see android.content.res.Resources.Theme#obtainStyledAttributes(int[]) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 685 | */ |
Tor Norbye | c91531a | 2015-04-01 17:41:55 -0700 | [diff] [blame] | 686 | public final TypedArray obtainStyledAttributes(@StyleableRes int[] attrs) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 687 | return getTheme().obtainStyledAttributes(attrs); |
| 688 | } |
| 689 | |
| 690 | /** |
| 691 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 692 | * {@link android.content.res.Resources.Theme#obtainStyledAttributes(int, int[])} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 693 | * for more information. |
| 694 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 695 | * @see android.content.res.Resources.Theme#obtainStyledAttributes(int, int[]) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 696 | */ |
| 697 | public final TypedArray obtainStyledAttributes( |
Tor Norbye | c91531a | 2015-04-01 17:41:55 -0700 | [diff] [blame] | 698 | @StyleRes int resid, @StyleableRes int[] attrs) throws Resources.NotFoundException { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 699 | return getTheme().obtainStyledAttributes(resid, attrs); |
| 700 | } |
| 701 | |
| 702 | /** |
| 703 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 704 | * {@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] | 705 | * for more information. |
| 706 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 707 | * @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] | 708 | */ |
| 709 | public final TypedArray obtainStyledAttributes( |
Tor Norbye | c91531a | 2015-04-01 17:41:55 -0700 | [diff] [blame] | 710 | AttributeSet set, @StyleableRes int[] attrs) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 711 | return getTheme().obtainStyledAttributes(set, attrs, 0, 0); |
| 712 | } |
| 713 | |
| 714 | /** |
| 715 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 716 | * {@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] | 717 | * for more information. |
| 718 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 719 | * @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] | 720 | */ |
| 721 | public final TypedArray obtainStyledAttributes( |
Tor Norbye | c91531a | 2015-04-01 17:41:55 -0700 | [diff] [blame] | 722 | AttributeSet set, @StyleableRes int[] attrs, @AttrRes int defStyleAttr, |
| 723 | @StyleRes int defStyleRes) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 724 | return getTheme().obtainStyledAttributes( |
| 725 | set, attrs, defStyleAttr, defStyleRes); |
| 726 | } |
| 727 | |
| 728 | /** |
| 729 | * Return a class loader you can use to retrieve classes in this package. |
| 730 | */ |
| 731 | public abstract ClassLoader getClassLoader(); |
| 732 | |
| 733 | /** Return the name of this application's package. */ |
| 734 | public abstract String getPackageName(); |
| 735 | |
Dianne Hackborn | d8e1dbb | 2013-01-17 17:47:37 -0800 | [diff] [blame] | 736 | /** @hide Return the name of the base context this context is derived from. */ |
Mathew Inwood | 1c77a11 | 2018-08-14 14:06:26 +0100 | [diff] [blame] | 737 | @UnsupportedAppUsage |
Dianne Hackborn | d8e1dbb | 2013-01-17 17:47:37 -0800 | [diff] [blame] | 738 | public abstract String getBasePackageName(); |
| 739 | |
Dianne Hackborn | 95d7853 | 2013-09-11 09:51:14 -0700 | [diff] [blame] | 740 | /** @hide Return the package name that should be used for app ops calls from |
| 741 | * this context. This is the same as {@link #getBasePackageName()} except in |
| 742 | * cases where system components are loaded into other app processes, in which |
| 743 | * case this will be the name of the primary package in that process (so that app |
| 744 | * ops uid verification will work with the name). */ |
Mathew Inwood | 1c77a11 | 2018-08-14 14:06:26 +0100 | [diff] [blame] | 745 | @UnsupportedAppUsage |
Dianne Hackborn | 95d7853 | 2013-09-11 09:51:14 -0700 | [diff] [blame] | 746 | public abstract String getOpPackageName(); |
| 747 | |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 748 | /** Return the full application info for this context's package. */ |
| 749 | public abstract ApplicationInfo getApplicationInfo(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 750 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 751 | /** |
Kenny Root | 3214839 | 2010-01-21 15:40:47 -0800 | [diff] [blame] | 752 | * Return the full path to this context's primary Android package. |
| 753 | * The Android package is a ZIP file which contains the application's |
| 754 | * primary resources. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 755 | * |
| 756 | * <p>Note: this is not generally useful for applications, since they should |
| 757 | * not be directly accessing the file system. |
| 758 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 759 | * @return String Path to the resources. |
| 760 | */ |
| 761 | public abstract String getPackageResourcePath(); |
| 762 | |
| 763 | /** |
Kenny Root | 3214839 | 2010-01-21 15:40:47 -0800 | [diff] [blame] | 764 | * Return the full path to this context's primary Android package. |
| 765 | * The Android package is a ZIP file which contains application's |
| 766 | * primary code and assets. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 767 | * |
| 768 | * <p>Note: this is not generally useful for applications, since they should |
| 769 | * not be directly accessing the file system. |
| 770 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 771 | * @return String Path to the code and assets. |
| 772 | */ |
| 773 | public abstract String getPackageCodePath(); |
| 774 | |
| 775 | /** |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 776 | * @hide |
| 777 | * @deprecated use {@link #getSharedPreferencesPath(String)} |
Joe Onorato | 23ecae3 | 2009-06-10 17:07:15 -0700 | [diff] [blame] | 778 | */ |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 779 | @Deprecated |
Mathew Inwood | 1c77a11 | 2018-08-14 14:06:26 +0100 | [diff] [blame] | 780 | @UnsupportedAppUsage |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 781 | public File getSharedPrefsFile(String name) { |
| 782 | return getSharedPreferencesPath(name); |
| 783 | } |
Joe Onorato | 23ecae3 | 2009-06-10 17:07:15 -0700 | [diff] [blame] | 784 | |
| 785 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 786 | * Retrieve and hold the contents of the preferences file 'name', returning |
| 787 | * a SharedPreferences through which you can retrieve and modify its |
| 788 | * values. Only one instance of the SharedPreferences object is returned |
| 789 | * to any callers for the same name, meaning they will see each other's |
| 790 | * edits as soon as they are made. |
| 791 | * |
Jonathan Dormody | 1bca5db | 2017-11-16 11:25:20 -0700 | [diff] [blame] | 792 | * This method is thead-safe. |
| 793 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 794 | * @param name Desired preferences file. If a preferences file by this name |
| 795 | * does not exist, it will be created when you retrieve an |
| 796 | * editor (SharedPreferences.edit()) and then commit changes (Editor.commit()). |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 797 | * @param mode Operating mode. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 798 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 799 | * @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] | 800 | * to retrieve and modify the preference values. |
| 801 | * |
| 802 | * @see #MODE_PRIVATE |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 803 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 804 | public abstract SharedPreferences getSharedPreferences(String name, @PreferencesMode int mode); |
Jeff Sharkey | 8fc29cf | 2015-11-30 17:51:00 -0700 | [diff] [blame] | 805 | |
| 806 | /** |
| 807 | * Retrieve and hold the contents of the preferences file, returning |
| 808 | * a SharedPreferences through which you can retrieve and modify its |
| 809 | * values. Only one instance of the SharedPreferences object is returned |
| 810 | * to any callers for the same name, meaning they will see each other's |
| 811 | * edits as soon as they are made. |
| 812 | * |
| 813 | * @param file Desired preferences file. If a preferences file by this name |
| 814 | * does not exist, it will be created when you retrieve an |
| 815 | * editor (SharedPreferences.edit()) and then commit changes (Editor.commit()). |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 816 | * @param mode Operating mode. |
Jeff Sharkey | 8fc29cf | 2015-11-30 17:51:00 -0700 | [diff] [blame] | 817 | * |
| 818 | * @return The single {@link SharedPreferences} instance that can be used |
| 819 | * to retrieve and modify the preference values. |
| 820 | * |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 821 | * @see #getSharedPreferencesPath(String) |
Jeff Sharkey | 8fc29cf | 2015-11-30 17:51:00 -0700 | [diff] [blame] | 822 | * @see #MODE_PRIVATE |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 823 | * @removed |
Jeff Sharkey | 8fc29cf | 2015-11-30 17:51:00 -0700 | [diff] [blame] | 824 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 825 | public abstract SharedPreferences getSharedPreferences(File file, @PreferencesMode int mode); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 826 | |
| 827 | /** |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 828 | * Move an existing shared preferences file from the given source storage |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 829 | * context to this context. This is typically used to migrate data between |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 830 | * storage locations after an upgrade, such as moving to device protected |
| 831 | * storage. |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 832 | * |
| 833 | * @param sourceContext The source context which contains the existing |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 834 | * shared preferences to move. |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 835 | * @param name The name of the shared preferences file. |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 836 | * @return {@code true} if the move was successful or if the shared |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 837 | * preferences didn't exist in the source context, otherwise |
| 838 | * {@code false}. |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 839 | * @see #createDeviceProtectedStorageContext() |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 840 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 841 | public abstract boolean moveSharedPreferencesFrom(Context sourceContext, String name); |
| 842 | |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 843 | /** |
| 844 | * Delete an existing shared preferences file. |
| 845 | * |
| 846 | * @param name The name (unique in the application package) of the shared |
| 847 | * preferences file. |
| 848 | * @return {@code true} if the shared preferences file was successfully |
| 849 | * deleted; else {@code false}. |
| 850 | * @see #getSharedPreferences(String, int) |
| 851 | */ |
| 852 | public abstract boolean deleteSharedPreferences(String name); |
| 853 | |
Christopher Tate | fe2368c | 2017-05-17 15:42:35 -0700 | [diff] [blame] | 854 | /** @hide */ |
| 855 | public abstract void reloadSharedPreferences(); |
| 856 | |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 857 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 858 | * Open a private file associated with this Context's application package |
| 859 | * for reading. |
| 860 | * |
| 861 | * @param name The name of the file to open; can not contain path |
| 862 | * separators. |
| 863 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 864 | * @return The resulting {@link FileInputStream}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 865 | * |
| 866 | * @see #openFileOutput |
| 867 | * @see #fileList |
| 868 | * @see #deleteFile |
| 869 | * @see java.io.FileInputStream#FileInputStream(String) |
| 870 | */ |
| 871 | public abstract FileInputStream openFileInput(String name) |
| 872 | throws FileNotFoundException; |
| 873 | |
| 874 | /** |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 875 | * Open a private file associated with this Context's application package |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 876 | * for writing. Creates the file if it doesn't already exist. |
| 877 | * <p> |
| 878 | * No additional permissions are required for the calling app to read or |
| 879 | * write the returned file. |
Ricardo Cervera | 90a5f98 | 2014-04-04 10:26:05 -0700 | [diff] [blame] | 880 | * |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 881 | * @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] | 882 | * separators. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 883 | * @param mode Operating mode. |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 884 | * @return The resulting {@link FileOutputStream}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 885 | * @see #MODE_APPEND |
| 886 | * @see #MODE_PRIVATE |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 887 | * @see #openFileInput |
| 888 | * @see #fileList |
| 889 | * @see #deleteFile |
| 890 | * @see java.io.FileOutputStream#FileOutputStream(String) |
| 891 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 892 | public abstract FileOutputStream openFileOutput(String name, @FileMode int mode) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 893 | throws FileNotFoundException; |
| 894 | |
| 895 | /** |
| 896 | * Delete the given private file associated with this Context's |
| 897 | * application package. |
| 898 | * |
| 899 | * @param name The name of the file to delete; can not contain path |
| 900 | * separators. |
| 901 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 902 | * @return {@code true} if the file was successfully deleted; else |
| 903 | * {@code false}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 904 | * |
| 905 | * @see #openFileInput |
| 906 | * @see #openFileOutput |
| 907 | * @see #fileList |
| 908 | * @see java.io.File#delete() |
| 909 | */ |
| 910 | public abstract boolean deleteFile(String name); |
| 911 | |
| 912 | /** |
| 913 | * Returns the absolute path on the filesystem where a file created with |
| 914 | * {@link #openFileOutput} is stored. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 915 | * <p> |
| 916 | * The returned path may change over time if the calling app is moved to an |
| 917 | * 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] | 918 | * |
| 919 | * @param name The name of the file for which you would like to get |
| 920 | * its path. |
| 921 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 922 | * @return An absolute path to the given file. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 923 | * |
| 924 | * @see #openFileOutput |
| 925 | * @see #getFilesDir |
| 926 | * @see #getDir |
| 927 | */ |
| 928 | public abstract File getFileStreamPath(String name); |
| 929 | |
| 930 | /** |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 931 | * Returns the absolute path on the filesystem where a file created with |
| 932 | * {@link #getSharedPreferences(String, int)} is stored. |
| 933 | * <p> |
| 934 | * The returned path may change over time if the calling app is moved to an |
| 935 | * adopted storage device, so only relative paths should be persisted. |
| 936 | * |
| 937 | * @param name The name of the shared preferences for which you would like |
| 938 | * to get a path. |
| 939 | * @return An absolute path to the given file. |
| 940 | * @see #getSharedPreferences(String, int) |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 941 | * @removed |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 942 | */ |
| 943 | public abstract File getSharedPreferencesPath(String name); |
| 944 | |
| 945 | /** |
Jeff Sharkey | 2c1ba9a | 2016-02-17 15:29:38 -0700 | [diff] [blame] | 946 | * Returns the absolute path to the directory on the filesystem where all |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 947 | * private files belonging to this app are stored. Apps should not use this |
| 948 | * path directly; they should instead use {@link #getFilesDir()}, |
| 949 | * {@link #getCacheDir()}, {@link #getDir(String, int)}, or other storage |
| 950 | * APIs on this class. |
Jeff Sharkey | 2c1ba9a | 2016-02-17 15:29:38 -0700 | [diff] [blame] | 951 | * <p> |
| 952 | * The returned path may change over time if the calling app is moved to an |
| 953 | * adopted storage device, so only relative paths should be persisted. |
| 954 | * <p> |
| 955 | * No additional permissions are required for the calling app to read or |
| 956 | * write files under the returned path. |
| 957 | * |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 958 | * @see ApplicationInfo#dataDir |
Jeff Sharkey | 2c1ba9a | 2016-02-17 15:29:38 -0700 | [diff] [blame] | 959 | */ |
| 960 | public abstract File getDataDir(); |
| 961 | |
| 962 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 963 | * Returns the absolute path to the directory on the filesystem where files |
| 964 | * created with {@link #openFileOutput} are stored. |
| 965 | * <p> |
| 966 | * The returned path may change over time if the calling app is moved to an |
| 967 | * adopted storage device, so only relative paths should be persisted. |
| 968 | * <p> |
| 969 | * No additional permissions are required for the calling app to read or |
| 970 | * write files under the returned path. |
Ricardo Cervera | 90a5f98 | 2014-04-04 10:26:05 -0700 | [diff] [blame] | 971 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 972 | * @return The path of the directory holding application files. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 973 | * @see #openFileOutput |
| 974 | * @see #getFileStreamPath |
| 975 | * @see #getDir |
| 976 | */ |
| 977 | public abstract File getFilesDir(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 978 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 979 | /** |
Christopher Tate | a7835b6 | 2014-07-11 17:25:57 -0700 | [diff] [blame] | 980 | * Returns the absolute path to the directory on the filesystem similar to |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 981 | * {@link #getFilesDir()}. The difference is that files placed under this |
| 982 | * directory will be excluded from automatic backup to remote storage. See |
Christopher Tate | a7835b6 | 2014-07-11 17:25:57 -0700 | [diff] [blame] | 983 | * {@link android.app.backup.BackupAgent BackupAgent} for a full discussion |
| 984 | * of the automatic backup mechanism in Android. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 985 | * <p> |
| 986 | * The returned path may change over time if the calling app is moved to an |
| 987 | * adopted storage device, so only relative paths should be persisted. |
| 988 | * <p> |
| 989 | * No additional permissions are required for the calling app to read or |
| 990 | * write files under the returned path. |
Christopher Tate | a7835b6 | 2014-07-11 17:25:57 -0700 | [diff] [blame] | 991 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 992 | * @return The path of the directory holding application files that will not |
| 993 | * be automatically backed up to remote storage. |
Christopher Tate | a7835b6 | 2014-07-11 17:25:57 -0700 | [diff] [blame] | 994 | * @see #openFileOutput |
| 995 | * @see #getFileStreamPath |
| 996 | * @see #getDir |
| 997 | * @see android.app.backup.BackupAgent |
| 998 | */ |
| 999 | public abstract File getNoBackupFilesDir(); |
| 1000 | |
| 1001 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1002 | * Returns the absolute path to the directory on the primary shared/external |
| 1003 | * storage device where the application can place persistent files it owns. |
| 1004 | * These files are internal to the applications, and not typically visible |
| 1005 | * to the user as media. |
| 1006 | * <p> |
| 1007 | * This is like {@link #getFilesDir()} in that these files will be deleted |
| 1008 | * when the application is uninstalled, however there are some important |
| 1009 | * differences: |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1010 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1011 | * <li>Shared storage may not always be available, since removable media can |
| 1012 | * be ejected by the user. Media state can be checked using |
| 1013 | * {@link Environment#getExternalStorageState(File)}. |
| 1014 | * <li>There is no security enforced with these files. For example, any |
| 1015 | * application holding |
| 1016 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1017 | * these files. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1018 | * </ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1019 | * <p> |
| 1020 | * If a shared storage device is emulated (as determined by |
| 1021 | * {@link Environment#isExternalStorageEmulated(File)}), it's contents are |
| 1022 | * backed by a private user data partition, which means there is little |
| 1023 | * benefit to storing data here instead of the private directories returned |
| 1024 | * by {@link #getFilesDir()}, etc. |
| 1025 | * <p> |
| 1026 | * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1027 | * 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] | 1028 | * accessible to the calling app. This only applies to paths generated for |
| 1029 | * package name of the calling application. To access paths belonging to |
| 1030 | * other packages, |
| 1031 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} and/or |
| 1032 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} are required. |
| 1033 | * <p> |
| 1034 | * On devices with multiple users (as described by {@link UserManager}), |
| 1035 | * each user has their own isolated shared storage. Applications only have |
| 1036 | * access to the shared storage for the user they're running as. |
| 1037 | * <p> |
| 1038 | * The returned path may change over time if different shared storage media |
| 1039 | * is inserted, so only relative paths should be persisted. |
| 1040 | * <p> |
| 1041 | * Here is an example of typical code to manipulate a file in an |
| 1042 | * application's shared storage: |
| 1043 | * </p> |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1044 | * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java |
| 1045 | * private_file} |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1046 | * <p> |
| 1047 | * If you supply a non-null <var>type</var> to this function, the returned |
| 1048 | * file will be a path to a sub-directory of the given type. Though these |
| 1049 | * files are not automatically scanned by the media scanner, you can |
| 1050 | * explicitly add them to the media database with |
| 1051 | * {@link android.media.MediaScannerConnection#scanFile(Context, String[], String[], android.media.MediaScannerConnection.OnScanCompletedListener) |
| 1052 | * MediaScannerConnection.scanFile}. Note that this is not the same as |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1053 | * {@link android.os.Environment#getExternalStoragePublicDirectory |
| 1054 | * Environment.getExternalStoragePublicDirectory()}, which provides |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1055 | * directories of media shared by all applications. The directories returned |
| 1056 | * here are owned by the application, and their contents will be removed |
| 1057 | * when the application is uninstalled. Unlike |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1058 | * {@link android.os.Environment#getExternalStoragePublicDirectory |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1059 | * Environment.getExternalStoragePublicDirectory()}, the directory returned |
| 1060 | * here will be automatically created for you. |
| 1061 | * <p> |
| 1062 | * Here is an example of typical code to manipulate a picture in an |
| 1063 | * application's shared storage and add it to the media database: |
| 1064 | * </p> |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1065 | * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java |
| 1066 | * private_picture} |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 1067 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1068 | * @param type The type of files directory to return. May be {@code null} |
| 1069 | * for the root of the files directory or one of the following |
| 1070 | * constants for a subdirectory: |
| 1071 | * {@link android.os.Environment#DIRECTORY_MUSIC}, |
| 1072 | * {@link android.os.Environment#DIRECTORY_PODCASTS}, |
| 1073 | * {@link android.os.Environment#DIRECTORY_RINGTONES}, |
| 1074 | * {@link android.os.Environment#DIRECTORY_ALARMS}, |
| 1075 | * {@link android.os.Environment#DIRECTORY_NOTIFICATIONS}, |
| 1076 | * {@link android.os.Environment#DIRECTORY_PICTURES}, or |
| 1077 | * {@link android.os.Environment#DIRECTORY_MOVIES}. |
| 1078 | * @return the absolute path to application-specific directory. May return |
| 1079 | * {@code null} if shared storage is not currently available. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1080 | * @see #getFilesDir |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1081 | * @see #getExternalFilesDirs(String) |
| 1082 | * @see Environment#getExternalStorageState(File) |
| 1083 | * @see Environment#isExternalStorageEmulated(File) |
| 1084 | * @see Environment#isExternalStorageRemovable(File) |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1085 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1086 | @Nullable |
| 1087 | public abstract File getExternalFilesDir(@Nullable String type); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1088 | |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1089 | /** |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1090 | * Returns absolute paths to application-specific directories on all |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1091 | * shared/external storage devices where the application can place |
| 1092 | * persistent files it owns. These files are internal to the application, |
| 1093 | * and not typically visible to the user as media. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1094 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1095 | * This is like {@link #getFilesDir()} in that these files will be deleted |
| 1096 | * when the application is uninstalled, however there are some important |
| 1097 | * differences: |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1098 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1099 | * <li>Shared storage may not always be available, since removable media can |
| 1100 | * be ejected by the user. Media state can be checked using |
| 1101 | * {@link Environment#getExternalStorageState(File)}. |
| 1102 | * <li>There is no security enforced with these files. For example, any |
| 1103 | * application holding |
| 1104 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 1105 | * these files. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1106 | * </ul> |
| 1107 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1108 | * If a shared storage device is emulated (as determined by |
| 1109 | * {@link Environment#isExternalStorageEmulated(File)}), it's contents are |
| 1110 | * backed by a private user data partition, which means there is little |
| 1111 | * benefit to storing data here instead of the private directories returned |
| 1112 | * by {@link #getFilesDir()}, etc. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1113 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1114 | * Shared storage devices returned here are considered a stable part of the |
| 1115 | * device, including physical media slots under a protective cover. The |
| 1116 | * returned paths do not include transient devices, such as USB flash drives |
| 1117 | * connected to handheld devices. |
| 1118 | * <p> |
| 1119 | * 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] | 1120 | * example, an app may choose to store large files on the device with the |
| 1121 | * most available space, as measured by {@link StatFs}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1122 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1123 | * No additional permissions are required for the calling app to read or |
| 1124 | * write files under the returned path. Write access outside of these paths |
| 1125 | * on secondary external storage devices is not available. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1126 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1127 | * The returned path may change over time if different shared storage media |
| 1128 | * is inserted, so only relative paths should be persisted. |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 1129 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1130 | * @param type The type of files directory to return. May be {@code null} |
| 1131 | * for the root of the files directory or one of the following |
| 1132 | * constants for a subdirectory: |
| 1133 | * {@link android.os.Environment#DIRECTORY_MUSIC}, |
| 1134 | * {@link android.os.Environment#DIRECTORY_PODCASTS}, |
| 1135 | * {@link android.os.Environment#DIRECTORY_RINGTONES}, |
| 1136 | * {@link android.os.Environment#DIRECTORY_ALARMS}, |
| 1137 | * {@link android.os.Environment#DIRECTORY_NOTIFICATIONS}, |
| 1138 | * {@link android.os.Environment#DIRECTORY_PICTURES}, or |
| 1139 | * {@link android.os.Environment#DIRECTORY_MOVIES}. |
| 1140 | * @return the absolute paths to application-specific directories. Some |
| 1141 | * individual paths may be {@code null} if that shared storage is |
| 1142 | * not currently available. The first path returned is the same as |
| 1143 | * {@link #getExternalFilesDir(String)}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1144 | * @see #getExternalFilesDir(String) |
Jeff Sharkey | 4ca728c | 2014-01-10 16:27:19 -0800 | [diff] [blame] | 1145 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1146 | * @see Environment#isExternalStorageEmulated(File) |
| 1147 | * @see Environment#isExternalStorageRemovable(File) |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1148 | */ |
| 1149 | public abstract File[] getExternalFilesDirs(String type); |
| 1150 | |
| 1151 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1152 | * Return the primary shared/external storage directory where this |
| 1153 | * application's OBB files (if there are any) can be found. Note if the |
| 1154 | * application does not have any OBB files, this directory may not exist. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1155 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1156 | * This is like {@link #getFilesDir()} in that these files will be deleted |
| 1157 | * when the application is uninstalled, however there are some important |
| 1158 | * differences: |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1159 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1160 | * <li>Shared storage may not always be available, since removable media can |
| 1161 | * be ejected by the user. Media state can be checked using |
| 1162 | * {@link Environment#getExternalStorageState(File)}. |
| 1163 | * <li>There is no security enforced with these files. For example, any |
| 1164 | * application holding |
| 1165 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1166 | * these files. |
| 1167 | * </ul> |
| 1168 | * <p> |
| 1169 | * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions |
Dave Friedman | cfe5088 | 2017-07-05 00:40:07 -0700 | [diff] [blame] | 1170 | * are required to read or write to the path that this method returns. |
| 1171 | * However, starting from {@link android.os.Build.VERSION_CODES#M}, |
| 1172 | * to read the OBB expansion files, you must declare the |
| 1173 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} permission in the app manifest and ask for |
| 1174 | * permission at runtime as follows: |
| 1175 | * </p> |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1176 | * <p> |
Dave Friedman | cfe5088 | 2017-07-05 00:40:07 -0700 | [diff] [blame] | 1177 | * {@code <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" |
| 1178 | * android:maxSdkVersion="23" />} |
| 1179 | * </p> |
| 1180 | * <p> |
| 1181 | * Starting from {@link android.os.Build.VERSION_CODES#N}, |
| 1182 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} |
| 1183 | * permission is not required, so don’t ask for this |
| 1184 | * permission at runtime. To handle both cases, your app must first try to read the OBB file, |
| 1185 | * and if it fails, you must request |
| 1186 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} permission at runtime. |
| 1187 | * </p> |
| 1188 | * |
| 1189 | * <p> |
| 1190 | * The following code snippet shows how to do this: |
| 1191 | * </p> |
| 1192 | * |
| 1193 | * <pre> |
| 1194 | * File obb = new File(obb_filename); |
| 1195 | * boolean open_failed = false; |
| 1196 | * |
| 1197 | * try { |
| 1198 | * BufferedReader br = new BufferedReader(new FileReader(obb)); |
| 1199 | * open_failed = false; |
| 1200 | * ReadObbFile(br); |
| 1201 | * } catch (IOException e) { |
| 1202 | * open_failed = true; |
| 1203 | * } |
| 1204 | * |
| 1205 | * if (open_failed) { |
| 1206 | * // request READ_EXTERNAL_STORAGE permission before reading OBB file |
| 1207 | * ReadObbFileWithPermission(); |
| 1208 | * } |
| 1209 | * </pre> |
| 1210 | * |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1211 | * On devices with multiple users (as described by {@link UserManager}), |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 1212 | * multiple users may share the same OBB storage location. Applications |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1213 | * should ensure that multiple instances running under different users don't |
| 1214 | * interfere with each other. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1215 | * |
| 1216 | * @return the absolute path to application-specific directory. May return |
| 1217 | * {@code null} if shared storage is not currently available. |
| 1218 | * @see #getObbDirs() |
| 1219 | * @see Environment#getExternalStorageState(File) |
| 1220 | * @see Environment#isExternalStorageEmulated(File) |
| 1221 | * @see Environment#isExternalStorageRemovable(File) |
Dianne Hackborn | 805fd7e | 2011-01-16 18:30:29 -0800 | [diff] [blame] | 1222 | */ |
| 1223 | public abstract File getObbDir(); |
| 1224 | |
| 1225 | /** |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1226 | * Returns absolute paths to application-specific directories on all |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1227 | * shared/external storage devices where the application's OBB files (if |
| 1228 | * there are any) can be found. Note if the application does not have any |
| 1229 | * OBB files, these directories may not exist. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1230 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1231 | * This is like {@link #getFilesDir()} in that these files will be deleted |
| 1232 | * when the application is uninstalled, however there are some important |
| 1233 | * differences: |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1234 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1235 | * <li>Shared storage may not always be available, since removable media can |
| 1236 | * be ejected by the user. Media state can be checked using |
| 1237 | * {@link Environment#getExternalStorageState(File)}. |
| 1238 | * <li>There is no security enforced with these files. For example, any |
| 1239 | * application holding |
| 1240 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 1241 | * these files. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1242 | * </ul> |
| 1243 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1244 | * Shared storage devices returned here are considered a stable part of the |
| 1245 | * device, including physical media slots under a protective cover. The |
| 1246 | * returned paths do not include transient devices, such as USB flash drives |
| 1247 | * connected to handheld devices. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1248 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1249 | * 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] | 1250 | * example, an app may choose to store large files on the device with the |
| 1251 | * most available space, as measured by {@link StatFs}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1252 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1253 | * No additional permissions are required for the calling app to read or |
| 1254 | * write files under the returned path. Write access outside of these paths |
| 1255 | * on secondary external storage devices is not available. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1256 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1257 | * @return the absolute paths to application-specific directories. Some |
| 1258 | * individual paths may be {@code null} if that shared storage is |
| 1259 | * not currently available. The first path returned is the same as |
| 1260 | * {@link #getObbDir()} |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1261 | * @see #getObbDir() |
Jeff Sharkey | 4ca728c | 2014-01-10 16:27:19 -0800 | [diff] [blame] | 1262 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1263 | * @see Environment#isExternalStorageEmulated(File) |
| 1264 | * @see Environment#isExternalStorageRemovable(File) |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1265 | */ |
| 1266 | public abstract File[] getObbDirs(); |
| 1267 | |
| 1268 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -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. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1271 | * <p> |
Jeff Sharkey | 60a82cd | 2017-04-18 18:19:16 -0600 | [diff] [blame] | 1272 | * The system will automatically delete files in this directory as disk |
| 1273 | * space is needed elsewhere on the device. The system will always delete |
| 1274 | * older files first, as reported by {@link File#lastModified()}. If |
| 1275 | * desired, you can exert more control over how files are deleted using |
| 1276 | * {@link StorageManager#setCacheBehaviorGroup(File, boolean)} and |
| 1277 | * {@link StorageManager#setCacheBehaviorTombstone(File, boolean)}. |
| 1278 | * <p> |
| 1279 | * Apps are strongly encouraged to keep their usage of cache space below the |
| 1280 | * quota returned by |
| 1281 | * {@link StorageManager#getCacheQuotaBytes(java.util.UUID)}. If your app |
| 1282 | * goes above this quota, your cached files will be some of the first to be |
| 1283 | * deleted when additional disk space is needed. Conversely, if your app |
| 1284 | * stays under this quota, your cached files will be some of the last to be |
| 1285 | * deleted when additional disk space is needed. |
| 1286 | * <p> |
| 1287 | * Note that your cache quota will change over time depending on how |
| 1288 | * frequently the user interacts with your app, and depending on how much |
| 1289 | * system-wide disk space is used. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1290 | * <p> |
| 1291 | * The returned path may change over time if the calling app is moved to an |
| 1292 | * adopted storage device, so only relative paths should be persisted. |
| 1293 | * <p> |
| 1294 | * Apps require no extra permissions to read or write to the returned path, |
| 1295 | * since this path lives in their private storage. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1296 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1297 | * @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] | 1298 | * @see #openFileOutput |
| 1299 | * @see #getFileStreamPath |
| 1300 | * @see #getDir |
Kevin Hufnagle | e9681e1 | 2016-09-23 16:44:03 -0700 | [diff] [blame] | 1301 | * @see #getExternalCacheDir |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1302 | */ |
| 1303 | public abstract File getCacheDir(); |
| 1304 | |
| 1305 | /** |
Jeff Sharkey | 4ed745d | 2014-07-15 20:39:15 -0700 | [diff] [blame] | 1306 | * Returns the absolute path to the application specific cache directory on |
Jeff Sharkey | 60a82cd | 2017-04-18 18:19:16 -0600 | [diff] [blame] | 1307 | * the filesystem designed for storing cached code. |
| 1308 | * <p> |
| 1309 | * The system will delete any files stored in this location both when your |
| 1310 | * specific application is upgraded, and when the entire platform is |
| 1311 | * upgraded. |
Jeff Sharkey | 4ed745d | 2014-07-15 20:39:15 -0700 | [diff] [blame] | 1312 | * <p> |
| 1313 | * This location is optimal for storing compiled or optimized code generated |
| 1314 | * by your application at runtime. |
| 1315 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1316 | * The returned path may change over time if the calling app is moved to an |
| 1317 | * adopted storage device, so only relative paths should be persisted. |
| 1318 | * <p> |
Jeff Sharkey | 4ed745d | 2014-07-15 20:39:15 -0700 | [diff] [blame] | 1319 | * Apps require no extra permissions to read or write to the returned path, |
| 1320 | * since this path lives in their private storage. |
| 1321 | * |
| 1322 | * @return The path of the directory holding application code cache files. |
| 1323 | */ |
| 1324 | public abstract File getCodeCacheDir(); |
| 1325 | |
| 1326 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1327 | * Returns absolute path to application-specific directory on the primary |
| 1328 | * shared/external storage device where the application can place cache |
| 1329 | * files it owns. These files are internal to the application, and not |
| 1330 | * typically visible to the user as media. |
| 1331 | * <p> |
| 1332 | * This is like {@link #getCacheDir()} in that these files will be deleted |
| 1333 | * when the application is uninstalled, however there are some important |
| 1334 | * differences: |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1335 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1336 | * <li>The platform does not always monitor the space available in shared |
| 1337 | * storage, and thus may not automatically delete these files. Apps should |
| 1338 | * always manage the maximum space used in this location. Currently the only |
| 1339 | * time files here will be deleted by the platform is when running on |
| 1340 | * {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} or later and |
| 1341 | * {@link Environment#isExternalStorageEmulated(File)} returns true. |
| 1342 | * <li>Shared storage may not always be available, since removable media can |
| 1343 | * be ejected by the user. Media state can be checked using |
| 1344 | * {@link Environment#getExternalStorageState(File)}. |
| 1345 | * <li>There is no security enforced with these files. For example, any |
| 1346 | * application holding |
| 1347 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1348 | * these files. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1349 | * </ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1350 | * <p> |
| 1351 | * If a shared storage device is emulated (as determined by |
Kevin Hufnagle | e9681e1 | 2016-09-23 16:44:03 -0700 | [diff] [blame] | 1352 | * {@link Environment#isExternalStorageEmulated(File)}), its contents are |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1353 | * backed by a private user data partition, which means there is little |
| 1354 | * benefit to storing data here instead of the private directory returned by |
| 1355 | * {@link #getCacheDir()}. |
| 1356 | * <p> |
| 1357 | * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1358 | * 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] | 1359 | * accessible to the calling app. This only applies to paths generated for |
| 1360 | * package name of the calling application. To access paths belonging to |
| 1361 | * other packages, |
| 1362 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} and/or |
| 1363 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} are required. |
| 1364 | * <p> |
| 1365 | * On devices with multiple users (as described by {@link UserManager}), |
| 1366 | * each user has their own isolated shared storage. Applications only have |
| 1367 | * access to the shared storage for the user they're running as. |
| 1368 | * <p> |
| 1369 | * The returned path may change over time if different shared storage media |
| 1370 | * is inserted, so only relative paths should be persisted. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1371 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1372 | * @return the absolute path to application-specific directory. May return |
| 1373 | * {@code null} if shared storage is not currently available. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1374 | * @see #getCacheDir |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1375 | * @see #getExternalCacheDirs() |
| 1376 | * @see Environment#getExternalStorageState(File) |
| 1377 | * @see Environment#isExternalStorageEmulated(File) |
| 1378 | * @see Environment#isExternalStorageRemovable(File) |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1379 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1380 | @Nullable |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1381 | public abstract File getExternalCacheDir(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1382 | |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1383 | /** |
Fyodor Kupolov | 6122129 | 2016-09-02 15:21:03 -0700 | [diff] [blame] | 1384 | * Returns absolute path to application-specific directory in the preloaded cache. |
| 1385 | * <p>Files stored in the cache directory can be deleted when the device runs low on storage. |
| 1386 | * There is no guarantee when these files will be deleted. |
| 1387 | * @hide |
| 1388 | */ |
| 1389 | @Nullable |
| 1390 | @SystemApi |
| 1391 | public abstract File getPreloadsFileCache(); |
| 1392 | |
| 1393 | /** |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1394 | * Returns absolute paths to application-specific directories on all |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1395 | * shared/external storage devices where the application can place cache |
| 1396 | * files it owns. These files are internal to the application, and not |
| 1397 | * typically visible to the user as media. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1398 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1399 | * This is like {@link #getCacheDir()} in that these files will be deleted |
| 1400 | * when the application is uninstalled, however there are some important |
| 1401 | * differences: |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1402 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1403 | * <li>The platform does not always monitor the space available in shared |
| 1404 | * storage, and thus may not automatically delete these files. Apps should |
| 1405 | * always manage the maximum space used in this location. Currently the only |
| 1406 | * time files here will be deleted by the platform is when running on |
| 1407 | * {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} or later and |
| 1408 | * {@link Environment#isExternalStorageEmulated(File)} returns true. |
| 1409 | * <li>Shared storage may not always be available, since removable media can |
| 1410 | * be ejected by the user. Media state can be checked using |
| 1411 | * {@link Environment#getExternalStorageState(File)}. |
| 1412 | * <li>There is no security enforced with these files. For example, any |
| 1413 | * application holding |
| 1414 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 1415 | * these files. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1416 | * </ul> |
| 1417 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1418 | * If a shared storage device is emulated (as determined by |
| 1419 | * {@link Environment#isExternalStorageEmulated(File)}), it's contents are |
| 1420 | * backed by a private user data partition, which means there is little |
| 1421 | * benefit to storing data here instead of the private directory returned by |
| 1422 | * {@link #getCacheDir()}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1423 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1424 | * Shared storage devices returned here are considered a stable part of the |
| 1425 | * device, including physical media slots under a protective cover. The |
| 1426 | * returned paths do not include transient devices, such as USB flash drives |
| 1427 | * connected to handheld devices. |
| 1428 | * <p> |
| 1429 | * 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] | 1430 | * example, an app may choose to store large files on the device with the |
| 1431 | * most available space, as measured by {@link StatFs}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1432 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1433 | * No additional permissions are required for the calling app to read or |
| 1434 | * write files under the returned path. Write access outside of these paths |
| 1435 | * on secondary external storage devices is not available. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1436 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1437 | * The returned paths may change over time if different shared storage media |
| 1438 | * is inserted, so only relative paths should be persisted. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1439 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1440 | * @return the absolute paths to application-specific directories. Some |
| 1441 | * individual paths may be {@code null} if that shared storage is |
| 1442 | * not currently available. The first path returned is the same as |
| 1443 | * {@link #getExternalCacheDir()}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1444 | * @see #getExternalCacheDir() |
Jeff Sharkey | 4ca728c | 2014-01-10 16:27:19 -0800 | [diff] [blame] | 1445 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1446 | * @see Environment#isExternalStorageEmulated(File) |
| 1447 | * @see Environment#isExternalStorageRemovable(File) |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1448 | */ |
| 1449 | public abstract File[] getExternalCacheDirs(); |
| 1450 | |
| 1451 | /** |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1452 | * Returns absolute paths to application-specific directories on all |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1453 | * shared/external storage devices where the application can place media |
| 1454 | * files. These files are scanned and made available to other apps through |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1455 | * {@link MediaStore}. |
| 1456 | * <p> |
| 1457 | * This is like {@link #getExternalFilesDirs} in that these files will be |
| 1458 | * deleted when the application is uninstalled, however there are some |
| 1459 | * important differences: |
| 1460 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1461 | * <li>Shared storage may not always be available, since removable media can |
| 1462 | * be ejected by the user. Media state can be checked using |
| 1463 | * {@link Environment#getExternalStorageState(File)}. |
| 1464 | * <li>There is no security enforced with these files. For example, any |
| 1465 | * application holding |
| 1466 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 1467 | * these files. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1468 | * </ul> |
| 1469 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1470 | * Shared storage devices returned here are considered a stable part of the |
| 1471 | * device, including physical media slots under a protective cover. The |
| 1472 | * returned paths do not include transient devices, such as USB flash drives |
| 1473 | * connected to handheld devices. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1474 | * <p> |
| 1475 | * An application may store data on any or all of the returned devices. For |
| 1476 | * example, an app may choose to store large files on the device with the |
| 1477 | * most available space, as measured by {@link StatFs}. |
| 1478 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1479 | * No additional permissions are required for the calling app to read or |
| 1480 | * write files under the returned path. Write access outside of these paths |
| 1481 | * on secondary external storage devices is not available. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1482 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1483 | * The returned paths may change over time if different shared storage media |
| 1484 | * is inserted, so only relative paths should be persisted. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1485 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1486 | * @return the absolute paths to application-specific directories. Some |
| 1487 | * individual paths may be {@code null} if that shared storage is |
| 1488 | * not currently available. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1489 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1490 | * @see Environment#isExternalStorageEmulated(File) |
| 1491 | * @see Environment#isExternalStorageRemovable(File) |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1492 | */ |
| 1493 | public abstract File[] getExternalMediaDirs(); |
| 1494 | |
| 1495 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1496 | * Returns an array of strings naming the private files associated with |
| 1497 | * this Context's application package. |
| 1498 | * |
| 1499 | * @return Array of strings naming the private files. |
| 1500 | * |
| 1501 | * @see #openFileInput |
| 1502 | * @see #openFileOutput |
| 1503 | * @see #deleteFile |
| 1504 | */ |
| 1505 | public abstract String[] fileList(); |
| 1506 | |
| 1507 | /** |
| 1508 | * Retrieve, creating if needed, a new directory in which the application |
| 1509 | * can place its own custom data files. You can use the returned File |
| 1510 | * object to create and access files in this directory. Note that files |
| 1511 | * created through a File object will only be accessible by your own |
| 1512 | * application; you can only set the mode of the entire directory, not |
| 1513 | * of individual files. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1514 | * <p> |
| 1515 | * The returned path may change over time if the calling app is moved to an |
| 1516 | * adopted storage device, so only relative paths should be persisted. |
| 1517 | * <p> |
| 1518 | * Apps require no extra permissions to read or write to the returned path, |
| 1519 | * since this path lives in their private storage. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1520 | * |
Nick Kralevich | 92091fa | 2012-12-12 16:24:31 -0800 | [diff] [blame] | 1521 | * @param name Name of the directory to retrieve. This is a directory |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1522 | * that is created as part of your application data. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1523 | * @param mode Operating mode. |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1524 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1525 | * @return A {@link File} object for the requested directory. The directory |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1526 | * 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] | 1527 | * |
| 1528 | * @see #openFileOutput(String, int) |
| 1529 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1530 | public abstract File getDir(String name, @FileMode int mode); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1531 | |
| 1532 | /** |
| 1533 | * Open a new private SQLiteDatabase associated with this Context's |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1534 | * 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] | 1535 | * |
| 1536 | * @param name The name (unique in the application package) of the database. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1537 | * @param mode Operating mode. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1538 | * @param factory An optional factory class that is called to instantiate a |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1539 | * cursor when query is called. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1540 | * @return The contents of a newly created database with the given name. |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1541 | * @throws android.database.sqlite.SQLiteException if the database file |
| 1542 | * could not be opened. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1543 | * @see #MODE_PRIVATE |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 1544 | * @see #MODE_ENABLE_WRITE_AHEAD_LOGGING |
Sunny Goyal | a21e6b2 | 2015-12-02 09:51:02 -0800 | [diff] [blame] | 1545 | * @see #MODE_NO_LOCALIZED_COLLATORS |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1546 | * @see #deleteDatabase |
| 1547 | */ |
| 1548 | public abstract SQLiteDatabase openOrCreateDatabase(String name, |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1549 | @DatabaseMode int mode, CursorFactory factory); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1550 | |
| 1551 | /** |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1552 | * Open a new private SQLiteDatabase associated with this Context's |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1553 | * application package. Creates the database file if it doesn't exist. |
| 1554 | * <p> |
| 1555 | * Accepts input param: a concrete instance of {@link DatabaseErrorHandler} |
| 1556 | * to be used to handle corruption when sqlite reports database corruption. |
| 1557 | * </p> |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1558 | * |
| 1559 | * @param name The name (unique in the application package) of the database. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1560 | * @param mode Operating mode. |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1561 | * @param factory An optional factory class that is called to instantiate a |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1562 | * cursor when query is called. |
| 1563 | * @param errorHandler the {@link DatabaseErrorHandler} to be used when |
| 1564 | * sqlite reports database corruption. if null, |
| 1565 | * {@link android.database.DefaultDatabaseErrorHandler} is |
| 1566 | * assumed. |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1567 | * @return The contents of a newly created database with the given name. |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1568 | * @throws android.database.sqlite.SQLiteException if the database file |
| 1569 | * could not be opened. |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1570 | * @see #MODE_PRIVATE |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 1571 | * @see #MODE_ENABLE_WRITE_AHEAD_LOGGING |
Sunny Goyal | a21e6b2 | 2015-12-02 09:51:02 -0800 | [diff] [blame] | 1572 | * @see #MODE_NO_LOCALIZED_COLLATORS |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1573 | * @see #deleteDatabase |
| 1574 | */ |
| 1575 | public abstract SQLiteDatabase openOrCreateDatabase(String name, |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1576 | @DatabaseMode int mode, CursorFactory factory, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1577 | @Nullable DatabaseErrorHandler errorHandler); |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1578 | |
| 1579 | /** |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 1580 | * Move an existing database file from the given source storage context to |
| 1581 | * this context. This is typically used to migrate data between storage |
| 1582 | * locations after an upgrade, such as migrating to device protected |
| 1583 | * storage. |
Jeff Sharkey | d21cad1 | 2016-05-20 11:30:07 -0600 | [diff] [blame] | 1584 | * <p> |
| 1585 | * The database must be closed before being moved. |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 1586 | * |
| 1587 | * @param sourceContext The source context which contains the existing |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 1588 | * database to move. |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 1589 | * @param name The name of the database file. |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 1590 | * @return {@code true} if the move was successful or if the database didn't |
| 1591 | * exist in the source context, otherwise {@code false}. |
| 1592 | * @see #createDeviceProtectedStorageContext() |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 1593 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 1594 | public abstract boolean moveDatabaseFrom(Context sourceContext, String name); |
| 1595 | |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 1596 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1597 | * Delete an existing private SQLiteDatabase associated with this Context's |
| 1598 | * application package. |
| 1599 | * |
| 1600 | * @param name The name (unique in the application package) of the |
| 1601 | * database. |
| 1602 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1603 | * @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] | 1604 | * |
| 1605 | * @see #openOrCreateDatabase |
| 1606 | */ |
| 1607 | public abstract boolean deleteDatabase(String name); |
| 1608 | |
| 1609 | /** |
| 1610 | * Returns the absolute path on the filesystem where a database created with |
| 1611 | * {@link #openOrCreateDatabase} is stored. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1612 | * <p> |
| 1613 | * The returned path may change over time if the calling app is moved to an |
| 1614 | * 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] | 1615 | * |
| 1616 | * @param name The name of the database for which you would like to get |
| 1617 | * its path. |
| 1618 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1619 | * @return An absolute path to the given database. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1620 | * |
| 1621 | * @see #openOrCreateDatabase |
| 1622 | */ |
| 1623 | public abstract File getDatabasePath(String name); |
| 1624 | |
| 1625 | /** |
| 1626 | * Returns an array of strings naming the private databases associated with |
| 1627 | * this Context's application package. |
| 1628 | * |
| 1629 | * @return Array of strings naming the private databases. |
| 1630 | * |
| 1631 | * @see #openOrCreateDatabase |
| 1632 | * @see #deleteDatabase |
| 1633 | */ |
| 1634 | public abstract String[] databaseList(); |
| 1635 | |
| 1636 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1637 | * @deprecated Use {@link android.app.WallpaperManager#getDrawable |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1638 | * WallpaperManager.get()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1639 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1640 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1641 | public abstract Drawable getWallpaper(); |
| 1642 | |
| 1643 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1644 | * @deprecated Use {@link android.app.WallpaperManager#peekDrawable |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1645 | * WallpaperManager.peek()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1646 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1647 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1648 | public abstract Drawable peekWallpaper(); |
| 1649 | |
| 1650 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1651 | * @deprecated Use {@link android.app.WallpaperManager#getDesiredMinimumWidth() |
| 1652 | * WallpaperManager.getDesiredMinimumWidth()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1653 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1654 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1655 | public abstract int getWallpaperDesiredMinimumWidth(); |
| 1656 | |
| 1657 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1658 | * @deprecated Use {@link android.app.WallpaperManager#getDesiredMinimumHeight() |
| 1659 | * WallpaperManager.getDesiredMinimumHeight()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1660 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1661 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1662 | public abstract int getWallpaperDesiredMinimumHeight(); |
| 1663 | |
| 1664 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1665 | * @deprecated Use {@link android.app.WallpaperManager#setBitmap(Bitmap) |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1666 | * WallpaperManager.set()} instead. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 1667 | * <p>This method requires the caller to hold the permission |
| 1668 | * {@link android.Manifest.permission#SET_WALLPAPER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1669 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1670 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1671 | public abstract void setWallpaper(Bitmap bitmap) throws IOException; |
| 1672 | |
| 1673 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1674 | * @deprecated Use {@link android.app.WallpaperManager#setStream(InputStream) |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1675 | * WallpaperManager.set()} instead. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 1676 | * <p>This method requires the caller to hold the permission |
| 1677 | * {@link android.Manifest.permission#SET_WALLPAPER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1678 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1679 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1680 | public abstract void setWallpaper(InputStream data) throws IOException; |
| 1681 | |
| 1682 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1683 | * @deprecated Use {@link android.app.WallpaperManager#clear |
| 1684 | * WallpaperManager.clear()} instead. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 1685 | * <p>This method requires the caller to hold the permission |
| 1686 | * {@link android.Manifest.permission#SET_WALLPAPER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1687 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1688 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1689 | public abstract void clearWallpaper() throws IOException; |
| 1690 | |
| 1691 | /** |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1692 | * Same as {@link #startActivity(Intent, Bundle)} with no options |
| 1693 | * specified. |
| 1694 | * |
| 1695 | * @param intent The description of the activity to start. |
| 1696 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1697 | * @throws ActivityNotFoundException |
Svet Ganov | 1ed0e55 | 2015-06-11 01:15:43 -0700 | [diff] [blame] | 1698 | *` |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1699 | * @see #startActivity(Intent, Bundle) |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1700 | * @see PackageManager#resolveActivity |
| 1701 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1702 | public abstract void startActivity(@RequiresPermission Intent intent); |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1703 | |
| 1704 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1705 | * Version of {@link #startActivity(Intent)} that allows you to specify the |
| 1706 | * 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] | 1707 | * that are not pre-installed on the system image. |
Amith Yamasani | 8264408 | 2012-08-03 13:09:11 -0700 | [diff] [blame] | 1708 | * @param intent The description of the activity to start. |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 1709 | * @param user The UserHandle of the user to start this activity for. |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1710 | * @throws ActivityNotFoundException |
Amith Yamasani | 8264408 | 2012-08-03 13:09:11 -0700 | [diff] [blame] | 1711 | * @hide |
| 1712 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 1713 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) |
Remi NGUYEN VAN | bf1ecd1 | 2019-01-20 21:18:22 +0900 | [diff] [blame] | 1714 | @SystemApi |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1715 | public void startActivityAsUser(@RequiresPermission Intent intent, UserHandle user) { |
Amith Yamasani | 8264408 | 2012-08-03 13:09:11 -0700 | [diff] [blame] | 1716 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 1717 | } |
| 1718 | |
| 1719 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1720 | * Launch a new activity. You will not receive any information about when |
| 1721 | * the activity exits. |
| 1722 | * |
| 1723 | * <p>Note that if this method is being called from outside of an |
| 1724 | * {@link android.app.Activity} Context, then the Intent must include |
| 1725 | * the {@link Intent#FLAG_ACTIVITY_NEW_TASK} launch flag. This is because, |
| 1726 | * without being started from an existing Activity, there is no existing |
| 1727 | * task in which to place the new activity and thus it needs to be placed |
| 1728 | * in its own separate task. |
| 1729 | * |
| 1730 | * <p>This method throws {@link ActivityNotFoundException} |
| 1731 | * if there was no Activity found to run the given Intent. |
| 1732 | * |
| 1733 | * @param intent The description of the activity to start. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1734 | * @param options Additional options for how the Activity should be started. |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 1735 | * May be null if there are no options. See {@link android.app.ActivityOptions} |
| 1736 | * for how to build the Bundle supplied here; there are no supported definitions |
| 1737 | * for building it manually. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1738 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1739 | * @throws ActivityNotFoundException |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1740 | * |
Scott Main | 60dd520 | 2012-06-23 00:01:22 -0700 | [diff] [blame] | 1741 | * @see #startActivity(Intent) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1742 | * @see PackageManager#resolveActivity |
| 1743 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1744 | public abstract void startActivity(@RequiresPermission Intent intent, |
| 1745 | @Nullable Bundle options); |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1746 | |
| 1747 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1748 | * Version of {@link #startActivity(Intent, Bundle)} that allows you to specify the |
| 1749 | * 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] | 1750 | * that are not pre-installed on the system image. |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 1751 | * @param intent The description of the activity to start. |
| 1752 | * @param options Additional options for how the Activity should be started. |
| 1753 | * May be null if there are no options. See {@link android.app.ActivityOptions} |
| 1754 | * for how to build the Bundle supplied here; there are no supported definitions |
| 1755 | * for building it manually. |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 1756 | * @param userId The UserHandle of the user to start this activity for. |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1757 | * @throws ActivityNotFoundException |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 1758 | * @hide |
| 1759 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 1760 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) |
Mathew Inwood | 1c77a11 | 2018-08-14 14:06:26 +0100 | [diff] [blame] | 1761 | @UnsupportedAppUsage |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1762 | public void startActivityAsUser(@RequiresPermission Intent intent, @Nullable Bundle options, |
| 1763 | UserHandle userId) { |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 1764 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 1765 | } |
| 1766 | |
| 1767 | /** |
Clara Bayarri | d5bf3ed | 2015-03-27 17:32:45 +0000 | [diff] [blame] | 1768 | * Version of {@link #startActivity(Intent, Bundle)} that returns a result to the caller. This |
| 1769 | * is only supported for Views and Fragments. |
| 1770 | * @param who The identifier for the calling element that will receive the result. |
| 1771 | * @param intent The intent to start. |
| 1772 | * @param requestCode The code that will be returned with onActivityResult() identifying this |
| 1773 | * request. |
| 1774 | * @param options Additional options for how the Activity should be started. |
| 1775 | * May be null if there are no options. See {@link android.app.ActivityOptions} |
| 1776 | * for how to build the Bundle supplied here; there are no supported definitions |
| 1777 | * for building it manually. |
| 1778 | * @hide |
| 1779 | */ |
Mathew Inwood | 1c77a11 | 2018-08-14 14:06:26 +0100 | [diff] [blame] | 1780 | @UnsupportedAppUsage |
Clara Bayarri | d5bf3ed | 2015-03-27 17:32:45 +0000 | [diff] [blame] | 1781 | public void startActivityForResult( |
| 1782 | @NonNull String who, Intent intent, int requestCode, @Nullable Bundle options) { |
| 1783 | throw new RuntimeException("This method is only implemented for Activity-based Contexts. " |
| 1784 | + "Check canStartActivityForResult() before calling."); |
| 1785 | } |
| 1786 | |
| 1787 | /** |
| 1788 | * Identifies whether this Context instance will be able to process calls to |
| 1789 | * {@link #startActivityForResult(String, Intent, int, Bundle)}. |
| 1790 | * @hide |
| 1791 | */ |
Mathew Inwood | 1c77a11 | 2018-08-14 14:06:26 +0100 | [diff] [blame] | 1792 | @UnsupportedAppUsage |
Clara Bayarri | d5bf3ed | 2015-03-27 17:32:45 +0000 | [diff] [blame] | 1793 | public boolean canStartActivityForResult() { |
| 1794 | return false; |
| 1795 | } |
| 1796 | |
| 1797 | /** |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1798 | * Same as {@link #startActivities(Intent[], Bundle)} with no options |
| 1799 | * specified. |
| 1800 | * |
| 1801 | * @param intents An array of Intents to be started. |
| 1802 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1803 | * @throws ActivityNotFoundException |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1804 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1805 | * @see #startActivities(Intent[], Bundle) |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1806 | * @see PackageManager#resolveActivity |
| 1807 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1808 | public abstract void startActivities(@RequiresPermission Intent[] intents); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1809 | |
| 1810 | /** |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1811 | * Launch multiple new activities. This is generally the same as calling |
| 1812 | * {@link #startActivity(Intent)} for the first Intent in the array, |
| 1813 | * that activity during its creation calling {@link #startActivity(Intent)} |
| 1814 | * for the second entry, etc. Note that unlike that approach, generally |
| 1815 | * none of the activities except the last in the array will be created |
| 1816 | * at this point, but rather will be created when the user first visits |
| 1817 | * them (due to pressing back from the activity on top). |
| 1818 | * |
| 1819 | * <p>This method throws {@link ActivityNotFoundException} |
| 1820 | * if there was no Activity found for <em>any</em> given Intent. In this |
| 1821 | * case the state of the activity stack is undefined (some Intents in the |
| 1822 | * list may be on it, some not), so you probably want to avoid such situations. |
| 1823 | * |
| 1824 | * @param intents An array of Intents to be started. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1825 | * @param options Additional options for how the Activity should be started. |
Elliot Waite | 54de774 | 2017-01-11 15:30:35 -0800 | [diff] [blame] | 1826 | * See {@link android.content.Context#startActivity(Intent, Bundle)} |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 1827 | * Context.startActivity(Intent, Bundle)} for more details. |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1828 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1829 | * @throws ActivityNotFoundException |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1830 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1831 | * @see #startActivities(Intent[]) |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1832 | * @see PackageManager#resolveActivity |
| 1833 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1834 | public abstract void startActivities(@RequiresPermission Intent[] intents, Bundle options); |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1835 | |
| 1836 | /** |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1837 | * @hide |
| 1838 | * Launch multiple new activities. This is generally the same as calling |
| 1839 | * {@link #startActivity(Intent)} for the first Intent in the array, |
| 1840 | * that activity during its creation calling {@link #startActivity(Intent)} |
| 1841 | * for the second entry, etc. Note that unlike that approach, generally |
| 1842 | * none of the activities except the last in the array will be created |
| 1843 | * at this point, but rather will be created when the user first visits |
| 1844 | * them (due to pressing back from the activity on top). |
| 1845 | * |
| 1846 | * <p>This method throws {@link ActivityNotFoundException} |
| 1847 | * if there was no Activity found for <em>any</em> given Intent. In this |
| 1848 | * case the state of the activity stack is undefined (some Intents in the |
| 1849 | * list may be on it, some not), so you probably want to avoid such situations. |
| 1850 | * |
| 1851 | * @param intents An array of Intents to be started. |
| 1852 | * @param options Additional options for how the Activity should be started. |
| 1853 | * @param userHandle The user for whom to launch the activities |
Elliot Waite | 54de774 | 2017-01-11 15:30:35 -0800 | [diff] [blame] | 1854 | * See {@link android.content.Context#startActivity(Intent, Bundle)} |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1855 | * Context.startActivity(Intent, Bundle)} for more details. |
| 1856 | * |
Selim Cinek | 7fa385a | 2018-01-24 08:35:28 -0800 | [diff] [blame] | 1857 | * @return The corresponding flag {@link ActivityManager#START_CANCELED}, |
| 1858 | * {@link ActivityManager#START_SUCCESS} etc. indicating whether the launch was |
| 1859 | * successful. |
| 1860 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1861 | * @throws ActivityNotFoundException |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1862 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1863 | * @see #startActivities(Intent[]) |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1864 | * @see PackageManager#resolveActivity |
| 1865 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 1866 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) |
Selim Cinek | 7fa385a | 2018-01-24 08:35:28 -0800 | [diff] [blame] | 1867 | public int startActivitiesAsUser(Intent[] intents, Bundle options, UserHandle userHandle) { |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1868 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 1869 | } |
| 1870 | |
| 1871 | /** |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1872 | * Same as {@link #startIntentSender(IntentSender, Intent, int, int, int, Bundle)} |
| 1873 | * with no options specified. |
| 1874 | * |
| 1875 | * @param intent The IntentSender to launch. |
| 1876 | * @param fillInIntent If non-null, this will be provided as the |
| 1877 | * intent parameter to {@link IntentSender#sendIntent}. |
| 1878 | * @param flagsMask Intent flags in the original IntentSender that you |
| 1879 | * would like to change. |
| 1880 | * @param flagsValues Desired values for any bits set in |
| 1881 | * <var>flagsMask</var> |
| 1882 | * @param extraFlags Always set to 0. |
| 1883 | * |
| 1884 | * @see #startActivity(Intent) |
| 1885 | * @see #startIntentSender(IntentSender, Intent, int, int, int, Bundle) |
| 1886 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1887 | public abstract void startIntentSender(IntentSender intent, @Nullable Intent fillInIntent, |
| 1888 | @Intent.MutableFlags int flagsMask, @Intent.MutableFlags int flagsValues, |
| 1889 | int extraFlags) throws IntentSender.SendIntentException; |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1890 | |
| 1891 | /** |
| 1892 | * Like {@link #startActivity(Intent, Bundle)}, but taking a IntentSender |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1893 | * 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] | 1894 | * as if you had called the regular {@link #startActivity(Intent)} |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1895 | * here; otherwise, its associated action will be executed (such as |
| 1896 | * sending a broadcast) as if you had called |
| 1897 | * {@link IntentSender#sendIntent IntentSender.sendIntent} on it. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1898 | * |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1899 | * @param intent The IntentSender to launch. |
| 1900 | * @param fillInIntent If non-null, this will be provided as the |
| 1901 | * intent parameter to {@link IntentSender#sendIntent}. |
| 1902 | * @param flagsMask Intent flags in the original IntentSender that you |
| 1903 | * would like to change. |
| 1904 | * @param flagsValues Desired values for any bits set in |
| 1905 | * <var>flagsMask</var> |
| 1906 | * @param extraFlags Always set to 0. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1907 | * @param options Additional options for how the Activity should be started. |
Elliot Waite | 54de774 | 2017-01-11 15:30:35 -0800 | [diff] [blame] | 1908 | * See {@link android.content.Context#startActivity(Intent, Bundle)} |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 1909 | * Context.startActivity(Intent, Bundle)} for more details. If options |
| 1910 | * have also been supplied by the IntentSender, options given here will |
| 1911 | * override any that conflict with those given by the IntentSender. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1912 | * |
| 1913 | * @see #startActivity(Intent, Bundle) |
| 1914 | * @see #startIntentSender(IntentSender, Intent, int, int, int) |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1915 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1916 | public abstract void startIntentSender(IntentSender intent, @Nullable Intent fillInIntent, |
| 1917 | @Intent.MutableFlags int flagsMask, @Intent.MutableFlags int flagsValues, |
| 1918 | int extraFlags, @Nullable Bundle options) throws IntentSender.SendIntentException; |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1919 | |
| 1920 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1921 | * Broadcast the given intent to all interested BroadcastReceivers. This |
| 1922 | * call is asynchronous; it returns immediately, and you will continue |
| 1923 | * executing while the receivers are run. No results are propagated from |
| 1924 | * receivers and receivers can not abort the broadcast. If you want |
| 1925 | * to allow receivers to propagate results or abort the broadcast, you must |
| 1926 | * send an ordered broadcast using |
| 1927 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 1928 | * |
| 1929 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1930 | * |
| 1931 | * @param intent The Intent to broadcast; all receivers matching this |
| 1932 | * Intent will receive the broadcast. |
| 1933 | * |
| 1934 | * @see android.content.BroadcastReceiver |
| 1935 | * @see #registerReceiver |
| 1936 | * @see #sendBroadcast(Intent, String) |
| 1937 | * @see #sendOrderedBroadcast(Intent, String) |
| 1938 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 1939 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1940 | public abstract void sendBroadcast(@RequiresPermission Intent intent); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1941 | |
| 1942 | /** |
| 1943 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
| 1944 | * an optional required permission to be enforced. This |
| 1945 | * call is asynchronous; it returns immediately, and you will continue |
| 1946 | * executing while the receivers are run. No results are propagated from |
| 1947 | * receivers and receivers can not abort the broadcast. If you want |
| 1948 | * to allow receivers to propagate results or abort the broadcast, you must |
| 1949 | * send an ordered broadcast using |
| 1950 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 1951 | * |
| 1952 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1953 | * |
| 1954 | * @param intent The Intent to broadcast; all receivers matching this |
| 1955 | * Intent will receive the broadcast. |
Brad Fitzpatrick | 26b71be | 2010-12-07 14:52:58 -0800 | [diff] [blame] | 1956 | * @param receiverPermission (optional) String naming a permission that |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1957 | * a receiver must hold in order to receive your broadcast. |
| 1958 | * If null, no permission is required. |
| 1959 | * |
| 1960 | * @see android.content.BroadcastReceiver |
| 1961 | * @see #registerReceiver |
| 1962 | * @see #sendBroadcast(Intent) |
| 1963 | * @see #sendOrderedBroadcast(Intent, String) |
| 1964 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 1965 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1966 | public abstract void sendBroadcast(@RequiresPermission Intent intent, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1967 | @Nullable String receiverPermission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1968 | |
Fyodor Kupolov | d4fd8c7 | 2015-07-13 19:19:25 -0700 | [diff] [blame] | 1969 | |
| 1970 | /** |
| 1971 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
| 1972 | * an array of required permissions to be enforced. This call is asynchronous; it returns |
| 1973 | * immediately, and you will continue executing while the receivers are run. No results are |
| 1974 | * propagated from receivers and receivers can not abort the broadcast. If you want to allow |
| 1975 | * receivers to propagate results or abort the broadcast, you must send an ordered broadcast |
| 1976 | * using {@link #sendOrderedBroadcast(Intent, String)}. |
| 1977 | * |
| 1978 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1979 | * |
| 1980 | * @param intent The Intent to broadcast; all receivers matching this |
| 1981 | * Intent will receive the broadcast. |
| 1982 | * @param receiverPermissions Array of names of permissions that a receiver must hold |
| 1983 | * in order to receive your broadcast. |
| 1984 | * If null or empty, no permissions are required. |
| 1985 | * |
| 1986 | * @see android.content.BroadcastReceiver |
| 1987 | * @see #registerReceiver |
| 1988 | * @see #sendBroadcast(Intent) |
| 1989 | * @see #sendOrderedBroadcast(Intent, String) |
| 1990 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 1991 | * @hide |
| 1992 | */ |
| 1993 | public abstract void sendBroadcastMultiplePermissions(Intent intent, |
| 1994 | String[] receiverPermissions); |
| 1995 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1996 | /** |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 1997 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
Tyler Gunn | f955e56 | 2018-04-26 14:43:31 -0700 | [diff] [blame] | 1998 | * an array of required permissions to be enforced. This call is asynchronous; it returns |
| 1999 | * immediately, and you will continue executing while the receivers are run. No results are |
| 2000 | * propagated from receivers and receivers can not abort the broadcast. If you want to allow |
| 2001 | * receivers to propagate results or abort the broadcast, you must send an ordered broadcast |
| 2002 | * using {@link #sendOrderedBroadcast(Intent, String)}. |
| 2003 | * |
| 2004 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2005 | * |
| 2006 | * @param intent The Intent to broadcast; all receivers matching this |
| 2007 | * Intent will receive the broadcast. |
| 2008 | * @param user The user to send the broadcast to. |
| 2009 | * @param receiverPermissions Array of names of permissions that a receiver must hold |
| 2010 | * in order to receive your broadcast. |
| 2011 | * If null or empty, no permissions are required. |
| 2012 | * |
| 2013 | * @see android.content.BroadcastReceiver |
| 2014 | * @see #registerReceiver |
| 2015 | * @see #sendBroadcast(Intent) |
| 2016 | * @see #sendOrderedBroadcast(Intent, String) |
| 2017 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2018 | * @hide |
| 2019 | */ |
| 2020 | public abstract void sendBroadcastAsUserMultiplePermissions(Intent intent, UserHandle user, |
| 2021 | String[] receiverPermissions); |
| 2022 | |
| 2023 | /** |
| 2024 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 2025 | * an optional required permission to be enforced. This |
| 2026 | * call is asynchronous; it returns immediately, and you will continue |
| 2027 | * executing while the receivers are run. No results are propagated from |
| 2028 | * receivers and receivers can not abort the broadcast. If you want |
| 2029 | * to allow receivers to propagate results or abort the broadcast, you must |
| 2030 | * send an ordered broadcast using |
| 2031 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2032 | * |
| 2033 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2034 | * |
| 2035 | * @param intent The Intent to broadcast; all receivers matching this |
| 2036 | * Intent will receive the broadcast. |
| 2037 | * @param receiverPermission (optional) String naming a permission that |
| 2038 | * a receiver must hold in order to receive your broadcast. |
| 2039 | * If null, no permission is required. |
| 2040 | * @param options (optional) Additional sending options, generated from a |
| 2041 | * {@link android.app.BroadcastOptions}. |
| 2042 | * |
| 2043 | * @see android.content.BroadcastReceiver |
| 2044 | * @see #registerReceiver |
| 2045 | * @see #sendBroadcast(Intent) |
| 2046 | * @see #sendOrderedBroadcast(Intent, String) |
| 2047 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2048 | * @hide |
| 2049 | */ |
| 2050 | @SystemApi |
| 2051 | public abstract void sendBroadcast(Intent intent, |
| 2052 | @Nullable String receiverPermission, |
| 2053 | @Nullable Bundle options); |
| 2054 | |
| 2055 | /** |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2056 | * Like {@link #sendBroadcast(Intent, String)}, but also allows specification |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2057 | * of an associated app op as per {@link android.app.AppOpsManager}. |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2058 | * @hide |
| 2059 | */ |
Mathew Inwood | 1c77a11 | 2018-08-14 14:06:26 +0100 | [diff] [blame] | 2060 | @UnsupportedAppUsage |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2061 | public abstract void sendBroadcast(Intent intent, |
| 2062 | String receiverPermission, int appOp); |
| 2063 | |
| 2064 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2065 | * Broadcast the given intent to all interested BroadcastReceivers, delivering |
| 2066 | * them one at a time to allow more preferred receivers to consume the |
| 2067 | * broadcast before it is delivered to less preferred receivers. This |
| 2068 | * call is asynchronous; it returns immediately, and you will continue |
| 2069 | * executing while the receivers are run. |
| 2070 | * |
| 2071 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2072 | * |
| 2073 | * @param intent The Intent to broadcast; all receivers matching this |
| 2074 | * Intent will receive the broadcast. |
| 2075 | * @param receiverPermission (optional) String naming a permissions that |
| 2076 | * a receiver must hold in order to receive your broadcast. |
| 2077 | * If null, no permission is required. |
| 2078 | * |
| 2079 | * @see android.content.BroadcastReceiver |
| 2080 | * @see #registerReceiver |
| 2081 | * @see #sendBroadcast(Intent) |
| 2082 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2083 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2084 | public abstract void sendOrderedBroadcast(@RequiresPermission Intent intent, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2085 | @Nullable String receiverPermission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2086 | |
| 2087 | /** |
| 2088 | * Version of {@link #sendBroadcast(Intent)} that allows you to |
| 2089 | * receive data back from the broadcast. This is accomplished by |
| 2090 | * supplying your own BroadcastReceiver when calling, which will be |
| 2091 | * treated as a final receiver at the end of the broadcast -- its |
| 2092 | * {@link BroadcastReceiver#onReceive} method will be called with |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2093 | * 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] | 2094 | * be serialized in the same way as calling |
| 2095 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2096 | * |
| 2097 | * <p>Like {@link #sendBroadcast(Intent)}, this method is |
| 2098 | * asynchronous; it will return before |
| 2099 | * resultReceiver.onReceive() is called. |
| 2100 | * |
| 2101 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2102 | * |
| 2103 | * @param intent The Intent to broadcast; all receivers matching this |
| 2104 | * Intent will receive the broadcast. |
| 2105 | * @param receiverPermission String naming a permissions that |
| 2106 | * a receiver must hold in order to receive your broadcast. |
| 2107 | * If null, no permission is required. |
| 2108 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2109 | * receiver of the broadcast. |
| 2110 | * @param scheduler A custom Handler with which to schedule the |
| 2111 | * resultReceiver callback; if null it will be |
| 2112 | * scheduled in the Context's main thread. |
| 2113 | * @param initialCode An initial value for the result code. Often |
| 2114 | * Activity.RESULT_OK. |
| 2115 | * @param initialData An initial value for the result data. Often |
| 2116 | * null. |
| 2117 | * @param initialExtras An initial value for the result extras. Often |
| 2118 | * null. |
| 2119 | * |
| 2120 | * @see #sendBroadcast(Intent) |
| 2121 | * @see #sendBroadcast(Intent, String) |
| 2122 | * @see #sendOrderedBroadcast(Intent, String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2123 | * @see android.content.BroadcastReceiver |
| 2124 | * @see #registerReceiver |
| 2125 | * @see android.app.Activity#RESULT_OK |
| 2126 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2127 | public abstract void sendOrderedBroadcast(@RequiresPermission @NonNull Intent intent, |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 2128 | @Nullable String receiverPermission, @Nullable BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2129 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2130 | @Nullable Bundle initialExtras); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2131 | |
| 2132 | /** |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 2133 | * Version of {@link #sendBroadcast(Intent)} that allows you to |
| 2134 | * receive data back from the broadcast. This is accomplished by |
| 2135 | * supplying your own BroadcastReceiver when calling, which will be |
| 2136 | * treated as a final receiver at the end of the broadcast -- its |
| 2137 | * {@link BroadcastReceiver#onReceive} method will be called with |
| 2138 | * the result values collected from the other receivers. The broadcast will |
| 2139 | * be serialized in the same way as calling |
| 2140 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2141 | * |
| 2142 | * <p>Like {@link #sendBroadcast(Intent)}, this method is |
| 2143 | * asynchronous; it will return before |
| 2144 | * resultReceiver.onReceive() is called. |
| 2145 | * |
| 2146 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2147 | * |
| 2148 | * |
| 2149 | * @param intent The Intent to broadcast; all receivers matching this |
| 2150 | * Intent will receive the broadcast. |
| 2151 | * @param receiverPermission String naming a permissions that |
| 2152 | * a receiver must hold in order to receive your broadcast. |
| 2153 | * If null, no permission is required. |
| 2154 | * @param options (optional) Additional sending options, generated from a |
| 2155 | * {@link android.app.BroadcastOptions}. |
| 2156 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2157 | * receiver of the broadcast. |
| 2158 | * @param scheduler A custom Handler with which to schedule the |
| 2159 | * resultReceiver callback; if null it will be |
| 2160 | * scheduled in the Context's main thread. |
| 2161 | * @param initialCode An initial value for the result code. Often |
| 2162 | * Activity.RESULT_OK. |
| 2163 | * @param initialData An initial value for the result data. Often |
| 2164 | * null. |
| 2165 | * @param initialExtras An initial value for the result extras. Often |
| 2166 | * null. |
| 2167 | * @see #sendBroadcast(Intent) |
| 2168 | * @see #sendBroadcast(Intent, String) |
| 2169 | * @see #sendOrderedBroadcast(Intent, String) |
| 2170 | * @see android.content.BroadcastReceiver |
| 2171 | * @see #registerReceiver |
| 2172 | * @see android.app.Activity#RESULT_OK |
| 2173 | * @hide |
| 2174 | */ |
| 2175 | @SystemApi |
| 2176 | public abstract void sendOrderedBroadcast(@NonNull Intent intent, |
| 2177 | @Nullable String receiverPermission, @Nullable Bundle options, |
| 2178 | @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, |
| 2179 | int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras); |
| 2180 | |
| 2181 | /** |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2182 | * Like {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, android.os.Handler, |
| 2183 | * int, String, android.os.Bundle)}, but also allows specification |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2184 | * of an associated app op as per {@link android.app.AppOpsManager}. |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2185 | * @hide |
| 2186 | */ |
Mathew Inwood | 1c77a11 | 2018-08-14 14:06:26 +0100 | [diff] [blame] | 2187 | @UnsupportedAppUsage |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2188 | public abstract void sendOrderedBroadcast(Intent intent, |
| 2189 | String receiverPermission, int appOp, BroadcastReceiver resultReceiver, |
| 2190 | Handler scheduler, int initialCode, String initialData, |
| 2191 | Bundle initialExtras); |
| 2192 | |
| 2193 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2194 | * Version of {@link #sendBroadcast(Intent)} that allows you to specify the |
| 2195 | * 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] | 2196 | * that are not pre-installed on the system image. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2197 | * @param intent The intent to broadcast |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 2198 | * @param user UserHandle to send the intent to. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2199 | * @see #sendBroadcast(Intent) |
| 2200 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2201 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2202 | public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent, |
| 2203 | UserHandle user); |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2204 | |
| 2205 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2206 | * Version of {@link #sendBroadcast(Intent, String)} that allows you to specify the |
| 2207 | * 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] | 2208 | * that are not pre-installed on the system image. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2209 | * |
| 2210 | * @param intent The Intent to broadcast; all receivers matching this |
| 2211 | * Intent will receive the broadcast. |
| 2212 | * @param user UserHandle to send the intent to. |
| 2213 | * @param receiverPermission (optional) String naming a permission that |
| 2214 | * a receiver must hold in order to receive your broadcast. |
| 2215 | * If null, no permission is required. |
| 2216 | * |
| 2217 | * @see #sendBroadcast(Intent, String) |
| 2218 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2219 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2220 | public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent, |
| 2221 | UserHandle user, @Nullable String receiverPermission); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2222 | |
Chad Brubaker | 52c8edc | 2016-07-25 14:30:26 -0700 | [diff] [blame] | 2223 | /** |
| 2224 | * Version of {@link #sendBroadcast(Intent, String, Bundle)} that allows you to specify the |
| 2225 | * 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] | 2226 | * that are not pre-installed on the system image. |
Chad Brubaker | 52c8edc | 2016-07-25 14:30:26 -0700 | [diff] [blame] | 2227 | * |
| 2228 | * @param intent The Intent to broadcast; all receivers matching this |
| 2229 | * Intent will receive the broadcast. |
| 2230 | * @param user UserHandle to send the intent to. |
| 2231 | * @param receiverPermission (optional) String naming a permission that |
| 2232 | * a receiver must hold in order to receive your broadcast. |
| 2233 | * If null, no permission is required. |
| 2234 | * @param options (optional) Additional sending options, generated from a |
| 2235 | * {@link android.app.BroadcastOptions}. |
| 2236 | * |
| 2237 | * @see #sendBroadcast(Intent, String, Bundle) |
| 2238 | * @hide |
| 2239 | */ |
| 2240 | @SystemApi |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2241 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Chad Brubaker | 52c8edc | 2016-07-25 14:30:26 -0700 | [diff] [blame] | 2242 | public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent, |
| 2243 | UserHandle user, @Nullable String receiverPermission, @Nullable Bundle options); |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 2244 | |
| 2245 | /** |
| 2246 | * Version of {@link #sendBroadcast(Intent, String)} that allows you to specify the |
| 2247 | * 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] | 2248 | * that are not pre-installed on the system image. |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 2249 | * |
| 2250 | * @param intent The Intent to broadcast; all receivers matching this |
| 2251 | * Intent will receive the broadcast. |
| 2252 | * @param user UserHandle to send the intent to. |
| 2253 | * @param receiverPermission (optional) String naming a permission that |
| 2254 | * a receiver must hold in order to receive your broadcast. |
| 2255 | * If null, no permission is required. |
| 2256 | * @param appOp The app op associated with the broadcast. |
| 2257 | * |
| 2258 | * @see #sendBroadcast(Intent, String) |
| 2259 | * |
| 2260 | * @hide |
| 2261 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2262 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Mathew Inwood | 1c77a11 | 2018-08-14 14:06:26 +0100 | [diff] [blame] | 2263 | @UnsupportedAppUsage |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2264 | public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent, |
| 2265 | UserHandle user, @Nullable String receiverPermission, int appOp); |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 2266 | |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2267 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2268 | * Version of |
| 2269 | * {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)} |
| 2270 | * that allows you to specify the |
| 2271 | * 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] | 2272 | * that are not pre-installed on the system image. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2273 | * |
| 2274 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2275 | * |
| 2276 | * @param intent The Intent to broadcast; all receivers matching this |
| 2277 | * Intent will receive the broadcast. |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 2278 | * @param user UserHandle to send the intent to. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2279 | * @param receiverPermission String naming a permissions that |
| 2280 | * a receiver must hold in order to receive your broadcast. |
| 2281 | * If null, no permission is required. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2282 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2283 | * receiver of the broadcast. |
| 2284 | * @param scheduler A custom Handler with which to schedule the |
| 2285 | * resultReceiver callback; if null it will be |
| 2286 | * scheduled in the Context's main thread. |
| 2287 | * @param initialCode An initial value for the result code. Often |
| 2288 | * Activity.RESULT_OK. |
| 2289 | * @param initialData An initial value for the result data. Often |
| 2290 | * null. |
| 2291 | * @param initialExtras An initial value for the result extras. Often |
| 2292 | * null. |
| 2293 | * |
| 2294 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2295 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2296 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2297 | public abstract void sendOrderedBroadcastAsUser(@RequiresPermission Intent intent, |
| 2298 | UserHandle user, @Nullable String receiverPermission, BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2299 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2300 | @Nullable Bundle initialExtras); |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2301 | |
| 2302 | /** |
Amith Yamasani | 3cf7572 | 2014-05-16 12:37:29 -0700 | [diff] [blame] | 2303 | * Similar to above but takes an appOp as well, to enforce restrictions. |
| 2304 | * @see #sendOrderedBroadcastAsUser(Intent, UserHandle, String, |
| 2305 | * BroadcastReceiver, Handler, int, String, Bundle) |
| 2306 | * @hide |
| 2307 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2308 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Mathew Inwood | 1c77a11 | 2018-08-14 14:06:26 +0100 | [diff] [blame] | 2309 | @UnsupportedAppUsage |
Amith Yamasani | 3cf7572 | 2014-05-16 12:37:29 -0700 | [diff] [blame] | 2310 | public abstract void sendOrderedBroadcastAsUser(Intent intent, UserHandle user, |
| 2311 | @Nullable String receiverPermission, int appOp, BroadcastReceiver resultReceiver, |
| 2312 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2313 | @Nullable Bundle initialExtras); |
| 2314 | |
| 2315 | /** |
Dianne Hackborn | fd854ee | 2015-07-13 18:00:37 -0700 | [diff] [blame] | 2316 | * Similar to above but takes an appOp as well, to enforce restrictions, and an options Bundle. |
| 2317 | * @see #sendOrderedBroadcastAsUser(Intent, UserHandle, String, |
| 2318 | * BroadcastReceiver, Handler, int, String, Bundle) |
| 2319 | * @hide |
| 2320 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2321 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Mathew Inwood | 1c77a11 | 2018-08-14 14:06:26 +0100 | [diff] [blame] | 2322 | @UnsupportedAppUsage |
Dianne Hackborn | fd854ee | 2015-07-13 18:00:37 -0700 | [diff] [blame] | 2323 | public abstract void sendOrderedBroadcastAsUser(Intent intent, UserHandle user, |
| 2324 | @Nullable String receiverPermission, int appOp, @Nullable Bundle options, |
| 2325 | BroadcastReceiver resultReceiver, @Nullable Handler scheduler, int initialCode, |
| 2326 | @Nullable String initialData, @Nullable Bundle initialExtras); |
| 2327 | |
| 2328 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2329 | * <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] | 2330 | * Intent you are sending stays around after the broadcast is complete, |
| 2331 | * so that others can quickly retrieve that data through the return |
| 2332 | * value of {@link #registerReceiver(BroadcastReceiver, IntentFilter)}. In |
| 2333 | * all other ways, this behaves the same as |
| 2334 | * {@link #sendBroadcast(Intent)}. |
| 2335 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2336 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2337 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2338 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2339 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2340 | * desired. |
| 2341 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2342 | * @param intent The Intent to broadcast; all receivers matching this |
| 2343 | * Intent will receive the broadcast, and the Intent will be held to |
| 2344 | * be re-broadcast to future receivers. |
| 2345 | * |
| 2346 | * @see #sendBroadcast(Intent) |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2347 | * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2348 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2349 | @Deprecated |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 2350 | @RequiresPermission(android.Manifest.permission.BROADCAST_STICKY) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2351 | public abstract void sendStickyBroadcast(@RequiresPermission Intent intent); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2352 | |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2353 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2354 | * <p>Version of {@link #sendStickyBroadcast} that allows you to |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2355 | * receive data back from the broadcast. This is accomplished by |
| 2356 | * supplying your own BroadcastReceiver when calling, which will be |
| 2357 | * treated as a final receiver at the end of the broadcast -- its |
| 2358 | * {@link BroadcastReceiver#onReceive} method will be called with |
| 2359 | * the result values collected from the other receivers. The broadcast will |
| 2360 | * be serialized in the same way as calling |
| 2361 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2362 | * |
| 2363 | * <p>Like {@link #sendBroadcast(Intent)}, this method is |
| 2364 | * asynchronous; it will return before |
| 2365 | * resultReceiver.onReceive() is called. Note that the sticky data |
| 2366 | * stored is only the data you initially supply to the broadcast, not |
| 2367 | * the result of any changes made by the receivers. |
| 2368 | * |
| 2369 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2370 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2371 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2372 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2373 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2374 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2375 | * desired. |
| 2376 | * |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2377 | * @param intent The Intent to broadcast; all receivers matching this |
| 2378 | * Intent will receive the broadcast. |
| 2379 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2380 | * receiver of the broadcast. |
| 2381 | * @param scheduler A custom Handler with which to schedule the |
| 2382 | * resultReceiver callback; if null it will be |
| 2383 | * scheduled in the Context's main thread. |
| 2384 | * @param initialCode An initial value for the result code. Often |
| 2385 | * Activity.RESULT_OK. |
| 2386 | * @param initialData An initial value for the result data. Often |
| 2387 | * null. |
| 2388 | * @param initialExtras An initial value for the result extras. Often |
| 2389 | * null. |
| 2390 | * |
| 2391 | * @see #sendBroadcast(Intent) |
| 2392 | * @see #sendBroadcast(Intent, String) |
| 2393 | * @see #sendOrderedBroadcast(Intent, String) |
| 2394 | * @see #sendStickyBroadcast(Intent) |
| 2395 | * @see android.content.BroadcastReceiver |
| 2396 | * @see #registerReceiver |
| 2397 | * @see android.app.Activity#RESULT_OK |
| 2398 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2399 | @Deprecated |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 2400 | @RequiresPermission(android.Manifest.permission.BROADCAST_STICKY) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2401 | public abstract void sendStickyOrderedBroadcast(@RequiresPermission Intent intent, |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2402 | BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2403 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2404 | @Nullable Bundle initialExtras); |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2405 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2406 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2407 | * <p>Remove the data previously sent with {@link #sendStickyBroadcast}, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2408 | * so that it is as if the sticky broadcast had never happened. |
| 2409 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2410 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2411 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2412 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2413 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2414 | * desired. |
| 2415 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2416 | * @param intent The Intent that was previously broadcast. |
| 2417 | * |
| 2418 | * @see #sendStickyBroadcast |
| 2419 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2420 | @Deprecated |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 2421 | @RequiresPermission(android.Manifest.permission.BROADCAST_STICKY) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2422 | public abstract void removeStickyBroadcast(@RequiresPermission Intent intent); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2423 | |
| 2424 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2425 | * <p>Version of {@link #sendStickyBroadcast(Intent)} that allows you to specify the |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2426 | * 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] | 2427 | * that are not pre-installed on the system image. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2428 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2429 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2430 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2431 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2432 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2433 | * desired. |
| 2434 | * |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2435 | * @param intent The Intent to broadcast; all receivers matching this |
| 2436 | * Intent will receive the broadcast, and the Intent will be held to |
| 2437 | * be re-broadcast to future receivers. |
| 2438 | * @param user UserHandle to send the intent to. |
| 2439 | * |
| 2440 | * @see #sendBroadcast(Intent) |
| 2441 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2442 | @Deprecated |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2443 | @RequiresPermission(allOf = { |
| 2444 | android.Manifest.permission.INTERACT_ACROSS_USERS, |
| 2445 | android.Manifest.permission.BROADCAST_STICKY |
| 2446 | }) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2447 | public abstract void sendStickyBroadcastAsUser(@RequiresPermission Intent intent, |
| 2448 | UserHandle user); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2449 | |
| 2450 | /** |
Dianne Hackborn | e0e413e | 2015-12-09 17:22:26 -0800 | [diff] [blame] | 2451 | * @hide |
| 2452 | * This is just here for sending CONNECTIVITY_ACTION. |
| 2453 | */ |
| 2454 | @Deprecated |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2455 | @RequiresPermission(allOf = { |
| 2456 | android.Manifest.permission.INTERACT_ACROSS_USERS, |
| 2457 | android.Manifest.permission.BROADCAST_STICKY |
| 2458 | }) |
Dianne Hackborn | e0e413e | 2015-12-09 17:22:26 -0800 | [diff] [blame] | 2459 | public abstract void sendStickyBroadcastAsUser(@RequiresPermission Intent intent, |
| 2460 | UserHandle user, Bundle options); |
| 2461 | |
| 2462 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2463 | * <p>Version of |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2464 | * {@link #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)} |
| 2465 | * that allows you to specify the |
| 2466 | * 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] | 2467 | * that are not pre-installed on the system image. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2468 | * |
| 2469 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2470 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2471 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2472 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2473 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2474 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2475 | * desired. |
| 2476 | * |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2477 | * @param intent The Intent to broadcast; all receivers matching this |
| 2478 | * Intent will receive the broadcast. |
| 2479 | * @param user UserHandle to send the intent to. |
| 2480 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2481 | * receiver of the broadcast. |
| 2482 | * @param scheduler A custom Handler with which to schedule the |
| 2483 | * resultReceiver callback; if null it will be |
| 2484 | * scheduled in the Context's main thread. |
| 2485 | * @param initialCode An initial value for the result code. Often |
| 2486 | * Activity.RESULT_OK. |
| 2487 | * @param initialData An initial value for the result data. Often |
| 2488 | * null. |
| 2489 | * @param initialExtras An initial value for the result extras. Often |
| 2490 | * null. |
| 2491 | * |
| 2492 | * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle) |
| 2493 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2494 | @Deprecated |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2495 | @RequiresPermission(allOf = { |
| 2496 | android.Manifest.permission.INTERACT_ACROSS_USERS, |
| 2497 | android.Manifest.permission.BROADCAST_STICKY |
| 2498 | }) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2499 | public abstract void sendStickyOrderedBroadcastAsUser(@RequiresPermission Intent intent, |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2500 | UserHandle user, BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2501 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2502 | @Nullable Bundle initialExtras); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2503 | |
| 2504 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2505 | * <p>Version of {@link #removeStickyBroadcast(Intent)} that allows you to specify the |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2506 | * 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] | 2507 | * that are not pre-installed on the system image. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2508 | * |
| 2509 | * <p>You must hold the {@link android.Manifest.permission#BROADCAST_STICKY} |
| 2510 | * permission in order to use this API. If you do not hold that |
| 2511 | * permission, {@link SecurityException} will be thrown. |
| 2512 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2513 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2514 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2515 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2516 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2517 | * desired. |
| 2518 | * |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2519 | * @param intent The Intent that was previously broadcast. |
| 2520 | * @param user UserHandle to remove the sticky broadcast from. |
| 2521 | * |
| 2522 | * @see #sendStickyBroadcastAsUser |
| 2523 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2524 | @Deprecated |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2525 | @RequiresPermission(allOf = { |
| 2526 | android.Manifest.permission.INTERACT_ACROSS_USERS, |
| 2527 | android.Manifest.permission.BROADCAST_STICKY |
| 2528 | }) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2529 | public abstract void removeStickyBroadcastAsUser(@RequiresPermission Intent intent, |
| 2530 | UserHandle user); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2531 | |
| 2532 | /** |
Chris Tate | a34df8a2 | 2009-04-02 23:15:58 -0700 | [diff] [blame] | 2533 | * 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] | 2534 | * <var>receiver</var> will be called with any broadcast Intent that |
| 2535 | * matches <var>filter</var>, in the main application thread. |
| 2536 | * |
| 2537 | * <p>The system may broadcast Intents that are "sticky" -- these stay |
Kweku Adams | 86f39a4 | 2016-11-16 12:50:38 -0800 | [diff] [blame] | 2538 | * 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] | 2539 | * registrations. If your IntentFilter matches one of these sticky |
| 2540 | * Intents, that Intent will be returned by this function |
| 2541 | * <strong>and</strong> sent to your <var>receiver</var> as if it had just |
| 2542 | * been broadcast. |
| 2543 | * |
| 2544 | * <p>There may be multiple sticky Intents that match <var>filter</var>, |
| 2545 | * in which case each of these will be sent to <var>receiver</var>. In |
| 2546 | * this case, only one of these can be returned directly by the function; |
| 2547 | * which of these that is returned is arbitrarily decided by the system. |
| 2548 | * |
| 2549 | * <p>If you know the Intent your are registering for is sticky, you can |
| 2550 | * supply null for your <var>receiver</var>. In this case, no receiver is |
| 2551 | * registered -- the function simply returns the sticky Intent that |
| 2552 | * matches <var>filter</var>. In the case of multiple matches, the same |
| 2553 | * rules as described above apply. |
| 2554 | * |
| 2555 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2556 | * |
Dianne Hackborn | 6c418d5 | 2011-06-29 14:05:33 -0700 | [diff] [blame] | 2557 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 2558 | * registered with this method will correctly respect the |
| 2559 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 2560 | * Prior to that, it would be ignored and delivered to all matching registered |
| 2561 | * receivers. Be careful if using this for security.</p> |
| 2562 | * |
Chris Tate | a34df8a2 | 2009-04-02 23:15:58 -0700 | [diff] [blame] | 2563 | * <p class="note">Note: this method <em>cannot be called from a |
| 2564 | * {@link BroadcastReceiver} component;</em> that is, from a BroadcastReceiver |
| 2565 | * that is declared in an application's manifest. It is okay, however, to call |
| 2566 | * this method from another BroadcastReceiver that has itself been registered |
| 2567 | * at run time with {@link #registerReceiver}, since the lifetime of such a |
| 2568 | * 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] | 2569 | * |
| 2570 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2571 | * @param filter Selects the Intent broadcasts to be received. |
| 2572 | * |
| 2573 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2574 | * or null if there are none. |
| 2575 | * |
| 2576 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
| 2577 | * @see #sendBroadcast |
| 2578 | * @see #unregisterReceiver |
| 2579 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2580 | @Nullable |
| 2581 | public abstract Intent registerReceiver(@Nullable BroadcastReceiver receiver, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2582 | IntentFilter filter); |
| 2583 | |
| 2584 | /** |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2585 | * Register to receive intent broadcasts, with the receiver optionally being |
| 2586 | * exposed to Instant Apps. See |
| 2587 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter)} for more |
| 2588 | * information. By default Instant Apps cannot interact with receivers in other |
| 2589 | * applications, this allows you to expose a receiver that Instant Apps can |
| 2590 | * interact with. |
| 2591 | * |
| 2592 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2593 | * |
| 2594 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 2595 | * registered with this method will correctly respect the |
| 2596 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 2597 | * Prior to that, it would be ignored and delivered to all matching registered |
| 2598 | * receivers. Be careful if using this for security.</p> |
| 2599 | * |
| 2600 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2601 | * @param filter Selects the Intent broadcasts to be received. |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2602 | * @param flags Additional options for the receiver. May be 0 or |
| 2603 | * {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2604 | * |
| 2605 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2606 | * or null if there are none. |
| 2607 | * |
| 2608 | * @see #registerReceiver(BroadcastReceiver, IntentFilter) |
| 2609 | * @see #sendBroadcast |
| 2610 | * @see #unregisterReceiver |
| 2611 | */ |
| 2612 | @Nullable |
| 2613 | public abstract Intent registerReceiver(@Nullable BroadcastReceiver receiver, |
| 2614 | IntentFilter filter, |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2615 | @RegisterReceiverFlags int flags); |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2616 | |
| 2617 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2618 | * Register to receive intent broadcasts, to run in the context of |
| 2619 | * <var>scheduler</var>. See |
| 2620 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter)} for more |
| 2621 | * information. This allows you to enforce permissions on who can |
| 2622 | * broadcast intents to your receiver, or have the receiver run in |
| 2623 | * a different thread than the main application thread. |
| 2624 | * |
| 2625 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2626 | * |
Dianne Hackborn | 6c418d5 | 2011-06-29 14:05:33 -0700 | [diff] [blame] | 2627 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 2628 | * registered with this method will correctly respect the |
| 2629 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 2630 | * Prior to that, it would be ignored and delivered to all matching registered |
| 2631 | * receivers. Be careful if using this for security.</p> |
| 2632 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2633 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2634 | * @param filter Selects the Intent broadcasts to be received. |
| 2635 | * @param broadcastPermission String naming a permissions that a |
| 2636 | * broadcaster must hold in order to send an Intent to you. If null, |
| 2637 | * no permission is required. |
| 2638 | * @param scheduler Handler identifying the thread that will receive |
| 2639 | * the Intent. If null, the main thread of the process will be used. |
| 2640 | * |
| 2641 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2642 | * or null if there are none. |
| 2643 | * |
| 2644 | * @see #registerReceiver(BroadcastReceiver, IntentFilter) |
| 2645 | * @see #sendBroadcast |
| 2646 | * @see #unregisterReceiver |
| 2647 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2648 | @Nullable |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2649 | public abstract Intent registerReceiver(BroadcastReceiver receiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2650 | IntentFilter filter, @Nullable String broadcastPermission, |
| 2651 | @Nullable Handler scheduler); |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2652 | |
| 2653 | /** |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2654 | * Register to receive intent broadcasts, to run in the context of |
| 2655 | * <var>scheduler</var>. See |
| 2656 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter, int)} and |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2657 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler)} |
| 2658 | * for more information. |
| 2659 | * |
| 2660 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2661 | * |
| 2662 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 2663 | * registered with this method will correctly respect the |
| 2664 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 2665 | * Prior to that, it would be ignored and delivered to all matching registered |
| 2666 | * receivers. Be careful if using this for security.</p> |
| 2667 | * |
| 2668 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2669 | * @param filter Selects the Intent broadcasts to be received. |
| 2670 | * @param broadcastPermission String naming a permissions that a |
| 2671 | * broadcaster must hold in order to send an Intent to you. If null, |
| 2672 | * no permission is required. |
| 2673 | * @param scheduler Handler identifying the thread that will receive |
| 2674 | * 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] | 2675 | * @param flags Additional options for the receiver. May be 0 or |
| 2676 | * {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2677 | * |
| 2678 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2679 | * or null if there are none. |
| 2680 | * |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2681 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, int) |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2682 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
| 2683 | * @see #sendBroadcast |
| 2684 | * @see #unregisterReceiver |
| 2685 | */ |
| 2686 | @Nullable |
| 2687 | public abstract Intent registerReceiver(BroadcastReceiver receiver, |
| 2688 | IntentFilter filter, @Nullable String broadcastPermission, |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2689 | @Nullable Handler scheduler, @RegisterReceiverFlags int flags); |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2690 | |
| 2691 | /** |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2692 | * @hide |
| 2693 | * Same as {@link #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
| 2694 | * but for a specific user. This receiver will receiver broadcasts that |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2695 | * are sent to the requested user. |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2696 | * |
| 2697 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2698 | * @param user UserHandle to send the intent to. |
| 2699 | * @param filter Selects the Intent broadcasts to be received. |
| 2700 | * @param broadcastPermission String naming a permissions that a |
| 2701 | * broadcaster must hold in order to send an Intent to you. If null, |
| 2702 | * no permission is required. |
| 2703 | * @param scheduler Handler identifying the thread that will receive |
| 2704 | * the Intent. If null, the main thread of the process will be used. |
| 2705 | * |
| 2706 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2707 | * or null if there are none. |
| 2708 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 2709 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2710 | * @see #sendBroadcast |
| 2711 | * @see #unregisterReceiver |
| 2712 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2713 | @Nullable |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2714 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) |
Mathew Inwood | 1c77a11 | 2018-08-14 14:06:26 +0100 | [diff] [blame] | 2715 | @UnsupportedAppUsage |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2716 | public abstract Intent registerReceiverAsUser(BroadcastReceiver receiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2717 | UserHandle user, IntentFilter filter, @Nullable String broadcastPermission, |
| 2718 | @Nullable Handler scheduler); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2719 | |
| 2720 | /** |
| 2721 | * Unregister a previously registered BroadcastReceiver. <em>All</em> |
| 2722 | * filters that have been registered for this BroadcastReceiver will be |
| 2723 | * removed. |
| 2724 | * |
| 2725 | * @param receiver The BroadcastReceiver to unregister. |
| 2726 | * |
| 2727 | * @see #registerReceiver |
| 2728 | */ |
| 2729 | public abstract void unregisterReceiver(BroadcastReceiver receiver); |
| 2730 | |
| 2731 | /** |
| 2732 | * Request that a given application service be started. The Intent |
Hans Boehm | fb9f6ac | 2016-05-05 13:09:28 -0700 | [diff] [blame] | 2733 | * should either contain the complete class name of a specific service |
| 2734 | * implementation to start, or a specific package name to target. If the |
| 2735 | * Intent is less specified, it logs a warning about this. In this case any of the |
| 2736 | * multiple matching services may be used. If this service |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2737 | * is not already running, it will be instantiated and started (creating a |
| 2738 | * process for it if needed); if it is running then it remains running. |
| 2739 | * |
| 2740 | * <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] | 2741 | * 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] | 2742 | * with the <var>intent</var> given here. This provides a convenient way |
| 2743 | * to submit jobs to a service without having to bind and call on to its |
| 2744 | * interface. |
| 2745 | * |
| 2746 | * <p>Using startService() overrides the default service lifetime that is |
| 2747 | * managed by {@link #bindService}: it requires the service to remain |
| 2748 | * running until {@link #stopService} is called, regardless of whether |
| 2749 | * any clients are connected to it. Note that calls to startService() |
Hans Boehm | fb9f6ac | 2016-05-05 13:09:28 -0700 | [diff] [blame] | 2750 | * 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] | 2751 | * a single call to {@link #stopService} will stop it. |
| 2752 | * |
| 2753 | * <p>The system attempts to keep running services around as much as |
| 2754 | * possible. The only time they should be stopped is if the current |
| 2755 | * foreground application is using so many resources that the service needs |
| 2756 | * to be killed. If any errors happen in the service's process, it will |
| 2757 | * automatically be restarted. |
| 2758 | * |
| 2759 | * <p>This function will throw {@link SecurityException} if you do not |
| 2760 | * have permission to start the given service. |
| 2761 | * |
Chris Craik | 1e35352 | 2016-04-18 10:20:50 -0700 | [diff] [blame] | 2762 | * <p class="note"><strong>Note:</strong> Each call to startService() |
| 2763 | * results in significant work done by the system to manage service |
| 2764 | * lifecycle surrounding the processing of the intent, which can take |
| 2765 | * multiple milliseconds of CPU time. Due to this cost, startService() |
| 2766 | * should not be used for frequent intent delivery to a service, and only |
| 2767 | * for scheduling significant work. Use {@link #bindService bound services} |
| 2768 | * for high frequency calls. |
| 2769 | * </p> |
| 2770 | * |
Mark Lu | 94ebbe0 | 2016-12-13 16:29:51 -0800 | [diff] [blame] | 2771 | * @param service Identifies the service to be started. The Intent must be |
| 2772 | * fully explicit (supplying a component name). Additional values |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2773 | * may be included in the Intent extras to supply arguments along with |
| 2774 | * this specific start call. |
| 2775 | * |
| 2776 | * @return If the service is being started or is already running, the |
| 2777 | * {@link ComponentName} of the actual service that was started is |
| 2778 | * returned; else if the service does not exist null is returned. |
| 2779 | * |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2780 | * @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] | 2781 | * or the service can not be found. |
| 2782 | * @throws IllegalStateException If the application is in a state where the service |
| 2783 | * 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] | 2784 | * |
| 2785 | * @see #stopService |
| 2786 | * @see #bindService |
| 2787 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2788 | @Nullable |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2789 | public abstract ComponentName startService(Intent service); |
| 2790 | |
| 2791 | /** |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2792 | * Similar to {@link #startService(Intent)}, but with an implicit promise that the |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 2793 | * Service will call {@link android.app.Service#startForeground(int, android.app.Notification) |
| 2794 | * startForeground(int, android.app.Notification)} once it begins running. The service is given |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2795 | * an amount of time comparable to the ANR interval to do this, otherwise the system |
| 2796 | * will automatically stop the service and declare the app ANR. |
| 2797 | * |
| 2798 | * <p>Unlike the ordinary {@link #startService(Intent)}, this method can be used |
| 2799 | * at any time, regardless of whether the app hosting the service is in a foreground |
| 2800 | * state. |
| 2801 | * |
| 2802 | * @param service Identifies the service to be started. The Intent must be |
| 2803 | * fully explicit (supplying a component name). Additional values |
| 2804 | * may be included in the Intent extras to supply arguments along with |
| 2805 | * this specific start call. |
| 2806 | * |
| 2807 | * @return If the service is being started or is already running, the |
| 2808 | * {@link ComponentName} of the actual service that was started is |
| 2809 | * returned; else if the service does not exist null is returned. |
| 2810 | * |
| 2811 | * @throws SecurityException If the caller does not have permission to access the service |
| 2812 | * or the service can not be found. |
| 2813 | * |
| 2814 | * @see #stopService |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 2815 | * @see android.app.Service#startForeground(int, android.app.Notification) |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2816 | */ |
| 2817 | @Nullable |
| 2818 | public abstract ComponentName startForegroundService(Intent service); |
| 2819 | |
| 2820 | /** |
| 2821 | * @hide like {@link #startForegroundService(Intent)} but for a specific user. |
| 2822 | */ |
| 2823 | @Nullable |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2824 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2825 | public abstract ComponentName startForegroundServiceAsUser(Intent service, UserHandle user); |
| 2826 | |
| 2827 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2828 | * Request that a given application service be stopped. If the service is |
| 2829 | * not running, nothing happens. Otherwise it is stopped. Note that calls |
| 2830 | * to startService() are not counted -- this stops the service no matter |
| 2831 | * how many times it was started. |
| 2832 | * |
| 2833 | * <p>Note that if a stopped service still has {@link ServiceConnection} |
| 2834 | * objects bound to it with the {@link #BIND_AUTO_CREATE} set, it will |
| 2835 | * not be destroyed until all of these bindings are removed. See |
| 2836 | * the {@link android.app.Service} documentation for more details on a |
| 2837 | * service's lifecycle. |
| 2838 | * |
| 2839 | * <p>This function will throw {@link SecurityException} if you do not |
| 2840 | * have permission to stop the given service. |
| 2841 | * |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 2842 | * @param service Description of the service to be stopped. The Intent must be either |
| 2843 | * fully explicit (supplying a component name) or specify a specific package |
kopriva | 219f7dc | 2018-10-09 13:42:28 -0700 | [diff] [blame] | 2844 | * name it is targeted to. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2845 | * |
| 2846 | * @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] | 2847 | * 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] | 2848 | * |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2849 | * @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] | 2850 | * or the service can not be found. |
| 2851 | * @throws IllegalStateException If the application is in a state where the service |
| 2852 | * 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] | 2853 | * |
| 2854 | * @see #startService |
| 2855 | */ |
| 2856 | public abstract boolean stopService(Intent service); |
| 2857 | |
| 2858 | /** |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 2859 | * @hide like {@link #startService(Intent)} but for a specific user. |
| 2860 | */ |
Christopher Tate | 42a386b | 2016-11-07 12:21:21 -0800 | [diff] [blame] | 2861 | @Nullable |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2862 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Mathew Inwood | 1c77a11 | 2018-08-14 14:06:26 +0100 | [diff] [blame] | 2863 | @UnsupportedAppUsage |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 2864 | public abstract ComponentName startServiceAsUser(Intent service, UserHandle user); |
| 2865 | |
| 2866 | /** |
| 2867 | * @hide like {@link #stopService(Intent)} but for a specific user. |
| 2868 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2869 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 2870 | public abstract boolean stopServiceAsUser(Intent service, UserHandle user); |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 2871 | |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 2872 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2873 | * Connect to an application service, creating it if needed. This defines |
| 2874 | * a dependency between your application and the service. The given |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 2875 | * <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] | 2876 | * told if it dies and restarts. The service will be considered required |
| 2877 | * by the system only for as long as the calling context exists. For |
| 2878 | * example, if this Context is an Activity that is stopped, the service will |
| 2879 | * not be required to continue running until the Activity is resumed. |
| 2880 | * |
Christopher Tate | 5d73b6d | 2017-10-06 16:15:34 -0700 | [diff] [blame] | 2881 | * <p>If the service does not support binding, it may return {@code null} from |
| 2882 | * its {@link android.app.Service#onBind(Intent) onBind()} method. If it does, then |
| 2883 | * the ServiceConnection's |
| 2884 | * {@link ServiceConnection#onNullBinding(ComponentName) onNullBinding()} method |
| 2885 | * will be invoked instead of |
| 2886 | * {@link ServiceConnection#onServiceConnected(ComponentName, IBinder) onServiceConnected()}. |
| 2887 | * |
| 2888 | * <p>This method will throw {@link SecurityException} if the calling app does not |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2889 | * have permission to bind to the given service. |
| 2890 | * |
Christopher Tate | 5d73b6d | 2017-10-06 16:15:34 -0700 | [diff] [blame] | 2891 | * <p class="note">Note: this method <em>cannot be called from a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2892 | * {@link BroadcastReceiver} component</em>. A pattern you can use to |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 2893 | * 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] | 2894 | * {@link #startService} with the arguments containing the command to be |
| 2895 | * sent, with the service calling its |
| 2896 | * {@link android.app.Service#stopSelf(int)} method when done executing |
| 2897 | * that command. See the API demo App/Service/Service Start Arguments |
| 2898 | * Controller for an illustration of this. It is okay, however, to use |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 2899 | * 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] | 2900 | * {@link #registerReceiver}, since the lifetime of this BroadcastReceiver |
| 2901 | * is tied to another object (the one that registered it).</p> |
| 2902 | * |
Mark Lu | 94ebbe0 | 2016-12-13 16:29:51 -0800 | [diff] [blame] | 2903 | * @param service Identifies the service to connect to. The Intent must |
| 2904 | * specify an explicit component name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2905 | * @param conn Receives information as the service is started and stopped. |
Christopher Tate | 79b3317 | 2012-06-18 14:54:21 -0700 | [diff] [blame] | 2906 | * This must be a valid ServiceConnection object; it must not be null. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2907 | * @param flags Operation options for the binding. May be 0, |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 2908 | * {@link #BIND_AUTO_CREATE}, {@link #BIND_DEBUG_UNBIND}, |
| 2909 | * {@link #BIND_NOT_FOREGROUND}, {@link #BIND_ABOVE_CLIENT}, |
| 2910 | * {@link #BIND_ALLOW_OOM_MANAGEMENT}, or |
| 2911 | * {@link #BIND_WAIVE_PRIORITY}. |
Kevin Hufnagle | 34acbc9b | 2017-06-29 15:58:48 -0700 | [diff] [blame] | 2912 | * @return {@code true} if the system is in the process of bringing up a |
| 2913 | * service that your client has permission to bind to; {@code false} |
| 2914 | * if the system couldn't find the service or if your client doesn't |
| 2915 | * have permission to bind to it. If this value is {@code true}, you |
| 2916 | * should later call {@link #unbindService} to release the |
| 2917 | * connection. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2918 | * |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2919 | * @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] | 2920 | * or the service can not be found. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2921 | * |
| 2922 | * @see #unbindService |
| 2923 | * @see #startService |
| 2924 | * @see #BIND_AUTO_CREATE |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2925 | * @see #BIND_DEBUG_UNBIND |
| 2926 | * @see #BIND_NOT_FOREGROUND |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2927 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2928 | public abstract boolean bindService(@RequiresPermission Intent service, |
| 2929 | @NonNull ServiceConnection conn, @BindServiceFlags int flags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2930 | |
| 2931 | /** |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2932 | * Same as {@link #bindService(Intent, ServiceConnection, int)}, but with an explicit userHandle |
Amith Yamasani | 37ce3a8 | 2012-02-06 12:04:42 -0800 | [diff] [blame] | 2933 | * argument for use by system server and other multi-user aware code. |
| 2934 | * @hide |
| 2935 | */ |
Amith Yamasani | c85029f | 2014-09-11 16:47:17 -0700 | [diff] [blame] | 2936 | @SystemApi |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 2937 | @SuppressWarnings("unused") |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2938 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2939 | public boolean bindServiceAsUser(@RequiresPermission Intent service, ServiceConnection conn, |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 2940 | int flags, UserHandle user) { |
Amith Yamasani | 37ce3a8 | 2012-02-06 12:04:42 -0800 | [diff] [blame] | 2941 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 2942 | } |
| 2943 | |
| 2944 | /** |
Adrian Roos | 691546e | 2016-02-09 10:13:41 -0800 | [diff] [blame] | 2945 | * Same as {@link #bindService(Intent, ServiceConnection, int, UserHandle)}, but with an |
| 2946 | * explicit non-null Handler to run the ServiceConnection callbacks on. |
| 2947 | * |
| 2948 | * @hide |
| 2949 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2950 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Mathew Inwood | 1c77a11 | 2018-08-14 14:06:26 +0100 | [diff] [blame] | 2951 | @UnsupportedAppUsage |
Adrian Roos | 691546e | 2016-02-09 10:13:41 -0800 | [diff] [blame] | 2952 | public boolean bindServiceAsUser(Intent service, ServiceConnection conn, int flags, |
| 2953 | Handler handler, UserHandle user) { |
| 2954 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 2955 | } |
| 2956 | |
| 2957 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2958 | * Disconnect from an application service. You will no longer receive |
| 2959 | * calls as the service is restarted, and the service is now allowed to |
| 2960 | * stop at any time. |
| 2961 | * |
| 2962 | * @param conn The connection interface previously supplied to |
Christopher Tate | 79b3317 | 2012-06-18 14:54:21 -0700 | [diff] [blame] | 2963 | * bindService(). This parameter must not be null. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2964 | * |
| 2965 | * @see #bindService |
| 2966 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2967 | public abstract void unbindService(@NonNull ServiceConnection conn); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2968 | |
| 2969 | /** |
| 2970 | * Start executing an {@link android.app.Instrumentation} class. The given |
| 2971 | * Instrumentation component will be run by killing its target application |
| 2972 | * (if currently running), starting the target process, instantiating the |
| 2973 | * instrumentation component, and then letting it drive the application. |
| 2974 | * |
| 2975 | * <p>This function is not synchronous -- it returns as soon as the |
| 2976 | * instrumentation has started and while it is running. |
| 2977 | * |
| 2978 | * <p>Instrumentation is normally only allowed to run against a package |
| 2979 | * that is either unsigned or signed with a signature that the |
| 2980 | * the instrumentation package is also signed with (ensuring the target |
| 2981 | * trusts the instrumentation). |
| 2982 | * |
| 2983 | * @param className Name of the Instrumentation component to be run. |
| 2984 | * @param profileFile Optional path to write profiling data as the |
| 2985 | * instrumentation runs, or null for no profiling. |
| 2986 | * @param arguments Additional optional arguments to pass to the |
| 2987 | * instrumentation, or null. |
| 2988 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 2989 | * @return {@code true} if the instrumentation was successfully started, |
| 2990 | * else {@code false} if it could not be found. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2991 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2992 | public abstract boolean startInstrumentation(@NonNull ComponentName className, |
| 2993 | @Nullable String profileFile, @Nullable Bundle arguments); |
| 2994 | |
| 2995 | /** @hide */ |
Jeff Sharkey | 5db9a91 | 2017-12-08 17:32:32 -0700 | [diff] [blame] | 2996 | @StringDef(suffix = { "_SERVICE" }, value = { |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2997 | POWER_SERVICE, |
| 2998 | WINDOW_SERVICE, |
| 2999 | LAYOUT_INFLATER_SERVICE, |
| 3000 | ACCOUNT_SERVICE, |
| 3001 | ACTIVITY_SERVICE, |
| 3002 | ALARM_SERVICE, |
| 3003 | NOTIFICATION_SERVICE, |
| 3004 | ACCESSIBILITY_SERVICE, |
| 3005 | CAPTIONING_SERVICE, |
| 3006 | KEYGUARD_SERVICE, |
| 3007 | LOCATION_SERVICE, |
| 3008 | //@hide: COUNTRY_DETECTOR, |
| 3009 | SEARCH_SERVICE, |
| 3010 | SENSOR_SERVICE, |
| 3011 | STORAGE_SERVICE, |
Jeff Sharkey | e8cece9 | 2017-01-04 11:33:33 -0700 | [diff] [blame] | 3012 | STORAGE_STATS_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3013 | WALLPAPER_SERVICE, |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 3014 | TIME_ZONE_RULES_MANAGER_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3015 | VIBRATOR_SERVICE, |
| 3016 | //@hide: STATUS_BAR_SERVICE, |
| 3017 | CONNECTIVITY_SERVICE, |
Chalard Jean | 8c141bd | 2018-12-04 20:20:56 +0900 | [diff] [blame] | 3018 | //@hide: IP_MEMORY_STORE_SERVICE, |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 3019 | IPSEC_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3020 | //@hide: UPDATE_LOCK_SERVICE, |
| 3021 | //@hide: NETWORKMANAGEMENT_SERVICE, |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3022 | NETWORK_STATS_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3023 | //@hide: NETWORK_POLICY_SERVICE, |
| 3024 | WIFI_SERVICE, |
Etan Cohen | 0413327 | 2016-10-26 11:22:06 -0700 | [diff] [blame] | 3025 | WIFI_AWARE_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3026 | WIFI_P2P_SERVICE, |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 3027 | WIFI_SCANNING_SERVICE, |
Robert Quattlebaum | 87a7104 | 2017-05-15 15:45:20 -0700 | [diff] [blame] | 3028 | //@hide: LOWPAN_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3029 | //@hide: WIFI_RTT_SERVICE, |
Lorenzo Colitti | bd8a374 | 2014-05-22 11:51:27 -0700 | [diff] [blame] | 3030 | //@hide: ETHERNET_SERVICE, |
Etan Cohen | 46efb48 | 2017-12-07 13:50:57 -0800 | [diff] [blame] | 3031 | WIFI_RTT_RANGING_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3032 | NSD_SERVICE, |
| 3033 | AUDIO_SERVICE, |
Jim Miller | ce7eb6d | 2015-04-03 19:29:13 -0700 | [diff] [blame] | 3034 | FINGERPRINT_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3035 | MEDIA_ROUTER_SERVICE, |
| 3036 | TELEPHONY_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3037 | TELEPHONY_SUBSCRIPTION_SERVICE, |
Jonathan Basseri | 9a1c9b6 | 2015-02-25 13:01:52 -0800 | [diff] [blame] | 3038 | CARRIER_CONFIG_SERVICE, |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 3039 | TELECOM_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3040 | CLIPBOARD_SERVICE, |
| 3041 | INPUT_METHOD_SERVICE, |
| 3042 | TEXT_SERVICES_MANAGER_SERVICE, |
Abodunrinwa Toki | 3de110b | 2017-05-04 16:29:04 +0100 | [diff] [blame] | 3043 | TEXT_CLASSIFICATION_SERVICE, |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 3044 | APPWIDGET_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3045 | //@hide: VOICE_INTERACTION_MANAGER_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3046 | //@hide: BACKUP_SERVICE, |
| 3047 | DROPBOX_SERVICE, |
Dianne Hackborn | 1958e5e | 2015-06-12 18:11:41 -0700 | [diff] [blame] | 3048 | //@hide: DEVICE_IDLE_CONTROLLER, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3049 | DEVICE_POLICY_SERVICE, |
| 3050 | UI_MODE_SERVICE, |
| 3051 | DOWNLOAD_SERVICE, |
| 3052 | NFC_SERVICE, |
| 3053 | BLUETOOTH_SERVICE, |
| 3054 | //@hide: SIP_SERVICE, |
| 3055 | USB_SERVICE, |
Amith Yamasani | 4f58263 | 2014-02-19 14:31:52 -0800 | [diff] [blame] | 3056 | LAUNCHER_APPS_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3057 | //@hide: SERIAL_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3058 | //@hide: HDMI_CONTROL_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3059 | INPUT_SERVICE, |
| 3060 | DISPLAY_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3061 | USER_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3062 | RESTRICTIONS_SERVICE, |
| 3063 | APP_OPS_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3064 | CAMERA_SERVICE, |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 3065 | PRINT_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3066 | CONSUMER_IR_SERVICE, |
| 3067 | //@hide: TRUST_SERVICE, |
| 3068 | TV_INPUT_SERVICE, |
| 3069 | //@hide: NETWORK_SCORE_SERVICE, |
| 3070 | USAGE_STATS_SERVICE, |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 3071 | MEDIA_SESSION_SERVICE, |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 3072 | BATTERY_SERVICE, |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 3073 | JOB_SCHEDULER_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3074 | //@hide: PERSISTENT_DATA_BLOCK_SERVICE, |
Andrew Scull | 3b8b46f | 2017-02-13 18:12:15 +0000 | [diff] [blame] | 3075 | //@hide: OEM_LOCK_SERVICE, |
Michael Wright | 446e019 | 2014-12-22 09:38:43 -0800 | [diff] [blame] | 3076 | MEDIA_PROJECTION_SERVICE, |
Mike Lockwood | 67f8e8b | 2014-12-01 13:54:59 -0800 | [diff] [blame] | 3077 | MIDI_SERVICE, |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 3078 | RADIO_SERVICE, |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 3079 | HARDWARE_PROPERTIES_SERVICE, |
Arunesh Mishra | a772e5f | 2016-01-25 10:33:11 -0800 | [diff] [blame] | 3080 | //@hide: SOUND_TRIGGER_SERVICE, |
Makoto Onuki | 6f7362d9 | 2016-03-04 13:39:41 -0800 | [diff] [blame] | 3081 | SHORTCUT_SERVICE, |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 3082 | //@hide: CONTEXTHUB_SERVICE, |
Joe Onorato | 1754d74 | 2016-11-21 17:51:35 -0800 | [diff] [blame] | 3083 | SYSTEM_HEALTH_SERVICE, |
Tor Norbye | 8246c07 | 2017-07-07 10:21:09 -0700 | [diff] [blame] | 3084 | //@hide: INCIDENT_SERVICE, |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 3085 | //@hide: STATS_COMPANION_SERVICE, |
Tony Mak | 9240c7f | 2017-12-29 11:02:02 +0000 | [diff] [blame] | 3086 | COMPANION_DEVICE_SERVICE, |
Tao Bao | 07342dc | 2017-01-24 15:08:21 -0800 | [diff] [blame] | 3087 | CROSS_PROFILE_APPS_SERVICE, |
| 3088 | //@hide: SYSTEM_UPDATE_SERVICE, |
Neil Fuller | b557907 | 2018-05-30 14:35:24 +0100 | [diff] [blame] | 3089 | //@hide: TIME_DETECTOR_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3090 | }) |
| 3091 | @Retention(RetentionPolicy.SOURCE) |
| 3092 | public @interface ServiceName {} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3093 | |
| 3094 | /** |
| 3095 | * Return the handle to a system-level service by name. The class of the |
| 3096 | * returned object varies by the requested name. Currently available names |
| 3097 | * are: |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3098 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3099 | * <dl> |
| 3100 | * <dt> {@link #WINDOW_SERVICE} ("window") |
| 3101 | * <dd> The top-level window manager in which you can place custom |
| 3102 | * windows. The returned object is a {@link android.view.WindowManager}. |
| 3103 | * <dt> {@link #LAYOUT_INFLATER_SERVICE} ("layout_inflater") |
| 3104 | * <dd> A {@link android.view.LayoutInflater} for inflating layout resources |
| 3105 | * in this context. |
| 3106 | * <dt> {@link #ACTIVITY_SERVICE} ("activity") |
| 3107 | * <dd> A {@link android.app.ActivityManager} for interacting with the |
| 3108 | * global activity state of the system. |
| 3109 | * <dt> {@link #POWER_SERVICE} ("power") |
| 3110 | * <dd> A {@link android.os.PowerManager} for controlling power |
| 3111 | * management. |
| 3112 | * <dt> {@link #ALARM_SERVICE} ("alarm") |
| 3113 | * <dd> A {@link android.app.AlarmManager} for receiving intents at the |
| 3114 | * time of your choosing. |
| 3115 | * <dt> {@link #NOTIFICATION_SERVICE} ("notification") |
| 3116 | * <dd> A {@link android.app.NotificationManager} for informing the user |
| 3117 | * of background events. |
| 3118 | * <dt> {@link #KEYGUARD_SERVICE} ("keyguard") |
| 3119 | * <dd> A {@link android.app.KeyguardManager} for controlling keyguard. |
| 3120 | * <dt> {@link #LOCATION_SERVICE} ("location") |
| 3121 | * <dd> A {@link android.location.LocationManager} for controlling location |
| 3122 | * (e.g., GPS) updates. |
| 3123 | * <dt> {@link #SEARCH_SERVICE} ("search") |
| 3124 | * <dd> A {@link android.app.SearchManager} for handling search. |
| 3125 | * <dt> {@link #VIBRATOR_SERVICE} ("vibrator") |
| 3126 | * <dd> A {@link android.os.Vibrator} for interacting with the vibrator |
| 3127 | * hardware. |
| 3128 | * <dt> {@link #CONNECTIVITY_SERVICE} ("connection") |
| 3129 | * <dd> A {@link android.net.ConnectivityManager ConnectivityManager} for |
| 3130 | * handling management of network connections. |
Nathan Harold | d999d22 | 2017-09-11 19:53:33 -0700 | [diff] [blame] | 3131 | * <dt> {@link #IPSEC_SERVICE} ("ipsec") |
| 3132 | * <dd> A {@link android.net.IpSecManager IpSecManager} for managing IPSec on |
| 3133 | * sockets and networks. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3134 | * <dt> {@link #WIFI_SERVICE} ("wifi") |
Paul Stewart | 0e164b1 | 2016-08-08 10:20:13 -0700 | [diff] [blame] | 3135 | * <dd> A {@link android.net.wifi.WifiManager WifiManager} for management of Wi-Fi |
| 3136 | * connectivity. On releases before NYC, it should only be obtained from an application |
| 3137 | * context, and not from any other derived context to avoid memory leaks within the calling |
| 3138 | * process. |
Etan Cohen | 6a4b323 | 2017-01-09 21:47:32 -0800 | [diff] [blame] | 3139 | * <dt> {@link #WIFI_AWARE_SERVICE} ("wifiaware") |
| 3140 | * <dd> A {@link android.net.wifi.aware.WifiAwareManager WifiAwareManager} for management of |
| 3141 | * Wi-Fi Aware discovery and connectivity. |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 3142 | * <dt> {@link #WIFI_P2P_SERVICE} ("wifip2p") |
| 3143 | * <dd> A {@link android.net.wifi.p2p.WifiP2pManager WifiP2pManager} for management of |
| 3144 | * Wi-Fi Direct connectivity. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3145 | * <dt> {@link #INPUT_METHOD_SERVICE} ("input_method") |
| 3146 | * <dd> An {@link android.view.inputmethod.InputMethodManager InputMethodManager} |
| 3147 | * for management of input methods. |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 3148 | * <dt> {@link #UI_MODE_SERVICE} ("uimode") |
| 3149 | * <dd> An {@link android.app.UiModeManager} for controlling UI modes. |
Steve Howard | 7083c42 | 2010-07-28 16:01:23 -0700 | [diff] [blame] | 3150 | * <dt> {@link #DOWNLOAD_SERVICE} ("download") |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 3151 | * <dd> A {@link android.app.DownloadManager} for requesting HTTP downloads |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 3152 | * <dt> {@link #BATTERY_SERVICE} ("batterymanager") |
Todd Poynor | 99f7e12 | 2014-04-15 16:03:42 -0700 | [diff] [blame] | 3153 | * <dd> A {@link android.os.BatteryManager} for managing battery state |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 3154 | * <dt> {@link #JOB_SCHEDULER_SERVICE} ("taskmanager") |
| 3155 | * <dd> A {@link android.app.job.JobScheduler} for managing scheduled tasks |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3156 | * <dt> {@link #NETWORK_STATS_SERVICE} ("netstats") |
| 3157 | * <dd> A {@link android.app.usage.NetworkStatsManager NetworkStatsManager} for querying network |
| 3158 | * usage statistics. |
Polina Bondarenko | 8333c73 | 2016-03-09 18:08:42 +0100 | [diff] [blame] | 3159 | * <dt> {@link #HARDWARE_PROPERTIES_SERVICE} ("hardware_properties") |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 3160 | * <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] | 3161 | * </dl> |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3162 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3163 | * <p>Note: System services obtained via this API may be closely associated with |
| 3164 | * the Context in which they are obtained from. In general, do not share the |
| 3165 | * service objects between various different contexts (Activities, Applications, |
| 3166 | * Services, Providers, etc.) |
| 3167 | * |
Svet Ganov | 8f90bcc | 2017-12-22 23:29:24 -0800 | [diff] [blame] | 3168 | * <p>Note: Instant apps, for which {@link PackageManager#isInstantApp()} returns true, |
| 3169 | * don't have access to the following system services: {@link #DEVICE_POLICY_SERVICE}, |
| 3170 | * {@link #FINGERPRINT_SERVICE}, {@link #SHORTCUT_SERVICE}, {@link #USB_SERVICE}, |
| 3171 | * {@link #WALLPAPER_SERVICE}, {@link #WIFI_P2P_SERVICE}, {@link #WIFI_SERVICE}, |
| 3172 | * {@link #WIFI_AWARE_SERVICE}. For these services this method will return <code>null</code>. |
| 3173 | * Generally, if you are running as an instant app you should always check whether the result |
| 3174 | * of this method is null. |
| 3175 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3176 | * @param name The name of the desired service. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3177 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3178 | * @return The service or null if the name does not exist. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3179 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3180 | * @see #WINDOW_SERVICE |
| 3181 | * @see android.view.WindowManager |
| 3182 | * @see #LAYOUT_INFLATER_SERVICE |
| 3183 | * @see android.view.LayoutInflater |
| 3184 | * @see #ACTIVITY_SERVICE |
| 3185 | * @see android.app.ActivityManager |
| 3186 | * @see #POWER_SERVICE |
| 3187 | * @see android.os.PowerManager |
| 3188 | * @see #ALARM_SERVICE |
| 3189 | * @see android.app.AlarmManager |
| 3190 | * @see #NOTIFICATION_SERVICE |
| 3191 | * @see android.app.NotificationManager |
| 3192 | * @see #KEYGUARD_SERVICE |
| 3193 | * @see android.app.KeyguardManager |
| 3194 | * @see #LOCATION_SERVICE |
| 3195 | * @see android.location.LocationManager |
| 3196 | * @see #SEARCH_SERVICE |
| 3197 | * @see android.app.SearchManager |
| 3198 | * @see #SENSOR_SERVICE |
| 3199 | * @see android.hardware.SensorManager |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 3200 | * @see #STORAGE_SERVICE |
San Mehat | b104340 | 2010-02-05 08:26:50 -0800 | [diff] [blame] | 3201 | * @see android.os.storage.StorageManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3202 | * @see #VIBRATOR_SERVICE |
| 3203 | * @see android.os.Vibrator |
| 3204 | * @see #CONNECTIVITY_SERVICE |
| 3205 | * @see android.net.ConnectivityManager |
| 3206 | * @see #WIFI_SERVICE |
| 3207 | * @see android.net.wifi.WifiManager |
| 3208 | * @see #AUDIO_SERVICE |
| 3209 | * @see android.media.AudioManager |
Dianne Hackborn | b58b8f8 | 2012-06-11 15:08:39 -0700 | [diff] [blame] | 3210 | * @see #MEDIA_ROUTER_SERVICE |
| 3211 | * @see android.media.MediaRouter |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3212 | * @see #TELEPHONY_SERVICE |
| 3213 | * @see android.telephony.TelephonyManager |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 3214 | * @see #TELEPHONY_SUBSCRIPTION_SERVICE |
| 3215 | * @see android.telephony.SubscriptionManager |
Jonathan Basseri | 9a1c9b6 | 2015-02-25 13:01:52 -0800 | [diff] [blame] | 3216 | * @see #CARRIER_CONFIG_SERVICE |
| 3217 | * @see android.telephony.CarrierConfigManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3218 | * @see #INPUT_METHOD_SERVICE |
| 3219 | * @see android.view.inputmethod.InputMethodManager |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 3220 | * @see #UI_MODE_SERVICE |
| 3221 | * @see android.app.UiModeManager |
Steve Howard | 7083c42 | 2010-07-28 16:01:23 -0700 | [diff] [blame] | 3222 | * @see #DOWNLOAD_SERVICE |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 3223 | * @see android.app.DownloadManager |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 3224 | * @see #BATTERY_SERVICE |
| 3225 | * @see android.os.BatteryManager |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 3226 | * @see #JOB_SCHEDULER_SERVICE |
| 3227 | * @see android.app.job.JobScheduler |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3228 | * @see #NETWORK_STATS_SERVICE |
| 3229 | * @see android.app.usage.NetworkStatsManager |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 3230 | * @see android.os.HardwarePropertiesManager |
| 3231 | * @see #HARDWARE_PROPERTIES_SERVICE |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3232 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 3233 | public abstract @Nullable Object getSystemService(@ServiceName @NonNull String name); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3234 | |
| 3235 | /** |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3236 | * Return the handle to a system-level service by class. |
| 3237 | * <p> |
| 3238 | * Currently available classes are: |
| 3239 | * {@link android.view.WindowManager}, {@link android.view.LayoutInflater}, |
| 3240 | * {@link android.app.ActivityManager}, {@link android.os.PowerManager}, |
| 3241 | * {@link android.app.AlarmManager}, {@link android.app.NotificationManager}, |
| 3242 | * {@link android.app.KeyguardManager}, {@link android.location.LocationManager}, |
| 3243 | * {@link android.app.SearchManager}, {@link android.os.Vibrator}, |
| 3244 | * {@link android.net.ConnectivityManager}, |
| 3245 | * {@link android.net.wifi.WifiManager}, |
| 3246 | * {@link android.media.AudioManager}, {@link android.media.MediaRouter}, |
| 3247 | * {@link android.telephony.TelephonyManager}, {@link android.telephony.SubscriptionManager}, |
| 3248 | * {@link android.view.inputmethod.InputMethodManager}, |
| 3249 | * {@link android.app.UiModeManager}, {@link android.app.DownloadManager}, |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3250 | * {@link android.os.BatteryManager}, {@link android.app.job.JobScheduler}, |
| 3251 | * {@link android.app.usage.NetworkStatsManager}. |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3252 | * </p><p> |
| 3253 | * Note: System services obtained via this API may be closely associated with |
| 3254 | * the Context in which they are obtained from. In general, do not share the |
| 3255 | * service objects between various different contexts (Activities, Applications, |
| 3256 | * Services, Providers, etc.) |
| 3257 | * </p> |
| 3258 | * |
Svet Ganov | 8f90bcc | 2017-12-22 23:29:24 -0800 | [diff] [blame] | 3259 | * <p>Note: Instant apps, for which {@link PackageManager#isInstantApp()} returns true, |
| 3260 | * don't have access to the following system services: {@link #DEVICE_POLICY_SERVICE}, |
| 3261 | * {@link #FINGERPRINT_SERVICE}, {@link #SHORTCUT_SERVICE}, {@link #USB_SERVICE}, |
| 3262 | * {@link #WALLPAPER_SERVICE}, {@link #WIFI_P2P_SERVICE}, {@link #WIFI_SERVICE}, |
| 3263 | * {@link #WIFI_AWARE_SERVICE}. For these services this method will return <code>null</code>. |
| 3264 | * Generally, if you are running as an instant app you should always check whether the result |
| 3265 | * of this method is null. |
| 3266 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3267 | * @param serviceClass The class of the desired service. |
| 3268 | * @return The service or null if the class is not a supported system service. |
| 3269 | */ |
| 3270 | @SuppressWarnings("unchecked") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 3271 | public final @Nullable <T> T getSystemService(@NonNull Class<T> serviceClass) { |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3272 | // Because subclasses may override getSystemService(String) we cannot |
| 3273 | // perform a lookup by class alone. We must first map the class to its |
| 3274 | // service name then invoke the string-based method. |
| 3275 | String serviceName = getSystemServiceName(serviceClass); |
| 3276 | return serviceName != null ? (T)getSystemService(serviceName) : null; |
| 3277 | } |
| 3278 | |
| 3279 | /** |
| 3280 | * Gets the name of the system-level service that is represented by the specified class. |
| 3281 | * |
| 3282 | * @param serviceClass The class of the desired service. |
| 3283 | * @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] | 3284 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 3285 | public abstract @Nullable String getSystemServiceName(@NonNull Class<?> serviceClass); |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3286 | |
| 3287 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3288 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3289 | * {@link android.os.PowerManager} for controlling power management, |
| 3290 | * including "wake locks," which let you keep the device on while |
| 3291 | * you're running long tasks. |
| 3292 | */ |
| 3293 | public static final String POWER_SERVICE = "power"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3294 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3295 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3296 | * Use with {@link #getSystemService(String)} to retrieve a |
Tao Bao | e8a403d | 2015-12-31 07:44:55 -0800 | [diff] [blame] | 3297 | * {@link android.os.RecoverySystem} for accessing the recovery system |
| 3298 | * service. |
| 3299 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3300 | * @see #getSystemService(String) |
Tao Bao | e8a403d | 2015-12-31 07:44:55 -0800 | [diff] [blame] | 3301 | * @hide |
| 3302 | */ |
| 3303 | public static final String RECOVERY_SERVICE = "recovery"; |
| 3304 | |
| 3305 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3306 | * Use with {@link #getSystemService(String)} to retrieve a |
Tao Bao | 07342dc | 2017-01-24 15:08:21 -0800 | [diff] [blame] | 3307 | * {@link android.os.SystemUpdateManager} for accessing the system update |
| 3308 | * manager service. |
| 3309 | * |
| 3310 | * @see #getSystemService(String) |
| 3311 | * @hide |
| 3312 | */ |
| 3313 | @SystemApi |
| 3314 | public static final String SYSTEM_UPDATE_SERVICE = "system_update"; |
| 3315 | |
| 3316 | /** |
| 3317 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3318 | * {@link android.view.WindowManager} for accessing the system's window |
| 3319 | * manager. |
| 3320 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3321 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3322 | * @see android.view.WindowManager |
| 3323 | */ |
| 3324 | public static final String WINDOW_SERVICE = "window"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3325 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3326 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3327 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3328 | * {@link android.view.LayoutInflater} for inflating layout resources in this |
| 3329 | * context. |
| 3330 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3331 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3332 | * @see android.view.LayoutInflater |
| 3333 | */ |
| 3334 | public static final String LAYOUT_INFLATER_SERVICE = "layout_inflater"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3335 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3336 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3337 | * Use with {@link #getSystemService(String)} to retrieve a |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 3338 | * {@link android.accounts.AccountManager} for receiving intents at a |
| 3339 | * time of your choosing. |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 3340 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3341 | * @see #getSystemService(String) |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 3342 | * @see android.accounts.AccountManager |
| 3343 | */ |
| 3344 | public static final String ACCOUNT_SERVICE = "account"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3345 | |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 3346 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3347 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3348 | * {@link android.app.ActivityManager} for interacting with the global |
| 3349 | * system state. |
| 3350 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3351 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3352 | * @see android.app.ActivityManager |
| 3353 | */ |
| 3354 | public static final String ACTIVITY_SERVICE = "activity"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3355 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3356 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3357 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3358 | * {@link android.app.AlarmManager} for receiving intents at a |
| 3359 | * time of your choosing. |
| 3360 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3361 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3362 | * @see android.app.AlarmManager |
| 3363 | */ |
| 3364 | public static final String ALARM_SERVICE = "alarm"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3365 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3366 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3367 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3368 | * {@link android.app.NotificationManager} for informing the user of |
| 3369 | * background events. |
| 3370 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3371 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3372 | * @see android.app.NotificationManager |
| 3373 | */ |
| 3374 | public static final String NOTIFICATION_SERVICE = "notification"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3375 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3376 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3377 | * Use with {@link #getSystemService(String)} to retrieve a |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 3378 | * {@link android.view.accessibility.AccessibilityManager} for giving the user |
| 3379 | * feedback for UI events through the registered event listeners. |
| 3380 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3381 | * @see #getSystemService(String) |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 3382 | * @see android.view.accessibility.AccessibilityManager |
| 3383 | */ |
| 3384 | public static final String ACCESSIBILITY_SERVICE = "accessibility"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3385 | |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 3386 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3387 | * Use with {@link #getSystemService(String)} to retrieve a |
Alan Viverette | 69ce69b | 2013-08-29 12:23:48 -0700 | [diff] [blame] | 3388 | * {@link android.view.accessibility.CaptioningManager} for obtaining |
| 3389 | * captioning properties and listening for changes in captioning |
| 3390 | * preferences. |
| 3391 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3392 | * @see #getSystemService(String) |
Alan Viverette | 69ce69b | 2013-08-29 12:23:48 -0700 | [diff] [blame] | 3393 | * @see android.view.accessibility.CaptioningManager |
| 3394 | */ |
| 3395 | public static final String CAPTIONING_SERVICE = "captioning"; |
| 3396 | |
| 3397 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3398 | * Use with {@link #getSystemService(String)} to retrieve a |
kopriva | 5495dbb | 2018-09-13 14:18:34 -0700 | [diff] [blame] | 3399 | * {@link android.app.KeyguardManager} for controlling keyguard. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3400 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3401 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3402 | * @see android.app.KeyguardManager |
| 3403 | */ |
| 3404 | public static final String KEYGUARD_SERVICE = "keyguard"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3405 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3406 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3407 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3408 | * android.location.LocationManager} for controlling location |
| 3409 | * updates. |
| 3410 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3411 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3412 | * @see android.location.LocationManager |
| 3413 | */ |
| 3414 | public static final String LOCATION_SERVICE = "location"; |
Bai Tao | a58a875 | 2010-07-13 15:32:16 +0800 | [diff] [blame] | 3415 | |
| 3416 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3417 | * Use with {@link #getSystemService(String)} to retrieve a |
Bai Tao | a58a875 | 2010-07-13 15:32:16 +0800 | [diff] [blame] | 3418 | * {@link android.location.CountryDetector} for detecting the country that |
| 3419 | * the user is in. |
| 3420 | * |
| 3421 | * @hide |
| 3422 | */ |
Mathew Inwood | 45d2c25 | 2018-09-14 12:35:36 +0100 | [diff] [blame] | 3423 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Bai Tao | a58a875 | 2010-07-13 15:32:16 +0800 | [diff] [blame] | 3424 | public static final String COUNTRY_DETECTOR = "country_detector"; |
| 3425 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3426 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3427 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3428 | * android.app.SearchManager} for handling searches. |
| 3429 | * |
Erik Wolsheimer | ac5cecd | 2017-12-05 13:11:50 -0800 | [diff] [blame] | 3430 | * <p> |
| 3431 | * {@link Configuration#UI_MODE_TYPE_WATCH} does not support |
| 3432 | * {@link android.app.SearchManager}. |
| 3433 | * |
| 3434 | * @see #getSystemService |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3435 | * @see android.app.SearchManager |
| 3436 | */ |
| 3437 | public static final String SEARCH_SERVICE = "search"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3438 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3439 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3440 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3441 | * android.hardware.SensorManager} for accessing sensors. |
| 3442 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3443 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3444 | * @see android.hardware.SensorManager |
| 3445 | */ |
| 3446 | public static final String SENSOR_SERVICE = "sensor"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3447 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3448 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3449 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Kenny Root | 02c8730 | 2010-07-01 08:10:18 -0700 | [diff] [blame] | 3450 | * android.os.storage.StorageManager} for accessing system storage |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 3451 | * functions. |
| 3452 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3453 | * @see #getSystemService(String) |
San Mehat | b104340 | 2010-02-05 08:26:50 -0800 | [diff] [blame] | 3454 | * @see android.os.storage.StorageManager |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 3455 | */ |
| 3456 | public static final String STORAGE_SERVICE = "storage"; |
| 3457 | |
| 3458 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3459 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Jeff Sharkey | e8cece9 | 2017-01-04 11:33:33 -0700 | [diff] [blame] | 3460 | * android.app.usage.StorageStatsManager} for accessing system storage |
| 3461 | * statistics. |
| 3462 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3463 | * @see #getSystemService(String) |
Jeff Sharkey | e8cece9 | 2017-01-04 11:33:33 -0700 | [diff] [blame] | 3464 | * @see android.app.usage.StorageStatsManager |
| 3465 | */ |
| 3466 | public static final String STORAGE_STATS_SERVICE = "storagestats"; |
| 3467 | |
| 3468 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3469 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3470 | * com.android.server.WallpaperService for accessing wallpapers. |
| 3471 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3472 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3473 | */ |
| 3474 | public static final String WALLPAPER_SERVICE = "wallpaper"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3475 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3476 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3477 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3478 | * android.os.Vibrator} for interacting with the vibration hardware. |
| 3479 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3480 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3481 | * @see android.os.Vibrator |
| 3482 | */ |
| 3483 | public static final String VIBRATOR_SERVICE = "vibrator"; |
Robert Greenwalt | 9e696c2 | 2010-04-01 14:45:18 -0700 | [diff] [blame] | 3484 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3485 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3486 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3487 | * android.app.StatusBarManager} for interacting with the status bar. |
| 3488 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3489 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3490 | * @see android.app.StatusBarManager |
| 3491 | * @hide |
| 3492 | */ |
Mathew Inwood | 1c77a11 | 2018-08-14 14:06:26 +0100 | [diff] [blame] | 3493 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3494 | public static final String STATUS_BAR_SERVICE = "statusbar"; |
| 3495 | |
| 3496 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3497 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3498 | * android.net.ConnectivityManager} for handling management of |
| 3499 | * network connections. |
| 3500 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3501 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3502 | * @see android.net.ConnectivityManager |
| 3503 | */ |
| 3504 | public static final String CONNECTIVITY_SERVICE = "connectivity"; |
| 3505 | |
| 3506 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3507 | * Use with {@link #getSystemService(String)} to retrieve a |
Remi NGUYEN VAN | 3193598 | 2019-01-28 11:40:08 +0900 | [diff] [blame] | 3508 | * {@link android.net.INetd} for communicating with the network stack |
| 3509 | * @hide |
| 3510 | * @see #getSystemService(String) |
| 3511 | * @hide |
| 3512 | */ |
| 3513 | @SystemApi |
| 3514 | public static final String NETD_SERVICE = "netd"; |
| 3515 | |
| 3516 | /** |
| 3517 | * Use with {@link #getSystemService(String)} to retrieve a |
Remi NGUYEN VAN | c094a54 | 2018-12-07 16:52:24 +0900 | [diff] [blame] | 3518 | * {@link NetworkStack} for communicating with the network stack |
| 3519 | * @hide |
| 3520 | * @see #getSystemService(String) |
| 3521 | * @see NetworkStack |
| 3522 | */ |
| 3523 | public static final String NETWORK_STACK_SERVICE = "network_stack"; |
| 3524 | |
| 3525 | /** |
| 3526 | * Use with {@link #getSystemService(String)} to retrieve a |
Chalard Jean | 8c141bd | 2018-12-04 20:20:56 +0900 | [diff] [blame] | 3527 | * {@link android.net.IpMemoryStore} to store and read information about |
| 3528 | * known networks. |
| 3529 | * @hide |
| 3530 | */ |
| 3531 | public static final String IP_MEMORY_STORE_SERVICE = "ipmemorystore"; |
| 3532 | |
| 3533 | /** |
| 3534 | * Use with {@link #getSystemService(String)} to retrieve a |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 3535 | * {@link android.net.IpSecManager} for encrypting Sockets or Networks with |
| 3536 | * IPSec. |
| 3537 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3538 | * @see #getSystemService(String) |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 3539 | */ |
| 3540 | public static final String IPSEC_SERVICE = "ipsec"; |
| 3541 | |
| 3542 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3543 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Christopher Tate | 8662cab5 | 2012-02-23 14:59:36 -0800 | [diff] [blame] | 3544 | * android.os.IUpdateLock} for managing runtime sequences that |
| 3545 | * must not be interrupted by headless OTA application or similar. |
| 3546 | * |
| 3547 | * @hide |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3548 | * @see #getSystemService(String) |
Christopher Tate | 8662cab5 | 2012-02-23 14:59:36 -0800 | [diff] [blame] | 3549 | * @see android.os.UpdateLock |
| 3550 | */ |
| 3551 | public static final String UPDATE_LOCK_SERVICE = "updatelock"; |
| 3552 | |
| 3553 | /** |
Dianne Hackborn | 35f72be | 2013-09-16 10:57:39 -0700 | [diff] [blame] | 3554 | * Constant for the internal network management service, not really a Context service. |
Dianne Hackborn | 0a6a80f | 2013-09-16 15:20:27 -0700 | [diff] [blame] | 3555 | * @hide |
San Mehat | d1df8ac | 2010-01-26 06:17:26 -0800 | [diff] [blame] | 3556 | */ |
| 3557 | public static final String NETWORKMANAGEMENT_SERVICE = "network_management"; |
| 3558 | |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3559 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3560 | * Use with {@link #getSystemService(String)} to retrieve a |
Jason Monk | 8f5f7ff | 2017-10-17 14:12:42 -0400 | [diff] [blame] | 3561 | * {@link com.android.server.slice.SliceManagerService} for managing slices. |
| 3562 | * @hide |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3563 | * @see #getSystemService(String) |
Jason Monk | 8f5f7ff | 2017-10-17 14:12:42 -0400 | [diff] [blame] | 3564 | */ |
| 3565 | public static final String SLICE_SERVICE = "slice"; |
| 3566 | |
| 3567 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3568 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3569 | * android.app.usage.NetworkStatsManager} for querying network usage stats. |
| 3570 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3571 | * @see #getSystemService(String) |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3572 | * @see android.app.usage.NetworkStatsManager |
| 3573 | */ |
Jeff Sharkey | 7527990 | 2011-05-24 18:39:45 -0700 | [diff] [blame] | 3574 | public static final String NETWORK_STATS_SERVICE = "netstats"; |
| 3575 | /** {@hide} */ |
Jeff Sharkey | eedcb95 | 2011-05-17 14:55:15 -0700 | [diff] [blame] | 3576 | public static final String NETWORK_POLICY_SERVICE = "netpolicy"; |
Ricky Wai | 1a6e667 | 2017-10-27 14:46:01 +0100 | [diff] [blame] | 3577 | /** {@hide} */ |
| 3578 | public static final String NETWORK_WATCHLIST_SERVICE = "network_watchlist"; |
Jeff Sharkey | eedcb95 | 2011-05-17 14:55:15 -0700 | [diff] [blame] | 3579 | |
San Mehat | d1df8ac | 2010-01-26 06:17:26 -0800 | [diff] [blame] | 3580 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3581 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3582 | * android.net.wifi.WifiManager} for handling management of |
| 3583 | * Wi-Fi access. |
| 3584 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3585 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3586 | * @see android.net.wifi.WifiManager |
| 3587 | */ |
| 3588 | public static final String WIFI_SERVICE = "wifi"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3589 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3590 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3591 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 3592 | * android.net.wifi.p2p.WifiP2pManager} for handling management of |
Irfan Sheriff | 651cdfc | 2011-09-07 00:31:20 -0700 | [diff] [blame] | 3593 | * Wi-Fi peer-to-peer connections. |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 3594 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3595 | * @see #getSystemService(String) |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 3596 | * @see android.net.wifi.p2p.WifiP2pManager |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 3597 | */ |
| 3598 | public static final String WIFI_P2P_SERVICE = "wifip2p"; |
| 3599 | |
| 3600 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3601 | * Use with {@link #getSystemService(String)} to retrieve a |
Etan Cohen | 0413327 | 2016-10-26 11:22:06 -0700 | [diff] [blame] | 3602 | * {@link android.net.wifi.aware.WifiAwareManager} for handling management of |
| 3603 | * Wi-Fi Aware. |
Etan Cohen | 20d329b | 2015-09-29 13:49:02 -0700 | [diff] [blame] | 3604 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3605 | * @see #getSystemService(String) |
Etan Cohen | 0413327 | 2016-10-26 11:22:06 -0700 | [diff] [blame] | 3606 | * @see android.net.wifi.aware.WifiAwareManager |
Etan Cohen | 20d329b | 2015-09-29 13:49:02 -0700 | [diff] [blame] | 3607 | */ |
Etan Cohen | 0413327 | 2016-10-26 11:22:06 -0700 | [diff] [blame] | 3608 | public static final String WIFI_AWARE_SERVICE = "wifiaware"; |
Etan Cohen | 20d329b | 2015-09-29 13:49:02 -0700 | [diff] [blame] | 3609 | |
| 3610 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3611 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 3612 | * android.net.wifi.WifiScanner} for scanning the wifi universe |
| 3613 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3614 | * @see #getSystemService(String) |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 3615 | * @see android.net.wifi.WifiScanner |
| 3616 | * @hide |
| 3617 | */ |
Wei Wang | 35d552f | 2014-07-08 21:37:01 -0700 | [diff] [blame] | 3618 | @SystemApi |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 3619 | public static final String WIFI_SCANNING_SERVICE = "wifiscanner"; |
| 3620 | |
| 3621 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3622 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Vinit Deshpande | 7686c06 | 2014-06-30 15:25:01 -0700 | [diff] [blame] | 3623 | * android.net.wifi.RttManager} for ranging devices with wifi |
| 3624 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3625 | * @see #getSystemService(String) |
Vinit Deshpande | 7686c06 | 2014-06-30 15:25:01 -0700 | [diff] [blame] | 3626 | * @see android.net.wifi.RttManager |
| 3627 | * @hide |
| 3628 | */ |
| 3629 | @SystemApi |
Etan Cohen | d0acccd | 2018-01-31 08:36:33 -0800 | [diff] [blame] | 3630 | @Deprecated |
Vinit Deshpande | 7686c06 | 2014-06-30 15:25:01 -0700 | [diff] [blame] | 3631 | public static final String WIFI_RTT_SERVICE = "rttmanager"; |
| 3632 | |
| 3633 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3634 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Etan Cohen | 17ba472 | 2017-08-21 10:52:17 -0700 | [diff] [blame] | 3635 | * android.net.wifi.rtt.WifiRttManager} for ranging devices with wifi |
| 3636 | * |
| 3637 | * Note: this is a replacement for WIFI_RTT_SERVICE above. It will |
| 3638 | * be renamed once final implementation in place. |
| 3639 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3640 | * @see #getSystemService(String) |
Etan Cohen | 17ba472 | 2017-08-21 10:52:17 -0700 | [diff] [blame] | 3641 | * @see android.net.wifi.rtt.WifiRttManager |
Etan Cohen | 17ba472 | 2017-08-21 10:52:17 -0700 | [diff] [blame] | 3642 | */ |
Etan Cohen | 091d777 | 2018-01-04 17:47:37 -0800 | [diff] [blame] | 3643 | public static final String WIFI_RTT_RANGING_SERVICE = "wifirtt"; |
Etan Cohen | 17ba472 | 2017-08-21 10:52:17 -0700 | [diff] [blame] | 3644 | |
| 3645 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3646 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Robert Quattlebaum | 87a7104 | 2017-05-15 15:45:20 -0700 | [diff] [blame] | 3647 | * android.net.lowpan.LowpanManager} for handling management of |
| 3648 | * LoWPAN access. |
| 3649 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3650 | * @see #getSystemService(String) |
Robert Quattlebaum | 87a7104 | 2017-05-15 15:45:20 -0700 | [diff] [blame] | 3651 | * @see android.net.lowpan.LowpanManager |
| 3652 | * |
| 3653 | * @hide |
| 3654 | */ |
| 3655 | public static final String LOWPAN_SERVICE = "lowpan"; |
| 3656 | |
| 3657 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3658 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Dianne Hackborn | fee756f | 2014-07-16 17:31:10 -0700 | [diff] [blame] | 3659 | * android.net.EthernetManager} for handling management of |
Lorenzo Colitti | f9ff2c9 | 2014-05-21 16:32:11 -0700 | [diff] [blame] | 3660 | * Ethernet access. |
| 3661 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3662 | * @see #getSystemService(String) |
Dianne Hackborn | fee756f | 2014-07-16 17:31:10 -0700 | [diff] [blame] | 3663 | * @see android.net.EthernetManager |
Lorenzo Colitti | f9ff2c9 | 2014-05-21 16:32:11 -0700 | [diff] [blame] | 3664 | * |
| 3665 | * @hide |
| 3666 | */ |
Mathew Inwood | 1c77a11 | 2018-08-14 14:06:26 +0100 | [diff] [blame] | 3667 | @UnsupportedAppUsage |
Lorenzo Colitti | f9ff2c9 | 2014-05-21 16:32:11 -0700 | [diff] [blame] | 3668 | public static final String ETHERNET_SERVICE = "ethernet"; |
| 3669 | |
| 3670 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3671 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Irfan Sheriff | 60309fc | 2012-04-24 14:52:37 -0700 | [diff] [blame] | 3672 | * android.net.nsd.NsdManager} for handling management of network service |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 3673 | * discovery |
| 3674 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3675 | * @see #getSystemService(String) |
Irfan Sheriff | 60309fc | 2012-04-24 14:52:37 -0700 | [diff] [blame] | 3676 | * @see android.net.nsd.NsdManager |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 3677 | */ |
| 3678 | public static final String NSD_SERVICE = "servicediscovery"; |
| 3679 | |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 3680 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3681 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3682 | * {@link android.media.AudioManager} for handling management of volume, |
| 3683 | * ringer modes and audio routing. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3684 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3685 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3686 | * @see android.media.AudioManager |
| 3687 | */ |
| 3688 | public static final String AUDIO_SERVICE = "audio"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3689 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3690 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3691 | * Use with {@link #getSystemService(String)} to retrieve a |
Jim Miller | ce7eb6d | 2015-04-03 19:29:13 -0700 | [diff] [blame] | 3692 | * {@link android.hardware.fingerprint.FingerprintManager} for handling management |
Jim Miller | 08fa40c | 2014-04-29 18:18:47 -0700 | [diff] [blame] | 3693 | * of fingerprints. |
| 3694 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3695 | * @see #getSystemService(String) |
Jim Miller | ce7eb6d | 2015-04-03 19:29:13 -0700 | [diff] [blame] | 3696 | * @see android.hardware.fingerprint.FingerprintManager |
Jim Miller | 08fa40c | 2014-04-29 18:18:47 -0700 | [diff] [blame] | 3697 | */ |
| 3698 | public static final String FINGERPRINT_SERVICE = "fingerprint"; |
| 3699 | |
| 3700 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3701 | * Use with {@link #getSystemService(String)} to retrieve a |
Dianne Hackborn | b58b8f8 | 2012-06-11 15:08:39 -0700 | [diff] [blame] | 3702 | * {@link android.media.MediaRouter} for controlling and managing |
| 3703 | * routing of media. |
| 3704 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3705 | * @see #getSystemService(String) |
Dianne Hackborn | b58b8f8 | 2012-06-11 15:08:39 -0700 | [diff] [blame] | 3706 | * @see android.media.MediaRouter |
| 3707 | */ |
| 3708 | public static final String MEDIA_ROUTER_SERVICE = "media_router"; |
| 3709 | |
| 3710 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3711 | * Use with {@link #getSystemService(String)} to retrieve a |
RoboErik | 42ea7ee | 2014-05-16 16:27:35 -0700 | [diff] [blame] | 3712 | * {@link android.media.session.MediaSessionManager} for managing media Sessions. |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 3713 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3714 | * @see #getSystemService(String) |
RoboErik | 42ea7ee | 2014-05-16 16:27:35 -0700 | [diff] [blame] | 3715 | * @see android.media.session.MediaSessionManager |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 3716 | */ |
| 3717 | public static final String MEDIA_SESSION_SERVICE = "media_session"; |
| 3718 | |
| 3719 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3720 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3721 | * {@link android.telephony.TelephonyManager} for handling management the |
| 3722 | * telephony features of the device. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3723 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3724 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3725 | * @see android.telephony.TelephonyManager |
| 3726 | */ |
| 3727 | public static final String TELEPHONY_SERVICE = "phone"; |
| 3728 | |
| 3729 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3730 | * Use with {@link #getSystemService(String)} to retrieve a |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 3731 | * {@link android.telephony.SubscriptionManager} for handling management the |
| 3732 | * telephony subscriptions of the device. |
| 3733 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3734 | * @see #getSystemService(String) |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 3735 | * @see android.telephony.SubscriptionManager |
| 3736 | */ |
| 3737 | public static final String TELEPHONY_SUBSCRIPTION_SERVICE = "telephony_subscription_service"; |
| 3738 | |
| 3739 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3740 | * Use with {@link #getSystemService(String)} to retrieve a |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 3741 | * {@link android.telecom.TelecomManager} to manage telecom-related features |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 3742 | * of the device. |
| 3743 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3744 | * @see #getSystemService(String) |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 3745 | * @see android.telecom.TelecomManager |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 3746 | */ |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 3747 | public static final String TELECOM_SERVICE = "telecom"; |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 3748 | |
| 3749 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3750 | * Use with {@link #getSystemService(String)} to retrieve a |
Jonathan Basseri | 9a1c9b6 | 2015-02-25 13:01:52 -0800 | [diff] [blame] | 3751 | * {@link android.telephony.CarrierConfigManager} for reading carrier configuration values. |
| 3752 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3753 | * @see #getSystemService(String) |
Jonathan Basseri | 9a1c9b6 | 2015-02-25 13:01:52 -0800 | [diff] [blame] | 3754 | * @see android.telephony.CarrierConfigManager |
| 3755 | */ |
| 3756 | public static final String CARRIER_CONFIG_SERVICE = "carrier_config"; |
| 3757 | |
| 3758 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3759 | * Use with {@link #getSystemService(String)} to retrieve a |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 3760 | * {@link android.telephony.euicc.EuiccManager} to manage the device eUICC (embedded SIM). |
| 3761 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3762 | * @see #getSystemService(String) |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 3763 | * @see android.telephony.euicc.EuiccManager |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 3764 | */ |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 3765 | public static final String EUICC_SERVICE = "euicc"; |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 3766 | |
| 3767 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3768 | * Use with {@link #getSystemService(String)} to retrieve a |
Holly Jiuyu Sun | 5c11024 | 2017-12-21 18:44:59 -0800 | [diff] [blame] | 3769 | * {@link android.telephony.euicc.EuiccCardManager} to access the device eUICC (embedded SIM). |
| 3770 | * |
| 3771 | * @see #getSystemService(String) |
| 3772 | * @see android.telephony.euicc.EuiccCardManager |
Holly Jiuyu Sun | 5c11024 | 2017-12-21 18:44:59 -0800 | [diff] [blame] | 3773 | * @hide |
| 3774 | */ |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 3775 | @SystemApi |
| 3776 | public static final String EUICC_CARD_SERVICE = "euicc_card"; |
Holly Jiuyu Sun | 5c11024 | 2017-12-21 18:44:59 -0800 | [diff] [blame] | 3777 | |
| 3778 | /** |
| 3779 | * Use with {@link #getSystemService(String)} to retrieve a |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3780 | * {@link android.content.ClipboardManager} for accessing and modifying |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3781 | * the contents of the global clipboard. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3782 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3783 | * @see #getSystemService(String) |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3784 | * @see android.content.ClipboardManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3785 | */ |
| 3786 | public static final String CLIPBOARD_SERVICE = "clipboard"; |
| 3787 | |
| 3788 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3789 | * Use with {@link #getSystemService(String)} to retrieve a |
Abodunrinwa Toki | f001fef | 2017-01-04 23:51:42 +0000 | [diff] [blame] | 3790 | * {@link TextClassificationManager} for text classification services. |
Abodunrinwa Toki | 8158af5 | 2016-11-23 20:41:09 +0000 | [diff] [blame] | 3791 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3792 | * @see #getSystemService(String) |
Abodunrinwa Toki | f001fef | 2017-01-04 23:51:42 +0000 | [diff] [blame] | 3793 | * @see TextClassificationManager |
Abodunrinwa Toki | 8158af5 | 2016-11-23 20:41:09 +0000 | [diff] [blame] | 3794 | */ |
| 3795 | public static final String TEXT_CLASSIFICATION_SERVICE = "textclassification"; |
| 3796 | |
| 3797 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3798 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3799 | * {@link android.view.inputmethod.InputMethodManager} for accessing input |
| 3800 | * methods. |
| 3801 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3802 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3803 | */ |
| 3804 | public static final String INPUT_METHOD_SERVICE = "input_method"; |
| 3805 | |
| 3806 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3807 | * Use with {@link #getSystemService(String)} to retrieve a |
satok | 988323c | 2011-06-22 16:38:13 +0900 | [diff] [blame] | 3808 | * {@link android.view.textservice.TextServicesManager} for accessing |
| 3809 | * text services. |
| 3810 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3811 | * @see #getSystemService(String) |
satok | 988323c | 2011-06-22 16:38:13 +0900 | [diff] [blame] | 3812 | */ |
| 3813 | public static final String TEXT_SERVICES_MANAGER_SERVICE = "textservices"; |
| 3814 | |
| 3815 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3816 | * Use with {@link #getSystemService(String)} to retrieve a |
Dan Egnor | e38d58b | 2009-12-30 19:29:03 -0800 | [diff] [blame] | 3817 | * {@link android.appwidget.AppWidgetManager} for accessing AppWidgets. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3818 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3819 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3820 | */ |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 3821 | public static final String APPWIDGET_SERVICE = "appwidget"; |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 3822 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3823 | /** |
Dianne Hackborn | 91097de | 2014-04-04 18:02:06 -0700 | [diff] [blame] | 3824 | * Official published name of the (internal) voice interaction manager service. |
| 3825 | * |
| 3826 | * @hide |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3827 | * @see #getSystemService(String) |
Dianne Hackborn | 91097de | 2014-04-04 18:02:06 -0700 | [diff] [blame] | 3828 | */ |
| 3829 | public static final String VOICE_INTERACTION_MANAGER_SERVICE = "voiceinteraction"; |
| 3830 | |
| 3831 | /** |
Felipe Leme | 640f30a | 2017-03-06 15:44:06 -0800 | [diff] [blame] | 3832 | * Official published name of the (internal) autofill service. |
Felipe Leme | 5381aa4 | 2016-10-13 09:02:32 -0700 | [diff] [blame] | 3833 | * |
| 3834 | * @hide |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3835 | * @see #getSystemService(String) |
Felipe Leme | 5381aa4 | 2016-10-13 09:02:32 -0700 | [diff] [blame] | 3836 | */ |
Felipe Leme | 640f30a | 2017-03-06 15:44:06 -0800 | [diff] [blame] | 3837 | public static final String AUTOFILL_MANAGER_SERVICE = "autofill"; |
Felipe Leme | 5381aa4 | 2016-10-13 09:02:32 -0700 | [diff] [blame] | 3838 | |
| 3839 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3840 | * Use with {@link #getSystemService(String)} to access the |
Arunesh Mishra | a772e5f | 2016-01-25 10:33:11 -0800 | [diff] [blame] | 3841 | * {@link com.android.server.voiceinteraction.SoundTriggerService}. |
| 3842 | * |
| 3843 | * @hide |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3844 | * @see #getSystemService(String) |
Arunesh Mishra | a772e5f | 2016-01-25 10:33:11 -0800 | [diff] [blame] | 3845 | */ |
| 3846 | public static final String SOUND_TRIGGER_SERVICE = "soundtrigger"; |
| 3847 | |
| 3848 | |
| 3849 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3850 | * Use with {@link #getSystemService(String)} to retrieve an |
Christopher Tate | 4528186 | 2010-03-05 15:46:30 -0800 | [diff] [blame] | 3851 | * {@link android.app.backup.IBackupManager IBackupManager} for communicating |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 3852 | * with the backup mechanism. |
Dianne Hackborn | 7f20543 | 2009-07-28 00:13:47 -0700 | [diff] [blame] | 3853 | * @hide |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3854 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3855 | * @see #getSystemService(String) |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 3856 | */ |
Christopher Tate | d5cf722 | 2014-07-29 16:53:09 -0700 | [diff] [blame] | 3857 | @SystemApi |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 3858 | public static final String BACKUP_SERVICE = "backup"; |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 3859 | |
| 3860 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3861 | * Use with {@link #getSystemService(String)} to retrieve a |
Dan Egnor | 1337b01 | 2010-01-04 11:01:44 -0800 | [diff] [blame] | 3862 | * {@link android.os.DropBoxManager} instance for recording |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 3863 | * diagnostic logs. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3864 | * @see #getSystemService(String) |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 3865 | */ |
| 3866 | public static final String DROPBOX_SERVICE = "dropbox"; |
| 3867 | |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 3868 | /** |
Philip P. Moltmann | f80809f | 2018-04-04 11:20:44 -0700 | [diff] [blame] | 3869 | * System service name for the DeviceIdleManager. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3870 | * @see #getSystemService(String) |
Dianne Hackborn | 1958e5e | 2015-06-12 18:11:41 -0700 | [diff] [blame] | 3871 | * @hide |
| 3872 | */ |
| 3873 | public static final String DEVICE_IDLE_CONTROLLER = "deviceidle"; |
| 3874 | |
| 3875 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3876 | * Use with {@link #getSystemService(String)} to retrieve a |
Dianne Hackborn | 87bba1e | 2010-02-26 17:25:54 -0800 | [diff] [blame] | 3877 | * {@link android.app.admin.DevicePolicyManager} for working with global |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 3878 | * device policy management. |
| 3879 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3880 | * @see #getSystemService(String) |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 3881 | */ |
| 3882 | public static final String DEVICE_POLICY_SERVICE = "device_policy"; |
| 3883 | |
| 3884 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3885 | * Use with {@link #getSystemService(String)} to retrieve a |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 3886 | * {@link android.app.UiModeManager} for controlling UI modes. |
| 3887 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3888 | * @see #getSystemService(String) |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 3889 | */ |
| 3890 | public static final String UI_MODE_SERVICE = "uimode"; |
| 3891 | |
| 3892 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3893 | * Use with {@link #getSystemService(String)} to retrieve a |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 3894 | * {@link android.app.DownloadManager} for requesting HTTP downloads. |
Steve Howard | a270936 | 2010-07-02 17:12:48 -0700 | [diff] [blame] | 3895 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3896 | * @see #getSystemService(String) |
Steve Howard | a270936 | 2010-07-02 17:12:48 -0700 | [diff] [blame] | 3897 | */ |
| 3898 | public static final String DOWNLOAD_SERVICE = "download"; |
| 3899 | |
| 3900 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3901 | * Use with {@link #getSystemService(String)} to retrieve a |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 3902 | * {@link android.os.BatteryManager} for managing battery state. |
| 3903 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3904 | * @see #getSystemService(String) |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 3905 | */ |
| 3906 | public static final String BATTERY_SERVICE = "batterymanager"; |
| 3907 | |
| 3908 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3909 | * Use with {@link #getSystemService(String)} to retrieve a |
Nick Pelly | 50b4d8f | 2010-12-07 22:40:28 -0800 | [diff] [blame] | 3910 | * {@link android.nfc.NfcManager} for using NFC. |
| 3911 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3912 | * @see #getSystemService(String) |
Nick Pelly | 50b4d8f | 2010-12-07 22:40:28 -0800 | [diff] [blame] | 3913 | */ |
| 3914 | public static final String NFC_SERVICE = "nfc"; |
| 3915 | |
| 3916 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3917 | * Use with {@link #getSystemService(String)} to retrieve a |
Florian Salbrechter | 084da9b | 2015-03-25 11:00:55 +0000 | [diff] [blame] | 3918 | * {@link android.bluetooth.BluetoothManager} for using Bluetooth. |
Jaikumar Ganesh | 1abb1cb | 2012-01-25 16:14:50 -0800 | [diff] [blame] | 3919 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3920 | * @see #getSystemService(String) |
Jaikumar Ganesh | 1abb1cb | 2012-01-25 16:14:50 -0800 | [diff] [blame] | 3921 | */ |
| 3922 | public static final String BLUETOOTH_SERVICE = "bluetooth"; |
| 3923 | |
| 3924 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3925 | * Use with {@link #getSystemService(String)} to retrieve a |
Chung-yih Wang | 2d94231 | 2010-08-05 12:17:37 +0800 | [diff] [blame] | 3926 | * {@link android.net.sip.SipManager} for accessing the SIP related service. |
| 3927 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3928 | * @see #getSystemService(String) |
Chung-yih Wang | 2d94231 | 2010-08-05 12:17:37 +0800 | [diff] [blame] | 3929 | */ |
| 3930 | /** @hide */ |
| 3931 | public static final String SIP_SERVICE = "sip"; |
| 3932 | |
| 3933 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3934 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Mike Lockwood | c4308f0 | 2011-03-01 08:04:54 -0800 | [diff] [blame] | 3935 | * 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] | 3936 | * and for controlling this device's behavior as a USB device. |
| 3937 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3938 | * @see #getSystemService(String) |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3939 | * @see android.hardware.usb.UsbManager |
Mike Lockwood | e7d511e | 2010-12-30 13:39:37 -0500 | [diff] [blame] | 3940 | */ |
| 3941 | public static final String USB_SERVICE = "usb"; |
| 3942 | |
| 3943 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3944 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Mike Lockwood | b01e8bf | 2011-08-29 20:11:07 -0400 | [diff] [blame] | 3945 | * android.hardware.SerialManager} for access to serial ports. |
| 3946 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3947 | * @see #getSystemService(String) |
Dianne Hackborn | 35f72be | 2013-09-16 10:57:39 -0700 | [diff] [blame] | 3948 | * @see android.hardware.SerialManager |
Mike Lockwood | b01e8bf | 2011-08-29 20:11:07 -0400 | [diff] [blame] | 3949 | * |
| 3950 | * @hide |
| 3951 | */ |
| 3952 | public static final String SERIAL_SERVICE = "serial"; |
| 3953 | |
| 3954 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3955 | * Use with {@link #getSystemService(String)} to retrieve a |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 3956 | * {@link android.hardware.hdmi.HdmiControlManager} for controlling and managing |
| 3957 | * HDMI-CEC protocol. |
| 3958 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3959 | * @see #getSystemService(String) |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 3960 | * @see android.hardware.hdmi.HdmiControlManager |
Jinsuk Kim | 66d1eb2 | 2014-06-06 16:12:18 +0900 | [diff] [blame] | 3961 | * @hide |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 3962 | */ |
Jinsuk Kim | 66d1eb2 | 2014-06-06 16:12:18 +0900 | [diff] [blame] | 3963 | @SystemApi |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 3964 | public static final String HDMI_CONTROL_SERVICE = "hdmi_control"; |
Jinsuk Kim | fbcd503 | 2014-03-21 16:25:13 +0900 | [diff] [blame] | 3965 | |
| 3966 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3967 | * Use with {@link #getSystemService(String)} to retrieve a |
Jeff Brown | 9df6e7a | 2012-04-05 11:49:26 -0700 | [diff] [blame] | 3968 | * {@link android.hardware.input.InputManager} for interacting with input devices. |
| 3969 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3970 | * @see #getSystemService(String) |
Jeff Brown | 9df6e7a | 2012-04-05 11:49:26 -0700 | [diff] [blame] | 3971 | * @see android.hardware.input.InputManager |
| 3972 | */ |
| 3973 | public static final String INPUT_SERVICE = "input"; |
| 3974 | |
| 3975 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3976 | * Use with {@link #getSystemService(String)} to retrieve a |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 3977 | * {@link android.hardware.display.DisplayManager} for interacting with display devices. |
| 3978 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3979 | * @see #getSystemService(String) |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 3980 | * @see android.hardware.display.DisplayManager |
| 3981 | */ |
| 3982 | public static final String DISPLAY_SERVICE = "display"; |
| 3983 | |
| 3984 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3985 | * Use with {@link #getSystemService(String)} to retrieve a |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 3986 | * {@link android.os.UserManager} for managing users on devices that support multiple users. |
| 3987 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3988 | * @see #getSystemService(String) |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 3989 | * @see android.os.UserManager |
| 3990 | */ |
| 3991 | public static final String USER_SERVICE = "user"; |
| 3992 | |
| 3993 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3994 | * Use with {@link #getSystemService(String)} to retrieve a |
Amith Yamasani | 4f58263 | 2014-02-19 14:31:52 -0800 | [diff] [blame] | 3995 | * {@link android.content.pm.LauncherApps} for querying and monitoring launchable apps across |
| 3996 | * profiles of a user. |
| 3997 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3998 | * @see #getSystemService(String) |
Amith Yamasani | 4f58263 | 2014-02-19 14:31:52 -0800 | [diff] [blame] | 3999 | * @see android.content.pm.LauncherApps |
| 4000 | */ |
| 4001 | public static final String LAUNCHER_APPS_SERVICE = "launcherapps"; |
| 4002 | |
| 4003 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4004 | * Use with {@link #getSystemService(String)} to retrieve a |
Amith Yamasani | f20d640 | 2014-05-24 15:34:37 -0700 | [diff] [blame] | 4005 | * {@link android.content.RestrictionsManager} for retrieving application restrictions |
| 4006 | * and requesting permissions for restricted operations. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4007 | * @see #getSystemService(String) |
Amith Yamasani | f20d640 | 2014-05-24 15:34:37 -0700 | [diff] [blame] | 4008 | * @see android.content.RestrictionsManager |
| 4009 | */ |
| 4010 | public static final String RESTRICTIONS_SERVICE = "restrictions"; |
| 4011 | |
| 4012 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4013 | * Use with {@link #getSystemService(String)} to retrieve a |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 4014 | * {@link android.app.AppOpsManager} for tracking application operations |
| 4015 | * on the device. |
| 4016 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4017 | * @see #getSystemService(String) |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 4018 | * @see android.app.AppOpsManager |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 4019 | */ |
| 4020 | public static final String APP_OPS_SERVICE = "appops"; |
| 4021 | |
| 4022 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4023 | * Use with {@link #getSystemService(String)} to retrieve a |
Eino-Ville Talvala | 2f1a2e4 | 2013-07-25 17:12:05 -0700 | [diff] [blame] | 4024 | * {@link android.hardware.camera2.CameraManager} for interacting with |
Eino-Ville Talvala | b267554 | 2012-12-12 13:29:45 -0800 | [diff] [blame] | 4025 | * camera devices. |
| 4026 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4027 | * @see #getSystemService(String) |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 4028 | * @see android.hardware.camera2.CameraManager |
Eino-Ville Talvala | b267554 | 2012-12-12 13:29:45 -0800 | [diff] [blame] | 4029 | */ |
| 4030 | public static final String CAMERA_SERVICE = "camera"; |
| 4031 | |
| 4032 | /** |
Svetoslav Ganov | 4b9a4d1 | 2013-06-11 15:20:06 -0700 | [diff] [blame] | 4033 | * {@link android.print.PrintManager} for printing and managing |
Jeff Brown | 511cd35 | 2013-08-23 17:43:37 -0700 | [diff] [blame] | 4034 | * printers and print tasks. |
Svetoslav Ganov | 4b9a4d1 | 2013-06-11 15:20:06 -0700 | [diff] [blame] | 4035 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4036 | * @see #getSystemService(String) |
Svetoslav Ganov | 4b9a4d1 | 2013-06-11 15:20:06 -0700 | [diff] [blame] | 4037 | * @see android.print.PrintManager |
| 4038 | */ |
| 4039 | public static final String PRINT_SERVICE = "print"; |
| 4040 | |
| 4041 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4042 | * Use with {@link #getSystemService(String)} to retrieve a |
Eugene Susla | 6ed45d8 | 2017-01-22 13:52:51 -0800 | [diff] [blame] | 4043 | * {@link android.companion.CompanionDeviceManager} for managing companion devices |
| 4044 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4045 | * @see #getSystemService(String) |
Eugene Susla | 6ed45d8 | 2017-01-22 13:52:51 -0800 | [diff] [blame] | 4046 | * @see android.companion.CompanionDeviceManager |
| 4047 | */ |
Eugene Susla | d7355cc | 2017-04-20 11:14:45 -0700 | [diff] [blame] | 4048 | public static final String COMPANION_DEVICE_SERVICE = "companiondevice"; |
Eugene Susla | 6ed45d8 | 2017-01-22 13:52:51 -0800 | [diff] [blame] | 4049 | |
| 4050 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4051 | * Use with {@link #getSystemService(String)} to retrieve a |
Erik Gilling | 51e95df | 2013-06-26 11:06:51 -0700 | [diff] [blame] | 4052 | * {@link android.hardware.ConsumerIrManager} for transmitting infrared |
| 4053 | * signals from the device. |
| 4054 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4055 | * @see #getSystemService(String) |
Erik Gilling | 51e95df | 2013-06-26 11:06:51 -0700 | [diff] [blame] | 4056 | * @see android.hardware.ConsumerIrManager |
| 4057 | */ |
| 4058 | public static final String CONSUMER_IR_SERVICE = "consumer_ir"; |
| 4059 | |
| 4060 | /** |
Adrian Roos | 82142c2 | 2014-03-27 14:56:59 +0100 | [diff] [blame] | 4061 | * {@link android.app.trust.TrustManager} for managing trust agents. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4062 | * @see #getSystemService(String) |
Adrian Roos | 82142c2 | 2014-03-27 14:56:59 +0100 | [diff] [blame] | 4063 | * @see android.app.trust.TrustManager |
| 4064 | * @hide |
| 4065 | */ |
| 4066 | public static final String TRUST_SERVICE = "trust"; |
| 4067 | |
| 4068 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4069 | * Use with {@link #getSystemService(String)} to retrieve a |
Jae Seo | d5cc4a2 | 2014-05-30 16:57:43 -0700 | [diff] [blame] | 4070 | * {@link android.media.tv.TvInputManager} for interacting with TV inputs |
| 4071 | * on the device. |
Jae Seo | 3957091 | 2014-02-20 18:23:25 -0800 | [diff] [blame] | 4072 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4073 | * @see #getSystemService(String) |
Jae Seo | d5cc4a2 | 2014-05-30 16:57:43 -0700 | [diff] [blame] | 4074 | * @see android.media.tv.TvInputManager |
Jae Seo | 3957091 | 2014-02-20 18:23:25 -0800 | [diff] [blame] | 4075 | */ |
| 4076 | public static final String TV_INPUT_SERVICE = "tv_input"; |
| 4077 | |
| 4078 | /** |
Jeff Davidson | b51e0a6 | 2014-04-09 12:38:15 -0700 | [diff] [blame] | 4079 | * {@link android.net.NetworkScoreManager} for managing network scoring. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4080 | * @see #getSystemService(String) |
Jeff Davidson | b51e0a6 | 2014-04-09 12:38:15 -0700 | [diff] [blame] | 4081 | * @see android.net.NetworkScoreManager |
| 4082 | * @hide |
| 4083 | */ |
Jeff Davidson | 5ad2079 | 2014-07-21 13:55:42 -0700 | [diff] [blame] | 4084 | @SystemApi |
Jeff Davidson | b51e0a6 | 2014-04-09 12:38:15 -0700 | [diff] [blame] | 4085 | public static final String NETWORK_SCORE_SERVICE = "network_score"; |
| 4086 | |
| 4087 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4088 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Adam Lesinski | aa60767 | 2014-11-24 11:27:50 -0800 | [diff] [blame] | 4089 | * android.app.usage.UsageStatsManager} for querying device usage stats. |
Dianne Hackborn | e22b3b1 | 2014-05-07 18:06:44 -0700 | [diff] [blame] | 4090 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4091 | * @see #getSystemService(String) |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 4092 | * @see android.app.usage.UsageStatsManager |
Dianne Hackborn | e22b3b1 | 2014-05-07 18:06:44 -0700 | [diff] [blame] | 4093 | */ |
| 4094 | public static final String USAGE_STATS_SERVICE = "usagestats"; |
| 4095 | |
| 4096 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4097 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 4098 | * android.app.job.JobScheduler} instance for managing occasional |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 4099 | * background tasks. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4100 | * @see #getSystemService(String) |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 4101 | * @see android.app.job.JobScheduler |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 4102 | */ |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 4103 | public static final String JOB_SCHEDULER_SERVICE = "jobscheduler"; |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 4104 | |
| 4105 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4106 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Andres Morales | 33df937 | 2014-09-26 17:08:59 -0700 | [diff] [blame] | 4107 | * android.service.persistentdata.PersistentDataBlockManager} instance |
| 4108 | * for interacting with a storage device that lives across factory resets. |
| 4109 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4110 | * @see #getSystemService(String) |
Andres Morales | 68d4acd | 2014-07-01 19:40:41 -0700 | [diff] [blame] | 4111 | * @see android.service.persistentdata.PersistentDataBlockManager |
| 4112 | * @hide |
| 4113 | */ |
Andres Morales | 33df937 | 2014-09-26 17:08:59 -0700 | [diff] [blame] | 4114 | @SystemApi |
Andres Morales | 68d4acd | 2014-07-01 19:40:41 -0700 | [diff] [blame] | 4115 | public static final String PERSISTENT_DATA_BLOCK_SERVICE = "persistent_data_block"; |
| 4116 | |
| 4117 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4118 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Andrew Scull | 3b8b46f | 2017-02-13 18:12:15 +0000 | [diff] [blame] | 4119 | * android.service.oemlock.OemLockManager} instance for managing the OEM lock. |
| 4120 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4121 | * @see #getSystemService(String) |
Andrew Scull | 3b8b46f | 2017-02-13 18:12:15 +0000 | [diff] [blame] | 4122 | * @see android.service.oemlock.OemLockManager |
| 4123 | * @hide |
| 4124 | */ |
| 4125 | @SystemApi |
| 4126 | public static final String OEM_LOCK_SERVICE = "oem_lock"; |
| 4127 | |
| 4128 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4129 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 4130 | * android.media.projection.MediaProjectionManager} instance for managing |
| 4131 | * media projection sessions. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4132 | * @see #getSystemService(String) |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 4133 | * @see android.media.projection.MediaProjectionManager |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 4134 | */ |
| 4135 | public static final String MEDIA_PROJECTION_SERVICE = "media_projection"; |
| 4136 | |
| 4137 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4138 | * Use with {@link #getSystemService(String)} to retrieve a |
Mike Lockwood | b673770 | 2015-02-20 08:28:47 -0800 | [diff] [blame] | 4139 | * {@link android.media.midi.MidiManager} for accessing the MIDI service. |
Mike Lockwood | 67f8e8b | 2014-12-01 13:54:59 -0800 | [diff] [blame] | 4140 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4141 | * @see #getSystemService(String) |
Mike Lockwood | 67f8e8b | 2014-12-01 13:54:59 -0800 | [diff] [blame] | 4142 | */ |
| 4143 | public static final String MIDI_SERVICE = "midi"; |
| 4144 | |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 4145 | |
| 4146 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4147 | * Use with {@link #getSystemService(String)} to retrieve a |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 4148 | * {@link android.hardware.radio.RadioManager} for accessing the broadcast radio service. |
| 4149 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4150 | * @see #getSystemService(String) |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 4151 | * @hide |
| 4152 | */ |
Tomasz Wasilczyk | 9110df7 | 2017-06-22 07:57:20 -0700 | [diff] [blame] | 4153 | public static final String RADIO_SERVICE = "broadcastradio"; |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 4154 | |
Paul McLean | a33be21 | 2015-02-20 07:52:45 -0800 | [diff] [blame] | 4155 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4156 | * Use with {@link #getSystemService(String)} to retrieve a |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 4157 | * {@link android.os.HardwarePropertiesManager} for accessing the hardware properties service. |
| 4158 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4159 | * @see #getSystemService(String) |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 4160 | */ |
Polina Bondarenko | 8333c73 | 2016-03-09 18:08:42 +0100 | [diff] [blame] | 4161 | public static final String HARDWARE_PROPERTIES_SERVICE = "hardware_properties"; |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 4162 | |
| 4163 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4164 | * Use with {@link #getSystemService(String)} to retrieve a |
Makoto Onuki | b5a012f | 2016-06-21 11:13:53 -0700 | [diff] [blame] | 4165 | * {@link android.content.pm.ShortcutManager} for accessing the launcher shortcut service. |
Makoto Onuki | 6f7362d9 | 2016-03-04 13:39:41 -0800 | [diff] [blame] | 4166 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4167 | * @see #getSystemService(String) |
Makoto Onuki | 6f7362d9 | 2016-03-04 13:39:41 -0800 | [diff] [blame] | 4168 | * @see android.content.pm.ShortcutManager |
| 4169 | */ |
| 4170 | public static final String SHORTCUT_SERVICE = "shortcut"; |
| 4171 | |
| 4172 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4173 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 4174 | * android.hardware.location.ContextHubManager} for accessing context hubs. |
| 4175 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4176 | * @see #getSystemService(String) |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 4177 | * @see android.hardware.location.ContextHubManager |
| 4178 | * |
| 4179 | * @hide |
| 4180 | */ |
| 4181 | @SystemApi |
| 4182 | public static final String CONTEXTHUB_SERVICE = "contexthub"; |
| 4183 | |
| 4184 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4185 | * Use with {@link #getSystemService(String)} to retrieve a |
Joe Onorato | 713fec8 | 2016-03-04 10:34:02 -0800 | [diff] [blame] | 4186 | * {@link android.os.health.SystemHealthManager} for accessing system health (battery, power, |
| 4187 | * memory, etc) metrics. |
| 4188 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4189 | * @see #getSystemService(String) |
Joe Onorato | 713fec8 | 2016-03-04 10:34:02 -0800 | [diff] [blame] | 4190 | */ |
| 4191 | public static final String SYSTEM_HEALTH_SERVICE = "systemhealth"; |
| 4192 | |
| 4193 | /** |
Amith Yamasani | d04aaa3 | 2016-06-13 12:09:36 -0700 | [diff] [blame] | 4194 | * Gatekeeper Service. |
| 4195 | * @hide |
| 4196 | */ |
| 4197 | public static final String GATEKEEPER_SERVICE = "android.service.gatekeeper.IGateKeeperService"; |
| 4198 | |
| 4199 | /** |
Svet Ganov | 37e4327 | 2016-09-09 16:01:32 -0700 | [diff] [blame] | 4200 | * Service defining the policy for access to device identifiers. |
| 4201 | * @hide |
| 4202 | */ |
| 4203 | public static final String DEVICE_IDENTIFIERS_SERVICE = "device_identifiers"; |
| 4204 | |
| 4205 | /** |
Joe Onorato | 1754d74 | 2016-11-21 17:51:35 -0800 | [diff] [blame] | 4206 | * Service to report a system health "incident" |
| 4207 | * @hide |
| 4208 | */ |
| 4209 | public static final String INCIDENT_SERVICE = "incident"; |
| 4210 | |
| 4211 | /** |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 4212 | * Service to assist statsd in obtaining general stats. |
| 4213 | * @hide |
| 4214 | */ |
| 4215 | public static final String STATS_COMPANION_SERVICE = "statscompanion"; |
| 4216 | |
| 4217 | /** |
Bookatz | c697797 | 2018-01-16 16:55:05 -0800 | [diff] [blame] | 4218 | * Use with {@link #getSystemService(String)} to retrieve an {@link android.app.StatsManager}. |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 4219 | * @hide |
| 4220 | */ |
| 4221 | @SystemApi |
| 4222 | public static final String STATS_MANAGER = "stats"; |
| 4223 | |
| 4224 | /** |
Nandana Dutt | 3386fb7 | 2018-12-12 17:26:57 +0000 | [diff] [blame] | 4225 | * Service to capture a bugreport. |
| 4226 | * @see #getSystemService(String) |
| 4227 | * @see android.os.BugreportManager |
| 4228 | * @hide |
| 4229 | */ |
| 4230 | // TODO: Expose API when the implementation is more complete. |
| 4231 | // @SystemApi |
| 4232 | public static final String BUGREPORT_SERVICE = "bugreport"; |
| 4233 | |
| 4234 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4235 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
MÃ¥rten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 4236 | * android.content.om.OverlayManager} for managing overlay packages. |
| 4237 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4238 | * @see #getSystemService(String) |
MÃ¥rten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 4239 | * @see android.content.om.OverlayManager |
| 4240 | * @hide |
| 4241 | */ |
| 4242 | public static final String OVERLAY_SERVICE = "overlay"; |
| 4243 | |
| 4244 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4245 | * Use with {@link #getSystemService(String)} to retrieve a |
Zak Cohen | 56345f4 | 2017-01-26 13:54:28 -0800 | [diff] [blame] | 4246 | * {@link VrManager} for accessing the VR service. |
| 4247 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4248 | * @see #getSystemService(String) |
Zak Cohen | 56345f4 | 2017-01-26 13:54:28 -0800 | [diff] [blame] | 4249 | * @hide |
| 4250 | */ |
| 4251 | @SystemApi |
| 4252 | public static final String VR_SERVICE = "vrmanager"; |
| 4253 | |
| 4254 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4255 | * Use with {@link #getSystemService(String)} to retrieve an |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 4256 | * {@link android.app.timezone.ITimeZoneRulesManager}. |
| 4257 | * @hide |
| 4258 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4259 | * @see #getSystemService(String) |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 4260 | */ |
| 4261 | public static final String TIME_ZONE_RULES_MANAGER_SERVICE = "timezone"; |
| 4262 | |
| 4263 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4264 | * Use with {@link #getSystemService(String)} to retrieve a |
Tony Mak | b0d2262 | 2018-01-18 12:49:49 +0000 | [diff] [blame] | 4265 | * {@link android.content.pm.CrossProfileApps} for cross profile operations. |
Tony Mak | 1b708e6 | 2017-10-12 10:59:11 +0100 | [diff] [blame] | 4266 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4267 | * @see #getSystemService(String) |
Tony Mak | 1b708e6 | 2017-10-12 10:59:11 +0100 | [diff] [blame] | 4268 | */ |
| 4269 | public static final String CROSS_PROFILE_APPS_SERVICE = "crossprofileapps"; |
| 4270 | |
| 4271 | /** |
Ruchi Kandoi | 6149b0f | 2018-01-03 16:14:57 -0800 | [diff] [blame] | 4272 | * Use with {@link #getSystemService} to retrieve a |
| 4273 | * {@link android.se.omapi.ISecureElementService} |
| 4274 | * for accessing the SecureElementService. |
| 4275 | * |
| 4276 | * @hide |
| 4277 | */ |
| 4278 | @SystemApi |
| 4279 | public static final String SECURE_ELEMENT_SERVICE = "secure_element"; |
| 4280 | |
| 4281 | /** |
Neil Fuller | b557907 | 2018-05-30 14:35:24 +0100 | [diff] [blame] | 4282 | * Use with {@link #getSystemService(String)} to retrieve an |
| 4283 | * {@link android.app.timedetector.ITimeDetectorService}. |
| 4284 | * @hide |
| 4285 | * |
| 4286 | * @see #getSystemService(String) |
| 4287 | */ |
| 4288 | public static final String TIME_DETECTOR_SERVICE = "time_detector"; |
| 4289 | |
| 4290 | /** |
Neil Fuller | cccc48d | 2018-06-19 12:53:47 +0100 | [diff] [blame] | 4291 | * Use with {@link #getSystemService(String)} to retrieve an |
Sahin Caliskan | 7719db2 | 2018-12-03 14:06:39 -0800 | [diff] [blame] | 4292 | * {@link android.telephony.ims.RcsManager}. |
Sahin Caliskan | 1256486 | 2018-10-31 13:23:29 -0700 | [diff] [blame] | 4293 | * @hide |
| 4294 | */ |
| 4295 | public static final String TELEPHONY_RCS_SERVICE = "ircs"; |
| 4296 | |
Howard Chen | f17f42b | 2019-01-07 14:10:44 +0800 | [diff] [blame] | 4297 | /** |
| 4298 | * Use with {@link #getSystemService(String)} to retrieve an |
| 4299 | * {@link android.os.DynamicAndroidManager}. |
| 4300 | * @hide |
| 4301 | */ |
| 4302 | @SystemApi |
| 4303 | public static final String DYNAMIC_ANDROID_SERVICE = "dynamic_android"; |
| 4304 | |
Sahin Caliskan | 1256486 | 2018-10-31 13:23:29 -0700 | [diff] [blame] | 4305 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4306 | * Determine whether the given permission is allowed for a particular |
| 4307 | * process and user ID running in the system. |
| 4308 | * |
| 4309 | * @param permission The name of the permission being checked. |
| 4310 | * @param pid The process ID being checked against. Must be > 0. |
| 4311 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 4312 | * user, which will pass every permission check. |
| 4313 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4314 | * @return {@link PackageManager#PERMISSION_GRANTED} if the given |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4315 | * pid/uid is allowed that permission, or |
| 4316 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4317 | * |
| 4318 | * @see PackageManager#checkPermission(String, String) |
| 4319 | * @see #checkCallingPermission |
| 4320 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4321 | @CheckResult(suggest="#enforcePermission(String,int,int,String)") |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4322 | @PackageManager.PermissionResult |
| 4323 | 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] | 4324 | |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 4325 | /** @hide */ |
| 4326 | @PackageManager.PermissionResult |
Mathew Inwood | 1c77a11 | 2018-08-14 14:06:26 +0100 | [diff] [blame] | 4327 | @UnsupportedAppUsage |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 4328 | public abstract int checkPermission(@NonNull String permission, int pid, int uid, |
| 4329 | IBinder callerToken); |
| 4330 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4331 | /** |
| 4332 | * Determine whether the calling process of an IPC you are handling has been |
| 4333 | * granted a particular permission. This is basically the same as calling |
| 4334 | * {@link #checkPermission(String, int, int)} with the pid and uid returned |
| 4335 | * by {@link android.os.Binder#getCallingPid} and |
| 4336 | * {@link android.os.Binder#getCallingUid}. One important difference |
| 4337 | * is that if you are not currently processing an IPC, this function |
| 4338 | * will always fail. This is done to protect against accidentally |
| 4339 | * leaking permissions; you can use {@link #checkCallingOrSelfPermission} |
| 4340 | * to avoid this protection. |
| 4341 | * |
| 4342 | * @param permission The name of the permission being checked. |
| 4343 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4344 | * @return {@link PackageManager#PERMISSION_GRANTED} if the calling |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4345 | * pid/uid is allowed that permission, or |
| 4346 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4347 | * |
| 4348 | * @see PackageManager#checkPermission(String, String) |
| 4349 | * @see #checkPermission |
| 4350 | * @see #checkCallingOrSelfPermission |
| 4351 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4352 | @CheckResult(suggest="#enforceCallingPermission(String,String)") |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4353 | @PackageManager.PermissionResult |
| 4354 | public abstract int checkCallingPermission(@NonNull String permission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4355 | |
| 4356 | /** |
| 4357 | * Determine whether the calling process of an IPC <em>or you</em> have been |
| 4358 | * granted a particular permission. This is the same as |
| 4359 | * {@link #checkCallingPermission}, except it grants your own permissions |
| 4360 | * if you are not currently processing an IPC. Use with care! |
| 4361 | * |
| 4362 | * @param permission The name of the permission being checked. |
| 4363 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4364 | * @return {@link PackageManager#PERMISSION_GRANTED} if the calling |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4365 | * pid/uid is allowed that permission, or |
| 4366 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4367 | * |
| 4368 | * @see PackageManager#checkPermission(String, String) |
| 4369 | * @see #checkPermission |
| 4370 | * @see #checkCallingPermission |
| 4371 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4372 | @CheckResult(suggest="#enforceCallingOrSelfPermission(String,String)") |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4373 | @PackageManager.PermissionResult |
| 4374 | public abstract int checkCallingOrSelfPermission(@NonNull String permission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4375 | |
| 4376 | /** |
Svetoslav | c6d1c34 | 2015-02-26 14:44:43 -0800 | [diff] [blame] | 4377 | * Determine whether <em>you</em> have been granted a particular permission. |
| 4378 | * |
| 4379 | * @param permission The name of the permission being checked. |
| 4380 | * |
| 4381 | * @return {@link PackageManager#PERMISSION_GRANTED} if you have the |
| 4382 | * permission, or {@link PackageManager#PERMISSION_DENIED} if not. |
| 4383 | * |
| 4384 | * @see PackageManager#checkPermission(String, String) |
| 4385 | * @see #checkCallingPermission(String) |
| 4386 | */ |
| 4387 | @PackageManager.PermissionResult |
| 4388 | public abstract int checkSelfPermission(@NonNull String permission); |
| 4389 | |
| 4390 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4391 | * If the given permission is not allowed for a particular process |
| 4392 | * and user ID running in the system, throw a {@link SecurityException}. |
| 4393 | * |
| 4394 | * @param permission The name of the permission being checked. |
| 4395 | * @param pid The process ID being checked against. Must be > 0. |
| 4396 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 4397 | * user, which will pass every permission check. |
| 4398 | * @param message A message to include in the exception if it is thrown. |
| 4399 | * |
| 4400 | * @see #checkPermission(String, int, int) |
| 4401 | */ |
| 4402 | public abstract void enforcePermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4403 | @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] | 4404 | |
| 4405 | /** |
| 4406 | * If the calling process of an IPC you are handling has not been |
| 4407 | * granted a particular permission, throw a {@link |
| 4408 | * SecurityException}. This is basically the same as calling |
| 4409 | * {@link #enforcePermission(String, int, int, String)} with the |
| 4410 | * pid and uid returned by {@link android.os.Binder#getCallingPid} |
| 4411 | * and {@link android.os.Binder#getCallingUid}. One important |
| 4412 | * difference is that if you are not currently processing an IPC, |
| 4413 | * this function will always throw the SecurityException. This is |
| 4414 | * done to protect against accidentally leaking permissions; you |
| 4415 | * can use {@link #enforceCallingOrSelfPermission} to avoid this |
| 4416 | * protection. |
| 4417 | * |
| 4418 | * @param permission The name of the permission being checked. |
| 4419 | * @param message A message to include in the exception if it is thrown. |
| 4420 | * |
| 4421 | * @see #checkCallingPermission(String) |
| 4422 | */ |
| 4423 | public abstract void enforceCallingPermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4424 | @NonNull String permission, @Nullable String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4425 | |
| 4426 | /** |
| 4427 | * If neither you nor the calling process of an IPC you are |
| 4428 | * handling has been granted a particular permission, throw a |
| 4429 | * {@link SecurityException}. This is the same as {@link |
| 4430 | * #enforceCallingPermission}, except it grants your own |
| 4431 | * permissions if you are not currently processing an IPC. Use |
| 4432 | * with care! |
| 4433 | * |
| 4434 | * @param permission The name of the permission being checked. |
| 4435 | * @param message A message to include in the exception if it is thrown. |
| 4436 | * |
| 4437 | * @see #checkCallingOrSelfPermission(String) |
| 4438 | */ |
| 4439 | public abstract void enforceCallingOrSelfPermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4440 | @NonNull String permission, @Nullable String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4441 | |
| 4442 | /** |
| 4443 | * Grant permission to access a specific Uri to another package, regardless |
| 4444 | * of whether that package has general permission to access the Uri's |
| 4445 | * content provider. This can be used to grant specific, temporary |
| 4446 | * permissions, typically in response to user interaction (such as the |
| 4447 | * user opening an attachment that you would like someone else to |
| 4448 | * display). |
| 4449 | * |
| 4450 | * <p>Normally you should use {@link Intent#FLAG_GRANT_READ_URI_PERMISSION |
| 4451 | * Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 4452 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
| 4453 | * Intent.FLAG_GRANT_WRITE_URI_PERMISSION} with the Intent being used to |
| 4454 | * start an activity instead of this function directly. If you use this |
| 4455 | * function directly, you should be sure to call |
| 4456 | * {@link #revokeUriPermission} when the target should no longer be allowed |
| 4457 | * to access it. |
| 4458 | * |
| 4459 | * <p>To succeed, the content provider owning the Uri must have set the |
| 4460 | * {@link android.R.styleable#AndroidManifestProvider_grantUriPermissions |
| 4461 | * grantUriPermissions} attribute in its manifest or included the |
| 4462 | * {@link android.R.styleable#AndroidManifestGrantUriPermission |
| 4463 | * <grant-uri-permissions>} tag. |
| 4464 | * |
| 4465 | * @param toPackage The package you would like to allow to access the Uri. |
| 4466 | * @param uri The Uri you would like to grant access to. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4467 | * @param modeFlags The desired access modes. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4468 | * |
| 4469 | * @see #revokeUriPermission |
| 4470 | */ |
| 4471 | public abstract void grantUriPermission(String toPackage, Uri uri, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4472 | @Intent.GrantUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4473 | |
| 4474 | /** |
| 4475 | * Remove all permissions to access a particular content provider Uri |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 4476 | * that were previously added with {@link #grantUriPermission} or <em>any other</em> mechanism. |
| 4477 | * 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] | 4478 | * 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] | 4479 | * revoke both "content://foo/target" and "content://foo/target/sub", but not |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4480 | * "content://foo". It will not remove any prefix grants that exist at a |
| 4481 | * higher level. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4482 | * |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 4483 | * <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] | 4484 | * regular permission access to a Uri, but had received access to it through |
| 4485 | * a specific Uri permission grant, you could not revoke that grant with this |
| 4486 | * function and a {@link SecurityException} would be thrown. As of |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 4487 | * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this function will not throw a security |
| 4488 | * 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] | 4489 | * (or none).</p> |
| 4490 | * |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 4491 | * <p>Unlike {@link #revokeUriPermission(String, Uri, int)}, this method impacts all permission |
| 4492 | * grants matching the given Uri, for any package they had been granted to, through any |
| 4493 | * mechanism this had happened (such as indirectly through the clipboard, activity launch, |
| 4494 | * service start, etc). That means this can be potentially dangerous to use, as it can |
| 4495 | * revoke grants that another app could be strongly expecting to stick around.</p> |
| 4496 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4497 | * @param uri The Uri you would like to revoke access to. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4498 | * @param modeFlags The access modes to revoke. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4499 | * |
| 4500 | * @see #grantUriPermission |
| 4501 | */ |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4502 | 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] | 4503 | |
| 4504 | /** |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 4505 | * Remove permissions to access a particular content provider Uri |
| 4506 | * that were previously added with {@link #grantUriPermission} for a specific target |
| 4507 | * package. The given Uri will match all previously granted Uris that are the same or a |
| 4508 | * sub-path of the given Uri. That is, revoking "content://foo/target" will |
| 4509 | * revoke both "content://foo/target" and "content://foo/target/sub", but not |
| 4510 | * "content://foo". It will not remove any prefix grants that exist at a |
| 4511 | * higher level. |
| 4512 | * |
| 4513 | * <p>Unlike {@link #revokeUriPermission(Uri, int)}, this method will <em>only</em> |
| 4514 | * revoke permissions that had been explicitly granted through {@link #grantUriPermission} |
| 4515 | * and only for the package specified. Any matching grants that have happened through |
| 4516 | * other mechanisms (clipboard, activity launching, service starting, etc) will not be |
| 4517 | * removed.</p> |
| 4518 | * |
| 4519 | * @param toPackage The package you had previously granted access to. |
| 4520 | * @param uri The Uri you would like to revoke access to. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4521 | * @param modeFlags The access modes to revoke. |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 4522 | * |
| 4523 | * @see #grantUriPermission |
| 4524 | */ |
| 4525 | public abstract void revokeUriPermission(String toPackage, Uri uri, |
| 4526 | @Intent.AccessUriMode int modeFlags); |
| 4527 | |
| 4528 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4529 | * Determine whether a particular process and user ID has been granted |
| 4530 | * permission to access a specific URI. This only checks for permissions |
| 4531 | * that have been explicitly granted -- if the given process/uid has |
| 4532 | * more general access to the URI's content provider then this check will |
| 4533 | * always fail. |
| 4534 | * |
| 4535 | * @param uri The uri that is being checked. |
| 4536 | * @param pid The process ID being checked against. Must be > 0. |
| 4537 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 4538 | * user, which will pass every permission check. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4539 | * @param modeFlags The access modes to check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4540 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4541 | * @return {@link PackageManager#PERMISSION_GRANTED} if the given |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4542 | * pid/uid is allowed to access that uri, or |
| 4543 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4544 | * |
| 4545 | * @see #checkCallingUriPermission |
| 4546 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4547 | @CheckResult(suggest="#enforceUriPermission(Uri,int,int,String)") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 4548 | @PackageManager.PermissionResult |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4549 | public abstract int checkUriPermission(Uri uri, int pid, int uid, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4550 | @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4551 | |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 4552 | /** @hide */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 4553 | @PackageManager.PermissionResult |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 4554 | public abstract int checkUriPermission(Uri uri, int pid, int uid, |
| 4555 | @Intent.AccessUriMode int modeFlags, IBinder callerToken); |
| 4556 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4557 | /** |
| 4558 | * Determine whether the calling process and user ID has been |
| 4559 | * granted permission to access a specific URI. This is basically |
| 4560 | * the same as calling {@link #checkUriPermission(Uri, int, int, |
| 4561 | * int)} with the pid and uid returned by {@link |
| 4562 | * android.os.Binder#getCallingPid} and {@link |
| 4563 | * android.os.Binder#getCallingUid}. One important difference is |
| 4564 | * that if you are not currently processing an IPC, this function |
| 4565 | * will always fail. |
| 4566 | * |
| 4567 | * @param uri The uri that is being checked. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4568 | * @param modeFlags The access modes to check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4569 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4570 | * @return {@link PackageManager#PERMISSION_GRANTED} if the caller |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4571 | * is allowed to access that uri, or |
| 4572 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4573 | * |
| 4574 | * @see #checkUriPermission(Uri, int, int, int) |
| 4575 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4576 | @CheckResult(suggest="#enforceCallingUriPermission(Uri,int,String)") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 4577 | @PackageManager.PermissionResult |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4578 | 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] | 4579 | |
| 4580 | /** |
| 4581 | * Determine whether the calling process of an IPC <em>or you</em> has been granted |
| 4582 | * permission to access a specific URI. This is the same as |
| 4583 | * {@link #checkCallingUriPermission}, except it grants your own permissions |
| 4584 | * if you are not currently processing an IPC. Use with care! |
| 4585 | * |
| 4586 | * @param uri The uri that is being checked. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4587 | * @param modeFlags The access modes to check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4588 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4589 | * @return {@link PackageManager#PERMISSION_GRANTED} if the caller |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4590 | * is allowed to access that uri, or |
| 4591 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4592 | * |
| 4593 | * @see #checkCallingUriPermission |
| 4594 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4595 | @CheckResult(suggest="#enforceCallingOrSelfUriPermission(Uri,int,String)") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 4596 | @PackageManager.PermissionResult |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4597 | public abstract int checkCallingOrSelfUriPermission(Uri uri, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4598 | @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4599 | |
| 4600 | /** |
| 4601 | * Check both a Uri and normal permission. This allows you to perform |
| 4602 | * both {@link #checkPermission} and {@link #checkUriPermission} in one |
| 4603 | * call. |
| 4604 | * |
| 4605 | * @param uri The Uri whose permission is to be checked, or null to not |
| 4606 | * do this check. |
| 4607 | * @param readPermission The permission that provides overall read access, |
| 4608 | * or null to not do this check. |
| 4609 | * @param writePermission The permission that provides overall write |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4610 | * access, or null to not do this check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4611 | * @param pid The process ID being checked against. Must be > 0. |
| 4612 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 4613 | * user, which will pass every permission check. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4614 | * @param modeFlags The access modes to check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4615 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4616 | * @return {@link PackageManager#PERMISSION_GRANTED} if the caller |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4617 | * is allowed to access that uri or holds one of the given permissions, or |
| 4618 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4619 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4620 | @CheckResult(suggest="#enforceUriPermission(Uri,String,String,int,int,int,String)") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 4621 | @PackageManager.PermissionResult |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4622 | public abstract int checkUriPermission(@Nullable Uri uri, @Nullable String readPermission, |
| 4623 | @Nullable String writePermission, int pid, int uid, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4624 | @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4625 | |
| 4626 | /** |
| 4627 | * If a particular process and user ID has not been granted |
| 4628 | * permission to access a specific URI, throw {@link |
| 4629 | * SecurityException}. This only checks for permissions that have |
| 4630 | * been explicitly granted -- if the given process/uid has more |
| 4631 | * general access to the URI's content provider then this check |
| 4632 | * will always fail. |
| 4633 | * |
| 4634 | * @param uri The uri that is being checked. |
| 4635 | * @param pid The process ID being checked against. Must be > 0. |
| 4636 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 4637 | * user, which will pass every permission check. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4638 | * @param modeFlags The access modes to enforce. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4639 | * @param message A message to include in the exception if it is thrown. |
| 4640 | * |
| 4641 | * @see #checkUriPermission(Uri, int, int, int) |
| 4642 | */ |
| 4643 | public abstract void enforceUriPermission( |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4644 | 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] | 4645 | |
| 4646 | /** |
| 4647 | * If the calling process and user ID has not been granted |
| 4648 | * permission to access a specific URI, throw {@link |
| 4649 | * SecurityException}. This is basically the same as calling |
| 4650 | * {@link #enforceUriPermission(Uri, int, int, int, String)} with |
| 4651 | * the pid and uid returned by {@link |
| 4652 | * android.os.Binder#getCallingPid} and {@link |
| 4653 | * android.os.Binder#getCallingUid}. One important difference is |
| 4654 | * that if you are not currently processing an IPC, this function |
| 4655 | * will always throw a SecurityException. |
| 4656 | * |
| 4657 | * @param uri The uri that is being checked. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4658 | * @param modeFlags The access modes to enforce. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4659 | * @param message A message to include in the exception if it is thrown. |
| 4660 | * |
| 4661 | * @see #checkCallingUriPermission(Uri, int) |
| 4662 | */ |
| 4663 | public abstract void enforceCallingUriPermission( |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4664 | Uri uri, @Intent.AccessUriMode int modeFlags, String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4665 | |
| 4666 | /** |
| 4667 | * If the calling process of an IPC <em>or you</em> has not been |
| 4668 | * granted permission to access a specific URI, throw {@link |
| 4669 | * SecurityException}. This is the same as {@link |
| 4670 | * #enforceCallingUriPermission}, except it grants your own |
| 4671 | * permissions if you are not currently processing an IPC. Use |
| 4672 | * with care! |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4673 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4674 | * @param uri The uri that is being checked. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4675 | * @param modeFlags The access modes to enforce. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4676 | * @param message A message to include in the exception if it is thrown. |
| 4677 | * |
| 4678 | * @see #checkCallingOrSelfUriPermission(Uri, int) |
| 4679 | */ |
| 4680 | public abstract void enforceCallingOrSelfUriPermission( |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4681 | Uri uri, @Intent.AccessUriMode int modeFlags, String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4682 | |
| 4683 | /** |
| 4684 | * Enforce both a Uri and normal permission. This allows you to perform |
| 4685 | * both {@link #enforcePermission} and {@link #enforceUriPermission} in one |
| 4686 | * call. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4687 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4688 | * @param uri The Uri whose permission is to be checked, or null to not |
| 4689 | * do this check. |
| 4690 | * @param readPermission The permission that provides overall read access, |
| 4691 | * or null to not do this check. |
| 4692 | * @param writePermission The permission that provides overall write |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4693 | * access, or null to not do this check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4694 | * @param pid The process ID being checked against. Must be > 0. |
| 4695 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 4696 | * user, which will pass every permission check. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4697 | * @param modeFlags The access modes to enforce. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4698 | * @param message A message to include in the exception if it is thrown. |
| 4699 | * |
| 4700 | * @see #checkUriPermission(Uri, String, String, int, int, int) |
| 4701 | */ |
| 4702 | public abstract void enforceUriPermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4703 | @Nullable Uri uri, @Nullable String readPermission, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4704 | @Nullable String writePermission, int pid, int uid, @Intent.AccessUriMode int modeFlags, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4705 | @Nullable String message); |
| 4706 | |
| 4707 | /** @hide */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 4708 | @IntDef(flag = true, prefix = { "CONTEXT_" }, value = { |
| 4709 | CONTEXT_INCLUDE_CODE, |
| 4710 | CONTEXT_IGNORE_SECURITY, |
| 4711 | CONTEXT_RESTRICTED, |
| 4712 | CONTEXT_DEVICE_PROTECTED_STORAGE, |
| 4713 | CONTEXT_CREDENTIAL_PROTECTED_STORAGE, |
| 4714 | CONTEXT_REGISTER_PACKAGE, |
| 4715 | }) |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4716 | @Retention(RetentionPolicy.SOURCE) |
| 4717 | public @interface CreatePackageOptions {} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4718 | |
| 4719 | /** |
| 4720 | * Flag for use with {@link #createPackageContext}: include the application |
| 4721 | * code with the context. This means loading code into the caller's |
| 4722 | * process, so that {@link #getClassLoader()} can be used to instantiate |
| 4723 | * the application's classes. Setting this flags imposes security |
| 4724 | * restrictions on what application context you can access; if the |
| 4725 | * requested application can not be safely loaded into your process, |
| 4726 | * java.lang.SecurityException will be thrown. If this flag is not set, |
| 4727 | * there will be no restrictions on the packages that can be loaded, |
| 4728 | * but {@link #getClassLoader} will always return the default system |
| 4729 | * class loader. |
| 4730 | */ |
| 4731 | public static final int CONTEXT_INCLUDE_CODE = 0x00000001; |
| 4732 | |
| 4733 | /** |
| 4734 | * Flag for use with {@link #createPackageContext}: ignore any security |
| 4735 | * restrictions on the Context being requested, allowing it to always |
| 4736 | * be loaded. For use with {@link #CONTEXT_INCLUDE_CODE} to allow code |
| 4737 | * to be loaded into a process even when it isn't safe to do so. Use |
| 4738 | * with extreme care! |
| 4739 | */ |
| 4740 | public static final int CONTEXT_IGNORE_SECURITY = 0x00000002; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4741 | |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 4742 | /** |
| 4743 | * Flag for use with {@link #createPackageContext}: a restricted context may |
| 4744 | * disable specific features. For instance, a View associated with a restricted |
| 4745 | * context would ignore particular XML attributes. |
| 4746 | */ |
| 4747 | public static final int CONTEXT_RESTRICTED = 0x00000004; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4748 | |
| 4749 | /** |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4750 | * Flag for use with {@link #createPackageContext}: point all file APIs at |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4751 | * device-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4752 | * |
| 4753 | * @hide |
| 4754 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4755 | public static final int CONTEXT_DEVICE_PROTECTED_STORAGE = 0x00000008; |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4756 | |
| 4757 | /** |
| 4758 | * Flag for use with {@link #createPackageContext}: point all file APIs at |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4759 | * credential-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4760 | * |
| 4761 | * @hide |
| 4762 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4763 | public static final int CONTEXT_CREDENTIAL_PROTECTED_STORAGE = 0x00000010; |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4764 | |
| 4765 | /** |
Dianne Hackborn | fee756f | 2014-07-16 17:31:10 -0700 | [diff] [blame] | 4766 | * @hide Used to indicate we should tell the activity manager about the process |
| 4767 | * loading this code. |
| 4768 | */ |
| 4769 | public static final int CONTEXT_REGISTER_PACKAGE = 0x40000000; |
| 4770 | |
| 4771 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4772 | * Return a new Context object for the given application name. This |
| 4773 | * Context is the same as what the named application gets when it is |
| 4774 | * launched, containing the same resources and class loader. Each call to |
| 4775 | * this method returns a new instance of a Context object; Context objects |
| 4776 | * are not shared, however they share common state (Resources, ClassLoader, |
| 4777 | * etc) so the Context instance itself is fairly lightweight. |
| 4778 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 4779 | * <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] | 4780 | * application with the given package name. |
| 4781 | * |
| 4782 | * <p>Throws {@link java.lang.SecurityException} if the Context requested |
| 4783 | * can not be loaded into the caller's process for security reasons (see |
| 4784 | * {@link #CONTEXT_INCLUDE_CODE} for more information}. |
| 4785 | * |
| 4786 | * @param packageName Name of the application's package. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 4787 | * @param flags Option flags. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4788 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4789 | * @return A {@link Context} for the application. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4790 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4791 | * @throws SecurityException |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4792 | * @throws PackageManager.NameNotFoundException if there is no application with |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4793 | * the given package name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4794 | */ |
| 4795 | public abstract Context createPackageContext(String packageName, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4796 | @CreatePackageOptions int flags) throws PackageManager.NameNotFoundException; |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 4797 | |
| 4798 | /** |
Jeff Sharkey | 6d51571 | 2012-09-20 16:06:08 -0700 | [diff] [blame] | 4799 | * Similar to {@link #createPackageContext(String, int)}, but with a |
| 4800 | * different {@link UserHandle}. For example, {@link #getContentResolver()} |
| 4801 | * will open any {@link Uri} as the given user. |
| 4802 | * |
| 4803 | * @hide |
| 4804 | */ |
Patrick Baumann | ef4c407 | 2018-02-01 08:54:05 -0800 | [diff] [blame] | 4805 | @SystemApi |
| 4806 | public Context createPackageContextAsUser( |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 4807 | String packageName, @CreatePackageOptions int flags, UserHandle user) |
Patrick Baumann | ef4c407 | 2018-02-01 08:54:05 -0800 | [diff] [blame] | 4808 | throws PackageManager.NameNotFoundException { |
| 4809 | if (Build.IS_ENG) { |
| 4810 | throw new IllegalStateException("createPackageContextAsUser not overridden!"); |
| 4811 | } |
| 4812 | return this; |
| 4813 | } |
Jeff Sharkey | 6d51571 | 2012-09-20 16:06:08 -0700 | [diff] [blame] | 4814 | |
| 4815 | /** |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 4816 | * Creates a context given an {@link android.content.pm.ApplicationInfo}. |
| 4817 | * |
| 4818 | * @hide |
| 4819 | */ |
Mathew Inwood | 1c77a11 | 2018-08-14 14:06:26 +0100 | [diff] [blame] | 4820 | @UnsupportedAppUsage |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 4821 | public abstract Context createApplicationContext(ApplicationInfo application, |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 4822 | @CreatePackageOptions int flags) throws PackageManager.NameNotFoundException; |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 4823 | |
| 4824 | /** |
Adam Lesinski | 4e86281 | 2016-11-21 16:02:24 -0800 | [diff] [blame] | 4825 | * Return a new Context object for the given split name. The new Context has a ClassLoader and |
| 4826 | * Resources object that can access the split's and all of its dependencies' code/resources. |
| 4827 | * Each call to this method returns a new instance of a Context object; |
| 4828 | * Context objects are not shared, however common state (ClassLoader, other Resources for |
| 4829 | * the same split) may be so the Context itself can be fairly lightweight. |
| 4830 | * |
| 4831 | * @param splitName The name of the split to include, as declared in the split's |
| 4832 | * <code>AndroidManifest.xml</code>. |
| 4833 | * @return A {@link Context} with the given split's code and/or resources loaded. |
| 4834 | */ |
| 4835 | public abstract Context createContextForSplit(String splitName) |
| 4836 | throws PackageManager.NameNotFoundException; |
| 4837 | |
| 4838 | /** |
Jeff Sharkey | ad357d1 | 2018-02-02 13:25:31 -0700 | [diff] [blame] | 4839 | * Get the user associated with this context |
Jim Miller | a75a883 | 2013-02-07 16:53:32 -0800 | [diff] [blame] | 4840 | * @hide |
| 4841 | */ |
Jeff Sharkey | a73b8fd | 2016-01-06 17:02:08 -0700 | [diff] [blame] | 4842 | @TestApi |
Jeff Sharkey | ad357d1 | 2018-02-02 13:25:31 -0700 | [diff] [blame] | 4843 | public UserHandle getUser() { |
| 4844 | return android.os.Process.myUserHandle(); |
| 4845 | } |
| 4846 | |
| 4847 | /** |
| 4848 | * Get the user associated with this context |
| 4849 | * @hide |
| 4850 | */ |
| 4851 | @TestApi |
| 4852 | public @UserIdInt int getUserId() { |
| 4853 | return android.os.UserHandle.myUserId(); |
| 4854 | } |
Jim Miller | a75a883 | 2013-02-07 16:53:32 -0800 | [diff] [blame] | 4855 | |
| 4856 | /** |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 4857 | * Return a new Context object for the current Context but whose resources |
| 4858 | * are adjusted to match the given Configuration. Each call to this method |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 4859 | * returns a new instance of a Context object; Context objects are not |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 4860 | * shared, however common state (ClassLoader, other Resources for the |
| 4861 | * same configuration) may be so the Context itself can be fairly lightweight. |
| 4862 | * |
| 4863 | * @param overrideConfiguration A {@link Configuration} specifying what |
| 4864 | * values to modify in the base Configuration of the original Context's |
| 4865 | * resources. If the base configuration changes (such as due to an |
| 4866 | * orientation change), the resources of this context will also change except |
| 4867 | * for those that have been explicitly overridden with a value here. |
| 4868 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4869 | * @return A {@link Context} with the given configuration override. |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 4870 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4871 | public abstract Context createConfigurationContext( |
| 4872 | @NonNull Configuration overrideConfiguration); |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 4873 | |
| 4874 | /** |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 4875 | * Return a new Context object for the current Context but whose resources |
| 4876 | * are adjusted to match the metrics of the given Display. Each call to this method |
| 4877 | * returns a new instance of a Context object; Context objects are not |
| 4878 | * shared, however common state (ClassLoader, other Resources for the |
| 4879 | * same configuration) may be so the Context itself can be fairly lightweight. |
| 4880 | * |
| 4881 | * The returned display Context provides a {@link WindowManager} |
| 4882 | * (see {@link #getSystemService(String)}) that is configured to show windows |
| 4883 | * on the given display. The WindowManager's {@link WindowManager#getDefaultDisplay} |
| 4884 | * method can be used to retrieve the Display from the returned Context. |
| 4885 | * |
| 4886 | * @param display A {@link Display} object specifying the display |
| 4887 | * for whose metrics the Context's resources should be tailored and upon which |
| 4888 | * new windows should be shown. |
| 4889 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4890 | * @return A {@link Context} for the display. |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 4891 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4892 | public abstract Context createDisplayContext(@NonNull Display display); |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 4893 | |
| 4894 | /** |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4895 | * Return a new Context object for the current Context but whose storage |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4896 | * APIs are backed by device-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4897 | * <p> |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 4898 | * On devices with direct boot, data stored in this location is encrypted |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4899 | * with a key tied to the physical device, and it can be accessed |
| 4900 | * immediately after the device has booted successfully, both |
| 4901 | * <em>before and after</em> the user has authenticated with their |
| 4902 | * credentials (such as a lock pattern or PIN). |
| 4903 | * <p> |
| 4904 | * Because device-protected data is available without user authentication, |
| 4905 | * you should carefully limit the data you store using this Context. For |
| 4906 | * example, storing sensitive authentication tokens or passwords in the |
| 4907 | * device-protected area is strongly discouraged. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4908 | * <p> |
Jeff Sharkey | 3ea44a5 | 2016-01-09 15:19:56 -0700 | [diff] [blame] | 4909 | * If the underlying device does not have the ability to store |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4910 | * device-protected and credential-protected data using different keys, then |
| 4911 | * both storage areas will become available at the same time. They remain as |
| 4912 | * two distinct storage locations on disk, and only the window of |
| 4913 | * availability changes. |
Jeff Sharkey | 3ea44a5 | 2016-01-09 15:19:56 -0700 | [diff] [blame] | 4914 | * <p> |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4915 | * Each call to this method returns a new instance of a Context object; |
| 4916 | * Context objects are not shared, however common state (ClassLoader, other |
| 4917 | * Resources for the same configuration) may be so the Context itself can be |
| 4918 | * fairly lightweight. |
| 4919 | * |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4920 | * @see #isDeviceProtectedStorage() |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4921 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4922 | public abstract Context createDeviceProtectedStorageContext(); |
| 4923 | |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4924 | /** |
| 4925 | * Return a new Context object for the current Context but whose storage |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4926 | * APIs are backed by credential-protected storage. This is the default |
| 4927 | * storage area for apps unless |
| 4928 | * {@link android.R.attr#defaultToDeviceProtectedStorage} was requested. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4929 | * <p> |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 4930 | * On devices with direct boot, data stored in this location is encrypted |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4931 | * with a key tied to user credentials, which can be accessed |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4932 | * <em>only after</em> the user has entered their credentials (such as a |
| 4933 | * lock pattern or PIN). |
| 4934 | * <p> |
Jeff Sharkey | 3ea44a5 | 2016-01-09 15:19:56 -0700 | [diff] [blame] | 4935 | * If the underlying device does not have the ability to store |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4936 | * device-protected and credential-protected data using different keys, then |
| 4937 | * both storage areas will become available at the same time. They remain as |
| 4938 | * two distinct storage locations on disk, and only the window of |
| 4939 | * availability changes. |
Jeff Sharkey | 3ea44a5 | 2016-01-09 15:19:56 -0700 | [diff] [blame] | 4940 | * <p> |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4941 | * Each call to this method returns a new instance of a Context object; |
| 4942 | * Context objects are not shared, however common state (ClassLoader, other |
| 4943 | * Resources for the same configuration) may be so the Context itself can be |
| 4944 | * fairly lightweight. |
| 4945 | * |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4946 | * @see #isCredentialProtectedStorage() |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 4947 | * @hide |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4948 | */ |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 4949 | @SystemApi |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4950 | public abstract Context createCredentialProtectedStorageContext(); |
| 4951 | |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4952 | /** |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 4953 | * Gets the display adjustments holder for this context. This information |
| 4954 | * is provided on a per-application or activity basis and is used to simulate lower density |
| 4955 | * display metrics for legacy applications and restricted screen sizes. |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 4956 | * |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 4957 | * @param displayId The display id for which to get compatibility info. |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 4958 | * @return The compatibility info holder, or null if not required by the application. |
| 4959 | * @hide |
| 4960 | */ |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 4961 | public abstract DisplayAdjustments getDisplayAdjustments(int displayId); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 4962 | |
| 4963 | /** |
Adam Lesinski | 4ece3d6 | 2016-06-16 18:05:41 -0700 | [diff] [blame] | 4964 | * @hide |
| 4965 | */ |
Mathew Inwood | 1c77a11 | 2018-08-14 14:06:26 +0100 | [diff] [blame] | 4966 | @UnsupportedAppUsage |
Adam Lesinski | 4ece3d6 | 2016-06-16 18:05:41 -0700 | [diff] [blame] | 4967 | public abstract Display getDisplay(); |
| 4968 | |
| 4969 | /** |
Andrii Kulian | b047b8b | 2017-02-08 18:38:26 -0800 | [diff] [blame] | 4970 | * @hide |
| 4971 | */ |
| 4972 | public abstract void updateDisplay(int displayId); |
| 4973 | |
| 4974 | /** |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 4975 | * Indicates whether this Context is restricted. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4976 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4977 | * @return {@code true} if this Context is restricted, {@code false} otherwise. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4978 | * |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 4979 | * @see #CONTEXT_RESTRICTED |
| 4980 | */ |
| 4981 | public boolean isRestricted() { |
| 4982 | return false; |
| 4983 | } |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4984 | |
| 4985 | /** |
| 4986 | * Indicates if the storage APIs of this Context are backed by |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4987 | * device-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4988 | * |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4989 | * @see #createDeviceProtectedStorageContext() |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4990 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4991 | public abstract boolean isDeviceProtectedStorage(); |
| 4992 | |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4993 | /** |
| 4994 | * Indicates if the storage APIs of this Context are backed by |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4995 | * credential-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4996 | * |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 4997 | * @see #createCredentialProtectedStorageContext() |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 4998 | * @hide |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 4999 | */ |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 5000 | @SystemApi |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5001 | public abstract boolean isCredentialProtectedStorage(); |
| 5002 | |
Tony Mak | 46aabe5 | 2016-11-14 12:53:06 +0000 | [diff] [blame] | 5003 | /** |
Seigo Nonaka | 6d6cd68 | 2017-06-22 08:22:18 -0700 | [diff] [blame] | 5004 | * Returns true if the context can load unsafe resources, e.g. fonts. |
| 5005 | * @hide |
| 5006 | */ |
| 5007 | public abstract boolean canLoadUnsafeResources(); |
| 5008 | |
| 5009 | /** |
Tony Mak | 46aabe5 | 2016-11-14 12:53:06 +0000 | [diff] [blame] | 5010 | * @hide |
| 5011 | */ |
| 5012 | public IBinder getActivityToken() { |
| 5013 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 5014 | } |
| 5015 | |
| 5016 | /** |
| 5017 | * @hide |
| 5018 | */ |
| 5019 | @Nullable |
| 5020 | public IServiceConnection getServiceDispatcher(ServiceConnection conn, Handler handler, |
| 5021 | int flags) { |
| 5022 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 5023 | } |
| 5024 | |
| 5025 | /** |
| 5026 | * @hide |
| 5027 | */ |
| 5028 | public IApplicationThread getIApplicationThread() { |
| 5029 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 5030 | } |
Tony Mak | bf9928d | 2016-12-22 11:02:45 +0000 | [diff] [blame] | 5031 | |
| 5032 | /** |
| 5033 | * @hide |
| 5034 | */ |
| 5035 | public Handler getMainThreadHandler() { |
| 5036 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 5037 | } |
Adam Lesinski | a82b626 | 2017-03-21 16:56:17 -0700 | [diff] [blame] | 5038 | |
| 5039 | /** |
Felipe Leme | bb567ae | 2017-10-04 09:56:21 -0700 | [diff] [blame] | 5040 | * @hide |
| 5041 | */ |
| 5042 | public AutofillClient getAutofillClient() { |
| 5043 | return null; |
| 5044 | } |
| 5045 | |
| 5046 | /** |
| 5047 | * @hide |
| 5048 | */ |
Svet Ganov | 47b37aa | 2018-02-16 00:11:39 -0800 | [diff] [blame] | 5049 | public void setAutofillClient(@SuppressWarnings("unused") AutofillClient client) { |
Felipe Leme | bb567ae | 2017-10-04 09:56:21 -0700 | [diff] [blame] | 5050 | } |
| 5051 | |
| 5052 | /** |
Svetoslav Ganov | 24c9045 | 2017-12-27 15:17:14 -0800 | [diff] [blame] | 5053 | * @hide |
| 5054 | */ |
| 5055 | public boolean isAutofillCompatibilityEnabled() { |
| 5056 | return false; |
| 5057 | } |
| 5058 | |
| 5059 | /** |
| 5060 | * @hide |
| 5061 | */ |
Svet Ganov | 47b37aa | 2018-02-16 00:11:39 -0800 | [diff] [blame] | 5062 | @TestApi |
| 5063 | public void setAutofillCompatibilityEnabled( |
| 5064 | @SuppressWarnings("unused") boolean autofillCompatEnabled) { |
Svetoslav Ganov | 24c9045 | 2017-12-27 15:17:14 -0800 | [diff] [blame] | 5065 | } |
| 5066 | |
| 5067 | /** |
Adam Lesinski | a82b626 | 2017-03-21 16:56:17 -0700 | [diff] [blame] | 5068 | * Throws an exception if the Context is using system resources, |
| 5069 | * which are non-runtime-overlay-themable and may show inconsistent UI. |
| 5070 | * @hide |
| 5071 | */ |
| 5072 | public void assertRuntimeOverlayThemable() { |
| 5073 | // Resources.getSystem() is a singleton and the only Resources not managed by |
| 5074 | // ResourcesManager; therefore Resources.getSystem() is not themable. |
| 5075 | if (getResources() == Resources.getSystem()) { |
| 5076 | throw new IllegalArgumentException("Non-UI context used to display UI; " |
| 5077 | + "get a UI context from ActivityThread#getSystemUiContext()"); |
| 5078 | } |
| 5079 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5080 | } |