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 | 5c0d354 | 2018-08-14 13:54:31 +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; |
| 52 | import android.net.Uri; |
Patrick Baumann | ef4c407 | 2018-02-01 08:54:05 -0800 | [diff] [blame] | 53 | import android.os.Build; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 54 | import android.os.Bundle; |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 55 | import android.os.Environment; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 56 | import android.os.Handler; |
Jeff Sharkey | 8439ac0 | 2017-12-12 17:26:23 -0700 | [diff] [blame] | 57 | import android.os.HandlerExecutor; |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 58 | import android.os.IBinder; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 59 | import android.os.Looper; |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 60 | import android.os.StatFs; |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 61 | import android.os.UserHandle; |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 62 | import android.os.UserManager; |
Jeff Sharkey | 60a82cd | 2017-04-18 18:19:16 -0600 | [diff] [blame] | 63 | import android.os.storage.StorageManager; |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 64 | import android.provider.MediaStore; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 65 | import android.util.AttributeSet; |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 66 | import android.view.Display; |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 67 | import android.view.DisplayAdjustments; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 68 | import android.view.View; |
Jon Miranda | 836c0a8 | 2014-08-11 12:32:26 -0700 | [diff] [blame] | 69 | import android.view.ViewDebug; |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 70 | import android.view.WindowManager; |
Felipe Leme | bb567ae | 2017-10-04 09:56:21 -0700 | [diff] [blame] | 71 | import android.view.autofill.AutofillManager.AutofillClient; |
Abodunrinwa Toki | f001fef | 2017-01-04 23:51:42 +0000 | [diff] [blame] | 72 | import android.view.textclassifier.TextClassificationManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 73 | |
| 74 | import java.io.File; |
| 75 | import java.io.FileInputStream; |
| 76 | import java.io.FileNotFoundException; |
| 77 | import java.io.FileOutputStream; |
| 78 | import java.io.IOException; |
| 79 | import java.io.InputStream; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 80 | import java.lang.annotation.Retention; |
| 81 | import java.lang.annotation.RetentionPolicy; |
Jeff Sharkey | 8439ac0 | 2017-12-12 17:26:23 -0700 | [diff] [blame] | 82 | import java.util.concurrent.Executor; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 83 | |
| 84 | /** |
| 85 | * Interface to global information about an application environment. This is |
| 86 | * an abstract class whose implementation is provided by |
| 87 | * the Android system. It |
| 88 | * allows access to application-specific resources and classes, as well as |
| 89 | * up-calls for application-level operations such as launching activities, |
| 90 | * broadcasting and receiving intents, etc. |
| 91 | */ |
| 92 | public abstract class Context { |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 93 | /** @hide */ |
| 94 | @IntDef(flag = true, prefix = { "MODE_" }, value = { |
| 95 | MODE_PRIVATE, |
| 96 | MODE_WORLD_READABLE, |
| 97 | MODE_WORLD_WRITEABLE, |
| 98 | MODE_APPEND, |
| 99 | }) |
| 100 | @Retention(RetentionPolicy.SOURCE) |
| 101 | public @interface FileMode {} |
| 102 | |
| 103 | /** @hide */ |
| 104 | @IntDef(flag = true, prefix = { "MODE_" }, value = { |
| 105 | MODE_PRIVATE, |
| 106 | MODE_WORLD_READABLE, |
| 107 | MODE_WORLD_WRITEABLE, |
| 108 | MODE_MULTI_PROCESS, |
| 109 | }) |
| 110 | @Retention(RetentionPolicy.SOURCE) |
| 111 | public @interface PreferencesMode {} |
| 112 | |
| 113 | /** @hide */ |
| 114 | @IntDef(flag = true, prefix = { "MODE_" }, value = { |
| 115 | MODE_PRIVATE, |
| 116 | MODE_WORLD_READABLE, |
| 117 | MODE_WORLD_WRITEABLE, |
| 118 | MODE_ENABLE_WRITE_AHEAD_LOGGING, |
| 119 | MODE_NO_LOCALIZED_COLLATORS, |
| 120 | }) |
| 121 | @Retention(RetentionPolicy.SOURCE) |
| 122 | public @interface DatabaseMode {} |
| 123 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 124 | /** |
| 125 | * File creation mode: the default mode, where the created file can only |
| 126 | * be accessed by the calling application (or all applications sharing the |
| 127 | * same user ID). |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 128 | */ |
| 129 | public static final int MODE_PRIVATE = 0x0000; |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 130 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 131 | /** |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 132 | * File creation mode: allow all other applications to have read access to |
| 133 | * the created file. |
| 134 | * <p> |
Dave Friedman | cfe5088 | 2017-07-05 00:40:07 -0700 | [diff] [blame] | 135 | * Starting from {@link android.os.Build.VERSION_CODES#N}, attempting to use this |
| 136 | * mode throws a {@link SecurityException}. |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 137 | * |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 138 | * @deprecated Creating world-readable files is very dangerous, and likely |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 139 | * to cause security holes in applications. It is strongly |
| 140 | * discouraged; instead, applications should use more formal |
| 141 | * mechanism for interactions such as {@link ContentProvider}, |
| 142 | * {@link BroadcastReceiver}, and {@link android.app.Service}. |
| 143 | * There are no guarantees that this access mode will remain on |
| 144 | * a file, such as when it goes through a backup and restore. |
| 145 | * @see android.support.v4.content.FileProvider |
| 146 | * @see Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 147 | */ |
Dianne Hackborn | 556b09e | 2012-09-23 17:46:53 -0700 | [diff] [blame] | 148 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 149 | public static final int MODE_WORLD_READABLE = 0x0001; |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 150 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 151 | /** |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 152 | * File creation mode: allow all other applications to have write access to |
| 153 | * the created file. |
| 154 | * <p> |
Dave Friedman | cfe5088 | 2017-07-05 00:40:07 -0700 | [diff] [blame] | 155 | * 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] | 156 | * mode will throw a {@link SecurityException}. |
| 157 | * |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 158 | * @deprecated Creating world-writable files is very dangerous, and likely |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 159 | * to cause security holes in applications. It is strongly |
| 160 | * discouraged; instead, applications should use more formal |
| 161 | * mechanism for interactions such as {@link ContentProvider}, |
| 162 | * {@link BroadcastReceiver}, and {@link android.app.Service}. |
| 163 | * There are no guarantees that this access mode will remain on |
| 164 | * a file, such as when it goes through a backup and restore. |
| 165 | * @see android.support.v4.content.FileProvider |
| 166 | * @see Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 167 | */ |
Dianne Hackborn | 556b09e | 2012-09-23 17:46:53 -0700 | [diff] [blame] | 168 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 169 | public static final int MODE_WORLD_WRITEABLE = 0x0002; |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 170 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 171 | /** |
| 172 | * File creation mode: for use with {@link #openFileOutput}, if the file |
| 173 | * already exists then write data to the end of the existing file |
| 174 | * instead of erasing it. |
| 175 | * @see #openFileOutput |
| 176 | */ |
| 177 | public static final int MODE_APPEND = 0x8000; |
| 178 | |
| 179 | /** |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 180 | * SharedPreference loading flag: when set, the file on disk will |
| 181 | * be checked for modification even if the shared preferences |
| 182 | * instance is already loaded in this process. This behavior is |
| 183 | * sometimes desired in cases where the application has multiple |
| 184 | * processes, all writing to the same SharedPreferences file. |
| 185 | * Generally there are better forms of communication between |
| 186 | * processes, though. |
| 187 | * |
| 188 | * <p>This was the legacy (but undocumented) behavior in and |
| 189 | * before Gingerbread (Android 2.3) and this flag is implied when |
kopriva | 219f7dc | 2018-10-09 13:42:28 -0700 | [diff] [blame] | 190 | * targeting such releases. For applications targeting SDK |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 191 | * versions <em>greater than</em> Android 2.3, this flag must be |
| 192 | * explicitly set if desired. |
| 193 | * |
| 194 | * @see #getSharedPreferences |
Christopher Tate | d5748b8 | 2015-05-08 18:14:01 -0700 | [diff] [blame] | 195 | * |
| 196 | * @deprecated MODE_MULTI_PROCESS does not work reliably in |
| 197 | * some versions of Android, and furthermore does not provide any |
| 198 | * mechanism for reconciling concurrent modifications across |
| 199 | * processes. Applications should not attempt to use it. Instead, |
| 200 | * they should use an explicit cross-process data management |
| 201 | * approach such as {@link android.content.ContentProvider ContentProvider}. |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 202 | */ |
Christopher Tate | d5748b8 | 2015-05-08 18:14:01 -0700 | [diff] [blame] | 203 | @Deprecated |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 204 | public static final int MODE_MULTI_PROCESS = 0x0004; |
| 205 | |
| 206 | /** |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 207 | * Database open flag: when set, the database is opened with write-ahead |
| 208 | * logging enabled by default. |
| 209 | * |
| 210 | * @see #openOrCreateDatabase(String, int, CursorFactory) |
| 211 | * @see #openOrCreateDatabase(String, int, CursorFactory, DatabaseErrorHandler) |
| 212 | * @see SQLiteDatabase#enableWriteAheadLogging |
| 213 | */ |
| 214 | public static final int MODE_ENABLE_WRITE_AHEAD_LOGGING = 0x0008; |
| 215 | |
Sunny Goyal | a21e6b2 | 2015-12-02 09:51:02 -0800 | [diff] [blame] | 216 | /** |
| 217 | * Database open flag: when set, the database is opened without support for |
| 218 | * localized collators. |
| 219 | * |
| 220 | * @see #openOrCreateDatabase(String, int, CursorFactory) |
| 221 | * @see #openOrCreateDatabase(String, int, CursorFactory, DatabaseErrorHandler) |
| 222 | * @see SQLiteDatabase#NO_LOCALIZED_COLLATORS |
| 223 | */ |
| 224 | public static final int MODE_NO_LOCALIZED_COLLATORS = 0x0010; |
| 225 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 226 | /** @hide */ |
Jeff Sharkey | ce8db99 | 2017-12-13 20:05:05 -0700 | [diff] [blame] | 227 | @IntDef(flag = true, prefix = { "BIND_" }, value = { |
| 228 | BIND_AUTO_CREATE, |
| 229 | BIND_DEBUG_UNBIND, |
| 230 | BIND_NOT_FOREGROUND, |
| 231 | BIND_ABOVE_CLIENT, |
| 232 | BIND_ALLOW_OOM_MANAGEMENT, |
| 233 | BIND_WAIVE_PRIORITY, |
| 234 | BIND_IMPORTANT, |
| 235 | BIND_ADJUST_WITH_ACTIVITY |
| 236 | }) |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 237 | @Retention(RetentionPolicy.SOURCE) |
| 238 | public @interface BindServiceFlags {} |
| 239 | |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 240 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 241 | * Flag for {@link #bindService}: automatically create the service as long |
| 242 | * as the binding exists. Note that while this will create the service, |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 243 | * its {@link android.app.Service#onStartCommand} |
| 244 | * method will still only be called due to an |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 245 | * explicit call to {@link #startService}. Even without that, though, |
| 246 | * this still provides you with access to the service object while the |
| 247 | * service is created. |
| 248 | * |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 249 | * <p>Note that prior to {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, |
| 250 | * not supplying this flag would also impact how important the system |
| 251 | * consider's the target service's process to be. When set, the only way |
| 252 | * for it to be raised was by binding from a service in which case it will |
| 253 | * only be important when that activity is in the foreground. Now to |
| 254 | * achieve this behavior you must explicitly supply the new flag |
| 255 | * {@link #BIND_ADJUST_WITH_ACTIVITY}. For compatibility, old applications |
| 256 | * that don't specify {@link #BIND_AUTO_CREATE} will automatically have |
| 257 | * the flags {@link #BIND_WAIVE_PRIORITY} and |
| 258 | * {@link #BIND_ADJUST_WITH_ACTIVITY} set for them in order to achieve |
| 259 | * the same result. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 260 | */ |
| 261 | public static final int BIND_AUTO_CREATE = 0x0001; |
| 262 | |
| 263 | /** |
| 264 | * Flag for {@link #bindService}: include debugging help for mismatched |
| 265 | * calls to unbind. When this flag is set, the callstack of the following |
| 266 | * {@link #unbindService} call is retained, to be printed if a later |
| 267 | * incorrect unbind call is made. Note that doing this requires retaining |
| 268 | * information about the binding that was made for the lifetime of the app, |
| 269 | * resulting in a leak -- this should only be used for debugging. |
| 270 | */ |
| 271 | public static final int BIND_DEBUG_UNBIND = 0x0002; |
| 272 | |
Dianne Hackborn | 09c916b | 2009-12-08 14:50:51 -0800 | [diff] [blame] | 273 | /** |
| 274 | * Flag for {@link #bindService}: don't allow this binding to raise |
| 275 | * the target service's process to the foreground scheduling priority. |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 276 | * It will still be raised to at least the same memory priority |
Dianne Hackborn | 09c916b | 2009-12-08 14:50:51 -0800 | [diff] [blame] | 277 | * as the client (so that its process will not be killable in any |
| 278 | * situation where the client is not killable), but for CPU scheduling |
| 279 | * purposes it may be left in the background. This only has an impact |
| 280 | * in the situation where the binding client is a foreground process |
| 281 | * and the target service is in a background process. |
| 282 | */ |
| 283 | public static final int BIND_NOT_FOREGROUND = 0x0004; |
| 284 | |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 285 | /** |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 286 | * Flag for {@link #bindService}: indicates that the client application |
| 287 | * binding to this service considers the service to be more important than |
| 288 | * 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] | 289 | * 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] | 290 | * this is not guaranteed to be the case. |
| 291 | */ |
| 292 | public static final int BIND_ABOVE_CLIENT = 0x0008; |
| 293 | |
| 294 | /** |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 295 | * Flag for {@link #bindService}: allow the process hosting the bound |
| 296 | * service to go through its normal memory management. It will be |
| 297 | * treated more like a running service, allowing the system to |
| 298 | * (temporarily) expunge the process if low on memory or for some other |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 299 | * whim it may have, and being more aggressive about making it a candidate |
| 300 | * to be killed (and restarted) if running for a long time. |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 301 | */ |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 302 | public static final int BIND_ALLOW_OOM_MANAGEMENT = 0x0010; |
| 303 | |
| 304 | /** |
| 305 | * Flag for {@link #bindService}: don't impact the scheduling or |
| 306 | * memory management priority of the target service's hosting process. |
| 307 | * Allows the service's process to be managed on the background LRU list |
| 308 | * just like a regular application process in the background. |
| 309 | */ |
| 310 | public static final int BIND_WAIVE_PRIORITY = 0x0020; |
| 311 | |
| 312 | /** |
| 313 | * Flag for {@link #bindService}: this service is very important to |
| 314 | * the client, so should be brought to the foreground process level |
| 315 | * when the client is. Normally a process can only be raised to the |
| 316 | * visibility level by a client, even if that client is in the foreground. |
| 317 | */ |
| 318 | public static final int BIND_IMPORTANT = 0x0040; |
| 319 | |
| 320 | /** |
| 321 | * Flag for {@link #bindService}: If binding from an activity, allow the |
| 322 | * target service's process importance to be raised based on whether the |
| 323 | * activity is visible to the user, regardless whether another flag is |
| 324 | * used to reduce the amount that the client process's overall importance |
| 325 | * is used to impact it. |
| 326 | */ |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 327 | public static final int BIND_ADJUST_WITH_ACTIVITY = 0x0080; |
| 328 | |
| 329 | /** |
Amith Yamasani | e5bfeee | 2018-09-05 18:52:35 -0700 | [diff] [blame] | 330 | * Flag for {@link #bindService}: If binding from something better than perceptible, |
| 331 | * still set the adjust below perceptible. This would be used for bound services that can |
| 332 | * afford to be evicted when under extreme memory pressure, but should be restarted as soon |
| 333 | * as possible. |
| 334 | * @hide |
| 335 | */ |
| 336 | public static final int BIND_ADJUST_BELOW_PERCEPTIBLE = 0x0100; |
| 337 | |
| 338 | /** |
Dianne Hackborn | c390aa8 | 2019-01-09 16:38:22 -0800 | [diff] [blame] | 339 | * @hide Flag for {@link #bindService}: the service being bound to represents a |
| 340 | * protected system component, so must have association restrictions applied to it. |
| 341 | * That is, a system config must have one or more allow-association tags limiting |
| 342 | * which packages it can interact with. If it does not have any such association |
| 343 | * restrictions, a default empty set will be created. |
| 344 | */ |
| 345 | public static final int BIND_RESTRICT_ASSOCIATIONS = 0x00200000; |
| 346 | |
| 347 | /** |
Svet Ganov | d223db3 | 2017-12-22 09:43:48 -0800 | [diff] [blame] | 348 | * @hide Flag for {@link #bindService}: allows binding to a service provided |
| 349 | * by an instant app. Note that the caller may not have access to the instant |
| 350 | * app providing the service which is a violation of the instant app sandbox. |
| 351 | * This flag is intended ONLY for development/testing and should be used with |
| 352 | * great care. Only the system is allowed to use this flag. |
| 353 | */ |
| 354 | public static final int BIND_ALLOW_INSTANT = 0x00400000; |
| 355 | |
| 356 | /** |
Dianne Hackborn | 83b40f6 | 2017-04-26 13:59:47 -0700 | [diff] [blame] | 357 | * @hide Flag for {@link #bindService}: like {@link #BIND_NOT_FOREGROUND}, but puts it |
| 358 | * up in to the important background state (instead of transient). |
| 359 | */ |
| 360 | public static final int BIND_IMPORTANT_BACKGROUND = 0x00800000; |
| 361 | |
| 362 | /** |
Felipe Leme | a1b79bf | 2016-05-24 13:06:54 -0700 | [diff] [blame] | 363 | * @hide Flag for {@link #bindService}: allows application hosting service to manage whitelists |
| 364 | * such as temporary allowing a {@code PendingIntent} to bypass Power Save mode. |
| 365 | */ |
| 366 | public static final int BIND_ALLOW_WHITELIST_MANAGEMENT = 0x01000000; |
| 367 | |
| 368 | /** |
Dianne Hackborn | d69e4c1 | 2015-04-24 09:54:54 -0700 | [diff] [blame] | 369 | * @hide Flag for {@link #bindService}: Like {@link #BIND_FOREGROUND_SERVICE}, |
| 370 | * but only applies while the device is awake. |
| 371 | */ |
| 372 | public static final int BIND_FOREGROUND_SERVICE_WHILE_AWAKE = 0x02000000; |
| 373 | |
| 374 | /** |
| 375 | * @hide Flag for {@link #bindService}: For only the case where the binding |
| 376 | * is coming from the system, set the process state to FOREGROUND_SERVICE |
| 377 | * instead of the normal maximum of IMPORTANT_FOREGROUND. That is, this is |
| 378 | * saying that the process shouldn't participate in the normal power reduction |
| 379 | * modes (removing network access etc). |
| 380 | */ |
| 381 | public static final int BIND_FOREGROUND_SERVICE = 0x04000000; |
| 382 | |
| 383 | /** |
Dianne Hackborn | f0f94d1 | 2014-03-17 16:04:21 -0700 | [diff] [blame] | 384 | * @hide Flag for {@link #bindService}: Treat the binding as hosting |
| 385 | * an activity, an unbinding as the activity going in the background. |
| 386 | * That is, when unbinding, the process when empty will go on the activity |
| 387 | * LRU list instead of the regular one, keeping it around more aggressively |
| 388 | * than it otherwise would be. This is intended for use with IMEs to try |
| 389 | * to keep IME processes around for faster keyboard switching. |
| 390 | */ |
| 391 | public static final int BIND_TREAT_LIKE_ACTIVITY = 0x08000000; |
| 392 | |
| 393 | /** |
Dianne Hackborn | b12e135 | 2012-09-26 11:39:20 -0700 | [diff] [blame] | 394 | * @hide An idea that is not yet implemented. |
| 395 | * Flag for {@link #bindService}: If binding from an activity, consider |
| 396 | * this service to be visible like the binding activity is. That is, |
| 397 | * it will be treated as something more important to keep around than |
| 398 | * invisible background activities. This will impact the number of |
| 399 | * recent activities the user can switch between without having them |
| 400 | * restart. There is no guarantee this will be respected, as the system |
| 401 | * tries to balance such requests from one app vs. the importantance of |
| 402 | * keeping other apps around. |
| 403 | */ |
Dianne Hackborn | c823051 | 2013-07-13 21:32:12 -0700 | [diff] [blame] | 404 | public static final int BIND_VISIBLE = 0x10000000; |
| 405 | |
| 406 | /** |
| 407 | * @hide |
| 408 | * Flag for {@link #bindService}: Consider this binding to be causing the target |
| 409 | * process to be showing UI, so it will be do a UI_HIDDEN memory trim when it goes |
| 410 | * away. |
| 411 | */ |
| 412 | public static final int BIND_SHOWING_UI = 0x20000000; |
Dianne Hackborn | b12e135 | 2012-09-26 11:39:20 -0700 | [diff] [blame] | 413 | |
| 414 | /** |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 415 | * Flag for {@link #bindService}: Don't consider the bound service to be |
| 416 | * visible, even if the caller is visible. |
| 417 | * @hide |
| 418 | */ |
| 419 | public static final int BIND_NOT_VISIBLE = 0x40000000; |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 420 | |
Alan Viverette | 713a5cd | 2015-12-16 15:46:32 -0500 | [diff] [blame] | 421 | /** |
Robert Sesek | b9a8666 | 2015-12-09 16:22:45 -0500 | [diff] [blame] | 422 | * Flag for {@link #bindService}: The service being bound is an |
| 423 | * {@link android.R.attr#isolatedProcess isolated}, |
| 424 | * {@link android.R.attr#externalService external} service. This binds the service into the |
| 425 | * 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] | 426 | * <p> |
| 427 | * When using this flag, the code for the service being bound will execute under the calling |
| 428 | * application's package name and user ID. Because the service must be an isolated process, |
| 429 | * it will not have direct access to the application's data, though. |
| 430 | * |
| 431 | * The purpose of this flag is to allow applications to provide services that are attributed |
| 432 | * to the app using the service, rather than the application providing the service. |
| 433 | * </p> |
Robert Sesek | b9a8666 | 2015-12-09 16:22:45 -0500 | [diff] [blame] | 434 | */ |
| 435 | public static final int BIND_EXTERNAL_SERVICE = 0x80000000; |
| 436 | |
Dianne Hackborn | a631d56 | 2018-11-20 15:58:15 -0800 | [diff] [blame] | 437 | /** |
| 438 | * These bind flags reduce the strength of the binding such that we shouldn't |
| 439 | * consider it as pulling the process up to the level of the one that is bound to it. |
| 440 | * @hide |
| 441 | */ |
| 442 | public static final int BIND_REDUCTION_FLAGS = |
| 443 | Context.BIND_ALLOW_OOM_MANAGEMENT | Context.BIND_WAIVE_PRIORITY |
| 444 | | Context.BIND_ADJUST_BELOW_PERCEPTIBLE | Context.BIND_NOT_VISIBLE; |
| 445 | |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 446 | /** @hide */ |
Jeff Sharkey | ce8db99 | 2017-12-13 20:05:05 -0700 | [diff] [blame] | 447 | @IntDef(flag = true, prefix = { "RECEIVER_VISIBLE_" }, value = { |
| 448 | RECEIVER_VISIBLE_TO_INSTANT_APPS |
| 449 | }) |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 450 | @Retention(RetentionPolicy.SOURCE) |
| 451 | public @interface RegisterReceiverFlags {} |
| 452 | |
| 453 | /** |
| 454 | * Flag for {@link #registerReceiver}: The receiver can receive broadcasts from Instant Apps. |
| 455 | */ |
| 456 | public static final int RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x1; |
| 457 | |
Robert Sesek | b9a8666 | 2015-12-09 16:22:45 -0500 | [diff] [blame] | 458 | /** |
Alan Viverette | 713a5cd | 2015-12-16 15:46:32 -0500 | [diff] [blame] | 459 | * Returns an AssetManager instance for the application's package. |
| 460 | * <p> |
| 461 | * <strong>Note:</strong> Implementations of this method should return |
| 462 | * an AssetManager instance that is consistent with the Resources instance |
| 463 | * returned by {@link #getResources()}. For example, they should share the |
| 464 | * same {@link Configuration} object. |
| 465 | * |
| 466 | * @return an AssetManager instance for the application's package |
| 467 | * @see #getResources() |
| 468 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 469 | public abstract AssetManager getAssets(); |
| 470 | |
Alan Viverette | 713a5cd | 2015-12-16 15:46:32 -0500 | [diff] [blame] | 471 | /** |
| 472 | * Returns a Resources instance for the application's package. |
| 473 | * <p> |
| 474 | * <strong>Note:</strong> Implementations of this method should return |
| 475 | * a Resources instance that is consistent with the AssetManager instance |
| 476 | * returned by {@link #getAssets()}. For example, they should share the |
| 477 | * same {@link Configuration} object. |
| 478 | * |
| 479 | * @return a Resources instance for the application's package |
| 480 | * @see #getAssets() |
| 481 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 482 | public abstract Resources getResources(); |
| 483 | |
| 484 | /** Return PackageManager instance to find global package information. */ |
| 485 | public abstract PackageManager getPackageManager(); |
| 486 | |
| 487 | /** Return a ContentResolver instance for your application's package. */ |
| 488 | public abstract ContentResolver getContentResolver(); |
| 489 | |
| 490 | /** |
| 491 | * Return the Looper for the main thread of the current process. This is |
| 492 | * the thread used to dispatch calls to application components (activities, |
| 493 | * services, etc). |
Jeff Brown | f9e989d | 2013-04-04 23:04:03 -0700 | [diff] [blame] | 494 | * <p> |
| 495 | * By definition, this method returns the same result as would be obtained |
| 496 | * by calling {@link Looper#getMainLooper() Looper.getMainLooper()}. |
| 497 | * </p> |
| 498 | * |
| 499 | * @return The main looper. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 500 | */ |
| 501 | public abstract Looper getMainLooper(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 502 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 503 | /** |
Jeff Sharkey | 8439ac0 | 2017-12-12 17:26:23 -0700 | [diff] [blame] | 504 | * Return an {@link Executor} that will run enqueued tasks on the main |
| 505 | * thread associated with this context. This is the thread used to dispatch |
| 506 | * calls to application components (activities, services, etc). |
| 507 | */ |
| 508 | public Executor getMainExecutor() { |
| 509 | // This is pretty inefficient, which is why ContextImpl overrides it |
| 510 | return new HandlerExecutor(new Handler(getMainLooper())); |
| 511 | } |
| 512 | |
| 513 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 514 | * Return the context of the single, global Application object of the |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 515 | * current process. This generally should only be used if you need a |
| 516 | * Context whose lifecycle is separate from the current context, that is |
| 517 | * tied to the lifetime of the process rather than the current component. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 518 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 519 | * <p>Consider for example how this interacts with |
Brad Fitzpatrick | 36af794 | 2010-12-08 11:31:07 -0800 | [diff] [blame] | 520 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter)}: |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 521 | * <ul> |
| 522 | * <li> <p>If used from an Activity context, the receiver is being registered |
| 523 | * within that activity. This means that you are expected to unregister |
| 524 | * before the activity is done being destroyed; in fact if you do not do |
| 525 | * so, the framework will clean up your leaked registration as it removes |
| 526 | * the activity and log an error. Thus, if you use the Activity context |
| 527 | * to register a receiver that is static (global to the process, not |
| 528 | * associated with an Activity instance) then that registration will be |
| 529 | * removed on you at whatever point the activity you used is destroyed. |
| 530 | * <li> <p>If used from the Context returned here, the receiver is being |
| 531 | * registered with the global state associated with your application. Thus |
| 532 | * it will never be unregistered for you. This is necessary if the receiver |
| 533 | * is associated with static data, not a particular component. However |
| 534 | * using the ApplicationContext elsewhere can easily lead to serious leaks |
| 535 | * if you forget to unregister, unbind, etc. |
| 536 | * </ul> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 537 | */ |
| 538 | public abstract Context getApplicationContext(); |
| 539 | |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 540 | /** Non-activity related autofill ids are unique in the app */ |
| 541 | private static int sLastAutofillId = View.NO_ID; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 542 | |
| 543 | /** |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 544 | * Gets the next autofill ID. |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 545 | * |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 546 | * <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] | 547 | * returned will be unique. |
| 548 | * |
| 549 | * @return A ID that is unique in the process |
| 550 | * |
| 551 | * {@hide} |
| 552 | */ |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 553 | public int getNextAutofillId() { |
| 554 | if (sLastAutofillId == View.LAST_APP_AUTOFILL_ID - 1) { |
| 555 | sLastAutofillId = View.NO_ID; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 556 | } |
| 557 | |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 558 | sLastAutofillId++; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 559 | |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 560 | return sLastAutofillId; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 561 | } |
| 562 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 563 | /** |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 564 | * Add a new {@link ComponentCallbacks} to the base application of the |
| 565 | * Context, which will be called at the same times as the ComponentCallbacks |
| 566 | * methods of activities and other components are called. Note that you |
| 567 | * <em>must</em> be sure to use {@link #unregisterComponentCallbacks} when |
| 568 | * appropriate in the future; this will not be removed for you. |
Dianne Hackborn | 905577f | 2011-09-07 18:31:28 -0700 | [diff] [blame] | 569 | * |
| 570 | * @param callback The interface to call. This can be either a |
| 571 | * {@link ComponentCallbacks} or {@link ComponentCallbacks2} interface. |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 572 | */ |
| 573 | public void registerComponentCallbacks(ComponentCallbacks callback) { |
| 574 | getApplicationContext().registerComponentCallbacks(callback); |
| 575 | } |
| 576 | |
| 577 | /** |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 578 | * Remove a {@link ComponentCallbacks} object that was previously registered |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 579 | * with {@link #registerComponentCallbacks(ComponentCallbacks)}. |
| 580 | */ |
| 581 | public void unregisterComponentCallbacks(ComponentCallbacks callback) { |
| 582 | getApplicationContext().unregisterComponentCallbacks(callback); |
| 583 | } |
| 584 | |
| 585 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 586 | * Return a localized, styled CharSequence from the application's package's |
| 587 | * default string table. |
| 588 | * |
| 589 | * @param resId Resource id for the CharSequence text |
| 590 | */ |
Chris Craik | ceb2693 | 2018-02-01 15:51:34 -0800 | [diff] [blame] | 591 | @NonNull |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 592 | public final CharSequence getText(@StringRes int resId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 593 | return getResources().getText(resId); |
| 594 | } |
| 595 | |
| 596 | /** |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 597 | * 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] | 598 | * default string table. |
| 599 | * |
| 600 | * @param resId Resource id for the string |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 601 | * @return The string data associated with the resource, stripped of styled |
| 602 | * text information. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 603 | */ |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 604 | @NonNull |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 605 | public final String getString(@StringRes int resId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 606 | return getResources().getString(resId); |
| 607 | } |
| 608 | |
| 609 | /** |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 610 | * 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] | 611 | * default string table, substituting the format arguments as defined in |
| 612 | * {@link java.util.Formatter} and {@link java.lang.String#format}. |
| 613 | * |
| 614 | * @param resId Resource id for the format string |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 615 | * @param formatArgs The format arguments that will be used for |
| 616 | * substitution. |
| 617 | * @return The string data associated with the resource, formatted and |
| 618 | * stripped of styled text information. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 619 | */ |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 620 | @NonNull |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 621 | public final String getString(@StringRes int resId, Object... formatArgs) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 622 | return getResources().getString(resId, formatArgs); |
| 623 | } |
| 624 | |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 625 | /** |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 626 | * Returns a color associated with a particular resource ID and styled for |
| 627 | * the current theme. |
| 628 | * |
| 629 | * @param id The desired resource identifier, as generated by the aapt |
| 630 | * tool. This integer encodes the package, type, and resource |
| 631 | * entry. The value 0 is an invalid identifier. |
| 632 | * @return A single color value in the form 0xAARRGGBB. |
| 633 | * @throws android.content.res.Resources.NotFoundException if the given ID |
| 634 | * does not exist. |
| 635 | */ |
Tor Norbye | 3e4cda7 | 2015-06-10 08:14:31 -0700 | [diff] [blame] | 636 | @ColorInt |
| 637 | public final int getColor(@ColorRes int id) { |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 638 | return getResources().getColor(id, getTheme()); |
| 639 | } |
| 640 | |
| 641 | /** |
| 642 | * Returns a drawable object associated with a particular resource ID and |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 643 | * styled for the current theme. |
| 644 | * |
| 645 | * @param id The desired resource identifier, as generated by the aapt |
| 646 | * tool. This integer encodes the package, type, and resource |
| 647 | * entry. The value 0 is an invalid identifier. |
Chris Craik | ceb2693 | 2018-02-01 15:51:34 -0800 | [diff] [blame] | 648 | * @return An object that can be used to draw this resource. |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 649 | * @throws android.content.res.Resources.NotFoundException if the given ID |
| 650 | * does not exist. |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 651 | */ |
Chris Craik | 1194b0b | 2018-03-23 13:36:24 -0700 | [diff] [blame] | 652 | @Nullable |
Tor Norbye | 3e4cda7 | 2015-06-10 08:14:31 -0700 | [diff] [blame] | 653 | public final Drawable getDrawable(@DrawableRes int id) { |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 654 | return getResources().getDrawable(id, getTheme()); |
| 655 | } |
| 656 | |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 657 | /** |
| 658 | * Returns a color state list associated with a particular resource ID and |
| 659 | * styled for the current theme. |
| 660 | * |
| 661 | * @param id The desired resource identifier, as generated by the aapt |
| 662 | * tool. This integer encodes the package, type, and resource |
| 663 | * entry. The value 0 is an invalid identifier. |
Chris Craik | ceb2693 | 2018-02-01 15:51:34 -0800 | [diff] [blame] | 664 | * @return A color state list. |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 665 | * @throws android.content.res.Resources.NotFoundException if the given ID |
| 666 | * does not exist. |
| 667 | */ |
Chris Craik | ceb2693 | 2018-02-01 15:51:34 -0800 | [diff] [blame] | 668 | @NonNull |
Tor Norbye | 3e4cda7 | 2015-06-10 08:14:31 -0700 | [diff] [blame] | 669 | public final ColorStateList getColorStateList(@ColorRes int id) { |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 670 | return getResources().getColorStateList(id, getTheme()); |
| 671 | } |
| 672 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 673 | /** |
| 674 | * Set the base theme for this context. Note that this should be called |
| 675 | * before any views are instantiated in the Context (for example before |
| 676 | * calling {@link android.app.Activity#setContentView} or |
| 677 | * {@link android.view.LayoutInflater#inflate}). |
| 678 | * |
| 679 | * @param resid The style resource describing the theme. |
| 680 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 681 | public abstract void setTheme(@StyleRes int resid); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 682 | |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 683 | /** @hide Needed for some internal implementation... not public because |
| 684 | * you can't assume this actually means anything. */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 685 | @UnsupportedAppUsage |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 686 | public int getThemeResId() { |
| 687 | return 0; |
| 688 | } |
| 689 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 690 | /** |
| 691 | * Return the Theme object associated with this Context. |
| 692 | */ |
Jon Miranda | 836c0a8 | 2014-08-11 12:32:26 -0700 | [diff] [blame] | 693 | @ViewDebug.ExportedProperty(deepExport = true) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 694 | public abstract Resources.Theme getTheme(); |
| 695 | |
| 696 | /** |
| 697 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 698 | * {@link android.content.res.Resources.Theme#obtainStyledAttributes(int[])} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 699 | * for more information. |
| 700 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 701 | * @see android.content.res.Resources.Theme#obtainStyledAttributes(int[]) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 702 | */ |
Aurimas Liutikas | 77acf4b | 2018-12-19 17:31:03 -0800 | [diff] [blame] | 703 | @NonNull |
| 704 | public final TypedArray obtainStyledAttributes(@NonNull @StyleableRes int[] attrs) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 705 | return getTheme().obtainStyledAttributes(attrs); |
| 706 | } |
| 707 | |
| 708 | /** |
| 709 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 710 | * {@link android.content.res.Resources.Theme#obtainStyledAttributes(int, int[])} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 711 | * for more information. |
| 712 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 713 | * @see android.content.res.Resources.Theme#obtainStyledAttributes(int, int[]) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 714 | */ |
Aurimas Liutikas | 77acf4b | 2018-12-19 17:31:03 -0800 | [diff] [blame] | 715 | @NonNull |
| 716 | public final TypedArray obtainStyledAttributes(@StyleRes int resid, |
| 717 | @NonNull @StyleableRes int[] attrs) throws Resources.NotFoundException { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 718 | return getTheme().obtainStyledAttributes(resid, attrs); |
| 719 | } |
| 720 | |
| 721 | /** |
| 722 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 723 | * {@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] | 724 | * for more information. |
| 725 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 726 | * @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] | 727 | */ |
Aurimas Liutikas | 77acf4b | 2018-12-19 17:31:03 -0800 | [diff] [blame] | 728 | @NonNull |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 729 | public final TypedArray obtainStyledAttributes( |
Aurimas Liutikas | 77acf4b | 2018-12-19 17:31:03 -0800 | [diff] [blame] | 730 | @Nullable AttributeSet set, @NonNull @StyleableRes int[] attrs) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 731 | return getTheme().obtainStyledAttributes(set, attrs, 0, 0); |
| 732 | } |
| 733 | |
| 734 | /** |
| 735 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 736 | * {@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] | 737 | * for more information. |
| 738 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 739 | * @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] | 740 | */ |
Aurimas Liutikas | 77acf4b | 2018-12-19 17:31:03 -0800 | [diff] [blame] | 741 | @NonNull |
| 742 | public final TypedArray obtainStyledAttributes(@Nullable AttributeSet set, |
| 743 | @NonNull @StyleableRes int[] attrs, @AttrRes int defStyleAttr, |
Tor Norbye | c91531a | 2015-04-01 17:41:55 -0700 | [diff] [blame] | 744 | @StyleRes int defStyleRes) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 745 | return getTheme().obtainStyledAttributes( |
| 746 | set, attrs, defStyleAttr, defStyleRes); |
| 747 | } |
| 748 | |
| 749 | /** |
| 750 | * Return a class loader you can use to retrieve classes in this package. |
| 751 | */ |
| 752 | public abstract ClassLoader getClassLoader(); |
| 753 | |
| 754 | /** Return the name of this application's package. */ |
| 755 | public abstract String getPackageName(); |
| 756 | |
Jaewan Kim | 0980c7f | 2018-11-28 23:55:15 +0900 | [diff] [blame] | 757 | /** |
| 758 | * @hide Return the name of the base context this context is derived from. |
| 759 | * This is the same as {@link #getOpPackageName()} except in |
| 760 | * cases where system components are loaded into other app processes, in which |
| 761 | * case {@link #getOpPackageName()} will be the name of the primary package in |
| 762 | * that process (so that app ops uid verification will work with the name). |
| 763 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 764 | @UnsupportedAppUsage |
Dianne Hackborn | d8e1dbb | 2013-01-17 17:47:37 -0800 | [diff] [blame] | 765 | public abstract String getBasePackageName(); |
| 766 | |
Jaewan Kim | 0980c7f | 2018-11-28 23:55:15 +0900 | [diff] [blame] | 767 | /** |
| 768 | * Return the package name that should be used for {@link android.app.AppOpsManager} calls from |
| 769 | * this context, so that app ops manager's uid verification will work with the name. |
| 770 | * <p> |
| 771 | * This is not generally intended for third party application developers. |
| 772 | */ |
Adrian Roos | fe6aeaf | 2019-01-22 16:58:56 +0100 | [diff] [blame] | 773 | public String getOpPackageName() { |
| 774 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 775 | } |
Dianne Hackborn | 95d7853 | 2013-09-11 09:51:14 -0700 | [diff] [blame] | 776 | |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 777 | /** Return the full application info for this context's package. */ |
| 778 | public abstract ApplicationInfo getApplicationInfo(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 779 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 780 | /** |
Kenny Root | 3214839 | 2010-01-21 15:40:47 -0800 | [diff] [blame] | 781 | * Return the full path to this context's primary Android package. |
| 782 | * The Android package is a ZIP file which contains the application's |
| 783 | * primary resources. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 784 | * |
| 785 | * <p>Note: this is not generally useful for applications, since they should |
| 786 | * not be directly accessing the file system. |
| 787 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 788 | * @return String Path to the resources. |
| 789 | */ |
| 790 | public abstract String getPackageResourcePath(); |
| 791 | |
| 792 | /** |
Kenny Root | 3214839 | 2010-01-21 15:40:47 -0800 | [diff] [blame] | 793 | * Return the full path to this context's primary Android package. |
| 794 | * The Android package is a ZIP file which contains application's |
| 795 | * primary code and assets. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 796 | * |
| 797 | * <p>Note: this is not generally useful for applications, since they should |
| 798 | * not be directly accessing the file system. |
| 799 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 800 | * @return String Path to the code and assets. |
| 801 | */ |
| 802 | public abstract String getPackageCodePath(); |
| 803 | |
| 804 | /** |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 805 | * @hide |
| 806 | * @deprecated use {@link #getSharedPreferencesPath(String)} |
Joe Onorato | 23ecae3 | 2009-06-10 17:07:15 -0700 | [diff] [blame] | 807 | */ |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 808 | @Deprecated |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 809 | @UnsupportedAppUsage |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 810 | public File getSharedPrefsFile(String name) { |
| 811 | return getSharedPreferencesPath(name); |
| 812 | } |
Joe Onorato | 23ecae3 | 2009-06-10 17:07:15 -0700 | [diff] [blame] | 813 | |
| 814 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 815 | * Retrieve and hold the contents of the preferences file 'name', returning |
| 816 | * a SharedPreferences through which you can retrieve and modify its |
| 817 | * values. Only one instance of the SharedPreferences object is returned |
| 818 | * to any callers for the same name, meaning they will see each other's |
| 819 | * edits as soon as they are made. |
| 820 | * |
Jonathan Dormody | 1bca5db | 2017-11-16 11:25:20 -0700 | [diff] [blame] | 821 | * This method is thead-safe. |
| 822 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 823 | * @param name Desired preferences file. If a preferences file by this name |
| 824 | * does not exist, it will be created when you retrieve an |
| 825 | * editor (SharedPreferences.edit()) and then commit changes (Editor.commit()). |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 826 | * @param mode Operating mode. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 827 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 828 | * @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] | 829 | * to retrieve and modify the preference values. |
| 830 | * |
| 831 | * @see #MODE_PRIVATE |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 832 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 833 | public abstract SharedPreferences getSharedPreferences(String name, @PreferencesMode int mode); |
Jeff Sharkey | 8fc29cf | 2015-11-30 17:51:00 -0700 | [diff] [blame] | 834 | |
| 835 | /** |
| 836 | * Retrieve and hold the contents of the preferences file, returning |
| 837 | * a SharedPreferences through which you can retrieve and modify its |
| 838 | * values. Only one instance of the SharedPreferences object is returned |
| 839 | * to any callers for the same name, meaning they will see each other's |
| 840 | * edits as soon as they are made. |
| 841 | * |
| 842 | * @param file Desired preferences file. If a preferences file by this name |
| 843 | * does not exist, it will be created when you retrieve an |
| 844 | * editor (SharedPreferences.edit()) and then commit changes (Editor.commit()). |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 845 | * @param mode Operating mode. |
Jeff Sharkey | 8fc29cf | 2015-11-30 17:51:00 -0700 | [diff] [blame] | 846 | * |
| 847 | * @return The single {@link SharedPreferences} instance that can be used |
| 848 | * to retrieve and modify the preference values. |
| 849 | * |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 850 | * @see #getSharedPreferencesPath(String) |
Jeff Sharkey | 8fc29cf | 2015-11-30 17:51:00 -0700 | [diff] [blame] | 851 | * @see #MODE_PRIVATE |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 852 | * @removed |
Jeff Sharkey | 8fc29cf | 2015-11-30 17:51:00 -0700 | [diff] [blame] | 853 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 854 | public abstract SharedPreferences getSharedPreferences(File file, @PreferencesMode int mode); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 855 | |
| 856 | /** |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 857 | * Move an existing shared preferences file from the given source storage |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 858 | * context to this context. This is typically used to migrate data between |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 859 | * storage locations after an upgrade, such as moving to device protected |
| 860 | * storage. |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 861 | * |
| 862 | * @param sourceContext The source context which contains the existing |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 863 | * shared preferences to move. |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 864 | * @param name The name of the shared preferences file. |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 865 | * @return {@code true} if the move was successful or if the shared |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 866 | * preferences didn't exist in the source context, otherwise |
| 867 | * {@code false}. |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 868 | * @see #createDeviceProtectedStorageContext() |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 869 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 870 | public abstract boolean moveSharedPreferencesFrom(Context sourceContext, String name); |
| 871 | |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 872 | /** |
| 873 | * Delete an existing shared preferences file. |
| 874 | * |
| 875 | * @param name The name (unique in the application package) of the shared |
| 876 | * preferences file. |
| 877 | * @return {@code true} if the shared preferences file was successfully |
| 878 | * deleted; else {@code false}. |
| 879 | * @see #getSharedPreferences(String, int) |
| 880 | */ |
| 881 | public abstract boolean deleteSharedPreferences(String name); |
| 882 | |
Christopher Tate | fe2368c | 2017-05-17 15:42:35 -0700 | [diff] [blame] | 883 | /** @hide */ |
| 884 | public abstract void reloadSharedPreferences(); |
| 885 | |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 886 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 887 | * Open a private file associated with this Context's application package |
| 888 | * for reading. |
| 889 | * |
| 890 | * @param name The name of the file to open; can not contain path |
| 891 | * separators. |
| 892 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 893 | * @return The resulting {@link FileInputStream}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 894 | * |
| 895 | * @see #openFileOutput |
| 896 | * @see #fileList |
| 897 | * @see #deleteFile |
| 898 | * @see java.io.FileInputStream#FileInputStream(String) |
| 899 | */ |
| 900 | public abstract FileInputStream openFileInput(String name) |
| 901 | throws FileNotFoundException; |
| 902 | |
| 903 | /** |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 904 | * Open a private file associated with this Context's application package |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 905 | * for writing. Creates the file if it doesn't already exist. |
| 906 | * <p> |
| 907 | * No additional permissions are required for the calling app to read or |
| 908 | * write the returned file. |
Ricardo Cervera | 90a5f98 | 2014-04-04 10:26:05 -0700 | [diff] [blame] | 909 | * |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 910 | * @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] | 911 | * separators. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 912 | * @param mode Operating mode. |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 913 | * @return The resulting {@link FileOutputStream}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 914 | * @see #MODE_APPEND |
| 915 | * @see #MODE_PRIVATE |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 916 | * @see #openFileInput |
| 917 | * @see #fileList |
| 918 | * @see #deleteFile |
| 919 | * @see java.io.FileOutputStream#FileOutputStream(String) |
| 920 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 921 | public abstract FileOutputStream openFileOutput(String name, @FileMode int mode) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 922 | throws FileNotFoundException; |
| 923 | |
| 924 | /** |
| 925 | * Delete the given private file associated with this Context's |
| 926 | * application package. |
| 927 | * |
| 928 | * @param name The name of the file to delete; can not contain path |
| 929 | * separators. |
| 930 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 931 | * @return {@code true} if the file was successfully deleted; else |
| 932 | * {@code false}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 933 | * |
| 934 | * @see #openFileInput |
| 935 | * @see #openFileOutput |
| 936 | * @see #fileList |
| 937 | * @see java.io.File#delete() |
| 938 | */ |
| 939 | public abstract boolean deleteFile(String name); |
| 940 | |
| 941 | /** |
| 942 | * Returns the absolute path on the filesystem where a file created with |
| 943 | * {@link #openFileOutput} is stored. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 944 | * <p> |
| 945 | * The returned path may change over time if the calling app is moved to an |
| 946 | * 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] | 947 | * |
| 948 | * @param name The name of the file for which you would like to get |
| 949 | * its path. |
| 950 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 951 | * @return An absolute path to the given file. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 952 | * |
| 953 | * @see #openFileOutput |
| 954 | * @see #getFilesDir |
| 955 | * @see #getDir |
| 956 | */ |
| 957 | public abstract File getFileStreamPath(String name); |
| 958 | |
| 959 | /** |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 960 | * Returns the absolute path on the filesystem where a file created with |
| 961 | * {@link #getSharedPreferences(String, int)} is stored. |
| 962 | * <p> |
| 963 | * The returned path may change over time if the calling app is moved to an |
| 964 | * adopted storage device, so only relative paths should be persisted. |
| 965 | * |
| 966 | * @param name The name of the shared preferences for which you would like |
| 967 | * to get a path. |
| 968 | * @return An absolute path to the given file. |
| 969 | * @see #getSharedPreferences(String, int) |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 970 | * @removed |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 971 | */ |
| 972 | public abstract File getSharedPreferencesPath(String name); |
| 973 | |
| 974 | /** |
Jeff Sharkey | 2c1ba9a | 2016-02-17 15:29:38 -0700 | [diff] [blame] | 975 | * Returns the absolute path to the directory on the filesystem where all |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 976 | * private files belonging to this app are stored. Apps should not use this |
| 977 | * path directly; they should instead use {@link #getFilesDir()}, |
| 978 | * {@link #getCacheDir()}, {@link #getDir(String, int)}, or other storage |
| 979 | * APIs on this class. |
Jeff Sharkey | 2c1ba9a | 2016-02-17 15:29:38 -0700 | [diff] [blame] | 980 | * <p> |
| 981 | * The returned path may change over time if the calling app is moved to an |
| 982 | * adopted storage device, so only relative paths should be persisted. |
| 983 | * <p> |
| 984 | * No additional permissions are required for the calling app to read or |
| 985 | * write files under the returned path. |
| 986 | * |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 987 | * @see ApplicationInfo#dataDir |
Jeff Sharkey | 2c1ba9a | 2016-02-17 15:29:38 -0700 | [diff] [blame] | 988 | */ |
| 989 | public abstract File getDataDir(); |
| 990 | |
| 991 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 992 | * Returns the absolute path to the directory on the filesystem where files |
| 993 | * created with {@link #openFileOutput} are stored. |
| 994 | * <p> |
| 995 | * The returned path may change over time if the calling app is moved to an |
| 996 | * adopted storage device, so only relative paths should be persisted. |
| 997 | * <p> |
| 998 | * No additional permissions are required for the calling app to read or |
| 999 | * write files under the returned path. |
Ricardo Cervera | 90a5f98 | 2014-04-04 10:26:05 -0700 | [diff] [blame] | 1000 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1001 | * @return The path of the directory holding application files. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1002 | * @see #openFileOutput |
| 1003 | * @see #getFileStreamPath |
| 1004 | * @see #getDir |
| 1005 | */ |
| 1006 | public abstract File getFilesDir(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1007 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1008 | /** |
Christopher Tate | a7835b6 | 2014-07-11 17:25:57 -0700 | [diff] [blame] | 1009 | * Returns the absolute path to the directory on the filesystem similar to |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1010 | * {@link #getFilesDir()}. The difference is that files placed under this |
| 1011 | * directory will be excluded from automatic backup to remote storage. See |
Christopher Tate | a7835b6 | 2014-07-11 17:25:57 -0700 | [diff] [blame] | 1012 | * {@link android.app.backup.BackupAgent BackupAgent} for a full discussion |
| 1013 | * of the automatic backup mechanism in Android. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1014 | * <p> |
| 1015 | * The returned path may change over time if the calling app is moved to an |
| 1016 | * adopted storage device, so only relative paths should be persisted. |
| 1017 | * <p> |
| 1018 | * No additional permissions are required for the calling app to read or |
| 1019 | * write files under the returned path. |
Christopher Tate | a7835b6 | 2014-07-11 17:25:57 -0700 | [diff] [blame] | 1020 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1021 | * @return The path of the directory holding application files that will not |
| 1022 | * be automatically backed up to remote storage. |
Christopher Tate | a7835b6 | 2014-07-11 17:25:57 -0700 | [diff] [blame] | 1023 | * @see #openFileOutput |
| 1024 | * @see #getFileStreamPath |
| 1025 | * @see #getDir |
| 1026 | * @see android.app.backup.BackupAgent |
| 1027 | */ |
| 1028 | public abstract File getNoBackupFilesDir(); |
| 1029 | |
| 1030 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1031 | * Returns the absolute path to the directory on the primary shared/external |
| 1032 | * storage device where the application can place persistent files it owns. |
| 1033 | * These files are internal to the applications, and not typically visible |
| 1034 | * to the user as media. |
| 1035 | * <p> |
| 1036 | * This is like {@link #getFilesDir()} in that these files will be deleted |
| 1037 | * when the application is uninstalled, however there are some important |
| 1038 | * differences: |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1039 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1040 | * <li>Shared storage may not always be available, since removable media can |
| 1041 | * be ejected by the user. Media state can be checked using |
| 1042 | * {@link Environment#getExternalStorageState(File)}. |
| 1043 | * <li>There is no security enforced with these files. For example, any |
| 1044 | * application holding |
| 1045 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1046 | * these files. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1047 | * </ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1048 | * <p> |
| 1049 | * If a shared storage device is emulated (as determined by |
| 1050 | * {@link Environment#isExternalStorageEmulated(File)}), it's contents are |
| 1051 | * backed by a private user data partition, which means there is little |
| 1052 | * benefit to storing data here instead of the private directories returned |
| 1053 | * by {@link #getFilesDir()}, etc. |
| 1054 | * <p> |
| 1055 | * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1056 | * 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] | 1057 | * accessible to the calling app. This only applies to paths generated for |
| 1058 | * package name of the calling application. To access paths belonging to |
| 1059 | * other packages, |
| 1060 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} and/or |
| 1061 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} are required. |
| 1062 | * <p> |
| 1063 | * On devices with multiple users (as described by {@link UserManager}), |
| 1064 | * each user has their own isolated shared storage. Applications only have |
| 1065 | * access to the shared storage for the user they're running as. |
| 1066 | * <p> |
| 1067 | * The returned path may change over time if different shared storage media |
| 1068 | * is inserted, so only relative paths should be persisted. |
| 1069 | * <p> |
| 1070 | * Here is an example of typical code to manipulate a file in an |
| 1071 | * application's shared storage: |
| 1072 | * </p> |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1073 | * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java |
| 1074 | * private_file} |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1075 | * <p> |
| 1076 | * If you supply a non-null <var>type</var> to this function, the returned |
| 1077 | * file will be a path to a sub-directory of the given type. Though these |
| 1078 | * files are not automatically scanned by the media scanner, you can |
| 1079 | * explicitly add them to the media database with |
| 1080 | * {@link android.media.MediaScannerConnection#scanFile(Context, String[], String[], android.media.MediaScannerConnection.OnScanCompletedListener) |
| 1081 | * MediaScannerConnection.scanFile}. Note that this is not the same as |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1082 | * {@link android.os.Environment#getExternalStoragePublicDirectory |
| 1083 | * Environment.getExternalStoragePublicDirectory()}, which provides |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1084 | * directories of media shared by all applications. The directories returned |
| 1085 | * here are owned by the application, and their contents will be removed |
| 1086 | * when the application is uninstalled. Unlike |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1087 | * {@link android.os.Environment#getExternalStoragePublicDirectory |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1088 | * Environment.getExternalStoragePublicDirectory()}, the directory returned |
| 1089 | * here will be automatically created for you. |
| 1090 | * <p> |
| 1091 | * Here is an example of typical code to manipulate a picture in an |
| 1092 | * application's shared storage and add it to the media database: |
| 1093 | * </p> |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1094 | * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java |
| 1095 | * private_picture} |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 1096 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1097 | * @param type The type of files directory to return. May be {@code null} |
| 1098 | * for the root of the files directory or one of the following |
| 1099 | * constants for a subdirectory: |
| 1100 | * {@link android.os.Environment#DIRECTORY_MUSIC}, |
| 1101 | * {@link android.os.Environment#DIRECTORY_PODCASTS}, |
| 1102 | * {@link android.os.Environment#DIRECTORY_RINGTONES}, |
| 1103 | * {@link android.os.Environment#DIRECTORY_ALARMS}, |
| 1104 | * {@link android.os.Environment#DIRECTORY_NOTIFICATIONS}, |
| 1105 | * {@link android.os.Environment#DIRECTORY_PICTURES}, or |
| 1106 | * {@link android.os.Environment#DIRECTORY_MOVIES}. |
| 1107 | * @return the absolute path to application-specific directory. May return |
| 1108 | * {@code null} if shared storage is not currently available. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1109 | * @see #getFilesDir |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1110 | * @see #getExternalFilesDirs(String) |
| 1111 | * @see Environment#getExternalStorageState(File) |
| 1112 | * @see Environment#isExternalStorageEmulated(File) |
| 1113 | * @see Environment#isExternalStorageRemovable(File) |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1114 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1115 | @Nullable |
| 1116 | public abstract File getExternalFilesDir(@Nullable String type); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1117 | |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1118 | /** |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1119 | * Returns absolute paths to application-specific directories on all |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1120 | * shared/external storage devices where the application can place |
| 1121 | * persistent files it owns. These files are internal to the application, |
| 1122 | * and not typically visible to the user as media. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1123 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1124 | * This is like {@link #getFilesDir()} in that these files will be deleted |
| 1125 | * when the application is uninstalled, however there are some important |
| 1126 | * differences: |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1127 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1128 | * <li>Shared storage may not always be available, since removable media can |
| 1129 | * be ejected by the user. Media state can be checked using |
| 1130 | * {@link Environment#getExternalStorageState(File)}. |
| 1131 | * <li>There is no security enforced with these files. For example, any |
| 1132 | * application holding |
| 1133 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 1134 | * these files. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1135 | * </ul> |
| 1136 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1137 | * If a shared storage device is emulated (as determined by |
| 1138 | * {@link Environment#isExternalStorageEmulated(File)}), it's contents are |
| 1139 | * backed by a private user data partition, which means there is little |
| 1140 | * benefit to storing data here instead of the private directories returned |
| 1141 | * by {@link #getFilesDir()}, etc. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1142 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1143 | * Shared storage devices returned here are considered a stable part of the |
| 1144 | * device, including physical media slots under a protective cover. The |
| 1145 | * returned paths do not include transient devices, such as USB flash drives |
| 1146 | * connected to handheld devices. |
| 1147 | * <p> |
| 1148 | * 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] | 1149 | * example, an app may choose to store large files on the device with the |
| 1150 | * most available space, as measured by {@link StatFs}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1151 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1152 | * No additional permissions are required for the calling app to read or |
| 1153 | * write files under the returned path. Write access outside of these paths |
| 1154 | * on secondary external storage devices is not available. |
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 | * The returned path may change over time if different shared storage media |
| 1157 | * is inserted, so only relative paths should be persisted. |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 1158 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1159 | * @param type The type of files directory to return. May be {@code null} |
| 1160 | * for the root of the files directory or one of the following |
| 1161 | * constants for a subdirectory: |
| 1162 | * {@link android.os.Environment#DIRECTORY_MUSIC}, |
| 1163 | * {@link android.os.Environment#DIRECTORY_PODCASTS}, |
| 1164 | * {@link android.os.Environment#DIRECTORY_RINGTONES}, |
| 1165 | * {@link android.os.Environment#DIRECTORY_ALARMS}, |
| 1166 | * {@link android.os.Environment#DIRECTORY_NOTIFICATIONS}, |
| 1167 | * {@link android.os.Environment#DIRECTORY_PICTURES}, or |
| 1168 | * {@link android.os.Environment#DIRECTORY_MOVIES}. |
| 1169 | * @return the absolute paths to application-specific directories. Some |
| 1170 | * individual paths may be {@code null} if that shared storage is |
| 1171 | * not currently available. The first path returned is the same as |
| 1172 | * {@link #getExternalFilesDir(String)}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1173 | * @see #getExternalFilesDir(String) |
Jeff Sharkey | 4ca728c | 2014-01-10 16:27:19 -0800 | [diff] [blame] | 1174 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1175 | * @see Environment#isExternalStorageEmulated(File) |
| 1176 | * @see Environment#isExternalStorageRemovable(File) |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1177 | */ |
| 1178 | public abstract File[] getExternalFilesDirs(String type); |
| 1179 | |
| 1180 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1181 | * Return the primary shared/external storage directory where this |
| 1182 | * application's OBB files (if there are any) can be found. Note if the |
| 1183 | * application does not have any OBB files, this directory may not exist. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1184 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1185 | * This is like {@link #getFilesDir()} in that these files will be deleted |
| 1186 | * when the application is uninstalled, however there are some important |
| 1187 | * differences: |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1188 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1189 | * <li>Shared storage may not always be available, since removable media can |
| 1190 | * be ejected by the user. Media state can be checked using |
| 1191 | * {@link Environment#getExternalStorageState(File)}. |
| 1192 | * <li>There is no security enforced with these files. For example, any |
| 1193 | * application holding |
| 1194 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1195 | * these files. |
| 1196 | * </ul> |
| 1197 | * <p> |
| 1198 | * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions |
Dave Friedman | cfe5088 | 2017-07-05 00:40:07 -0700 | [diff] [blame] | 1199 | * are required to read or write to the path that this method returns. |
| 1200 | * However, starting from {@link android.os.Build.VERSION_CODES#M}, |
| 1201 | * to read the OBB expansion files, you must declare the |
| 1202 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} permission in the app manifest and ask for |
| 1203 | * permission at runtime as follows: |
| 1204 | * </p> |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1205 | * <p> |
Dave Friedman | cfe5088 | 2017-07-05 00:40:07 -0700 | [diff] [blame] | 1206 | * {@code <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" |
| 1207 | * android:maxSdkVersion="23" />} |
| 1208 | * </p> |
| 1209 | * <p> |
| 1210 | * Starting from {@link android.os.Build.VERSION_CODES#N}, |
| 1211 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} |
| 1212 | * permission is not required, so don’t ask for this |
| 1213 | * permission at runtime. To handle both cases, your app must first try to read the OBB file, |
| 1214 | * and if it fails, you must request |
| 1215 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} permission at runtime. |
| 1216 | * </p> |
| 1217 | * |
| 1218 | * <p> |
| 1219 | * The following code snippet shows how to do this: |
| 1220 | * </p> |
| 1221 | * |
| 1222 | * <pre> |
| 1223 | * File obb = new File(obb_filename); |
| 1224 | * boolean open_failed = false; |
| 1225 | * |
| 1226 | * try { |
| 1227 | * BufferedReader br = new BufferedReader(new FileReader(obb)); |
| 1228 | * open_failed = false; |
| 1229 | * ReadObbFile(br); |
| 1230 | * } catch (IOException e) { |
| 1231 | * open_failed = true; |
| 1232 | * } |
| 1233 | * |
| 1234 | * if (open_failed) { |
| 1235 | * // request READ_EXTERNAL_STORAGE permission before reading OBB file |
| 1236 | * ReadObbFileWithPermission(); |
| 1237 | * } |
| 1238 | * </pre> |
| 1239 | * |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1240 | * On devices with multiple users (as described by {@link UserManager}), |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 1241 | * multiple users may share the same OBB storage location. Applications |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1242 | * should ensure that multiple instances running under different users don't |
| 1243 | * interfere with each other. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1244 | * |
| 1245 | * @return the absolute path to application-specific directory. May return |
| 1246 | * {@code null} if shared storage is not currently available. |
| 1247 | * @see #getObbDirs() |
| 1248 | * @see Environment#getExternalStorageState(File) |
| 1249 | * @see Environment#isExternalStorageEmulated(File) |
| 1250 | * @see Environment#isExternalStorageRemovable(File) |
Dianne Hackborn | 805fd7e | 2011-01-16 18:30:29 -0800 | [diff] [blame] | 1251 | */ |
| 1252 | public abstract File getObbDir(); |
| 1253 | |
| 1254 | /** |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1255 | * Returns absolute paths to application-specific directories on all |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1256 | * shared/external storage devices where the application's OBB files (if |
| 1257 | * there are any) can be found. Note if the application does not have any |
| 1258 | * OBB files, these directories may not exist. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1259 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1260 | * This is like {@link #getFilesDir()} in that these files will be deleted |
| 1261 | * when the application is uninstalled, however there are some important |
| 1262 | * differences: |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1263 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1264 | * <li>Shared storage may not always be available, since removable media can |
| 1265 | * be ejected by the user. Media state can be checked using |
| 1266 | * {@link Environment#getExternalStorageState(File)}. |
| 1267 | * <li>There is no security enforced with these files. For example, any |
| 1268 | * application holding |
| 1269 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 1270 | * these files. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1271 | * </ul> |
| 1272 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1273 | * Shared storage devices returned here are considered a stable part of the |
| 1274 | * device, including physical media slots under a protective cover. The |
| 1275 | * returned paths do not include transient devices, such as USB flash drives |
| 1276 | * connected to handheld devices. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1277 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1278 | * 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] | 1279 | * example, an app may choose to store large files on the device with the |
| 1280 | * most available space, as measured by {@link StatFs}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1281 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1282 | * No additional permissions are required for the calling app to read or |
| 1283 | * write files under the returned path. Write access outside of these paths |
| 1284 | * on secondary external storage devices is not available. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1285 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1286 | * @return the absolute paths to application-specific directories. Some |
| 1287 | * individual paths may be {@code null} if that shared storage is |
| 1288 | * not currently available. The first path returned is the same as |
| 1289 | * {@link #getObbDir()} |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1290 | * @see #getObbDir() |
Jeff Sharkey | 4ca728c | 2014-01-10 16:27:19 -0800 | [diff] [blame] | 1291 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1292 | * @see Environment#isExternalStorageEmulated(File) |
| 1293 | * @see Environment#isExternalStorageRemovable(File) |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1294 | */ |
| 1295 | public abstract File[] getObbDirs(); |
| 1296 | |
| 1297 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1298 | * Returns the absolute path to the application specific cache directory on |
Jeff Sharkey | 60a82cd | 2017-04-18 18:19:16 -0600 | [diff] [blame] | 1299 | * the filesystem. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1300 | * <p> |
Jeff Sharkey | 60a82cd | 2017-04-18 18:19:16 -0600 | [diff] [blame] | 1301 | * The system will automatically delete files in this directory as disk |
| 1302 | * space is needed elsewhere on the device. The system will always delete |
| 1303 | * older files first, as reported by {@link File#lastModified()}. If |
| 1304 | * desired, you can exert more control over how files are deleted using |
| 1305 | * {@link StorageManager#setCacheBehaviorGroup(File, boolean)} and |
| 1306 | * {@link StorageManager#setCacheBehaviorTombstone(File, boolean)}. |
| 1307 | * <p> |
| 1308 | * Apps are strongly encouraged to keep their usage of cache space below the |
| 1309 | * quota returned by |
| 1310 | * {@link StorageManager#getCacheQuotaBytes(java.util.UUID)}. If your app |
| 1311 | * goes above this quota, your cached files will be some of the first to be |
| 1312 | * deleted when additional disk space is needed. Conversely, if your app |
| 1313 | * stays under this quota, your cached files will be some of the last to be |
| 1314 | * deleted when additional disk space is needed. |
| 1315 | * <p> |
| 1316 | * Note that your cache quota will change over time depending on how |
| 1317 | * frequently the user interacts with your app, and depending on how much |
| 1318 | * system-wide disk space is used. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1319 | * <p> |
| 1320 | * The returned path may change over time if the calling app is moved to an |
| 1321 | * adopted storage device, so only relative paths should be persisted. |
| 1322 | * <p> |
| 1323 | * Apps require no extra permissions to read or write to the returned path, |
| 1324 | * since this path lives in their private storage. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1325 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1326 | * @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] | 1327 | * @see #openFileOutput |
| 1328 | * @see #getFileStreamPath |
| 1329 | * @see #getDir |
Kevin Hufnagle | e9681e1 | 2016-09-23 16:44:03 -0700 | [diff] [blame] | 1330 | * @see #getExternalCacheDir |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1331 | */ |
| 1332 | public abstract File getCacheDir(); |
| 1333 | |
| 1334 | /** |
Jeff Sharkey | 4ed745d | 2014-07-15 20:39:15 -0700 | [diff] [blame] | 1335 | * Returns the absolute path to the application specific cache directory on |
Jeff Sharkey | 60a82cd | 2017-04-18 18:19:16 -0600 | [diff] [blame] | 1336 | * the filesystem designed for storing cached code. |
| 1337 | * <p> |
| 1338 | * The system will delete any files stored in this location both when your |
| 1339 | * specific application is upgraded, and when the entire platform is |
| 1340 | * upgraded. |
Jeff Sharkey | 4ed745d | 2014-07-15 20:39:15 -0700 | [diff] [blame] | 1341 | * <p> |
| 1342 | * This location is optimal for storing compiled or optimized code generated |
| 1343 | * by your application at runtime. |
| 1344 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1345 | * The returned path may change over time if the calling app is moved to an |
| 1346 | * adopted storage device, so only relative paths should be persisted. |
| 1347 | * <p> |
Jeff Sharkey | 4ed745d | 2014-07-15 20:39:15 -0700 | [diff] [blame] | 1348 | * Apps require no extra permissions to read or write to the returned path, |
| 1349 | * since this path lives in their private storage. |
| 1350 | * |
| 1351 | * @return The path of the directory holding application code cache files. |
| 1352 | */ |
| 1353 | public abstract File getCodeCacheDir(); |
| 1354 | |
| 1355 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1356 | * Returns absolute path to application-specific directory on the primary |
| 1357 | * shared/external storage device where the application can place cache |
| 1358 | * files it owns. These files are internal to the application, and not |
| 1359 | * typically visible to the user as media. |
| 1360 | * <p> |
| 1361 | * This is like {@link #getCacheDir()} in that these files will be deleted |
| 1362 | * when the application is uninstalled, however there are some important |
| 1363 | * differences: |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1364 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1365 | * <li>The platform does not always monitor the space available in shared |
| 1366 | * storage, and thus may not automatically delete these files. Apps should |
| 1367 | * always manage the maximum space used in this location. Currently the only |
| 1368 | * time files here will be deleted by the platform is when running on |
| 1369 | * {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} or later and |
| 1370 | * {@link Environment#isExternalStorageEmulated(File)} returns true. |
| 1371 | * <li>Shared storage may not always be available, since removable media can |
| 1372 | * be ejected by the user. Media state can be checked using |
| 1373 | * {@link Environment#getExternalStorageState(File)}. |
| 1374 | * <li>There is no security enforced with these files. For example, any |
| 1375 | * application holding |
| 1376 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1377 | * these files. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1378 | * </ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1379 | * <p> |
| 1380 | * If a shared storage device is emulated (as determined by |
Kevin Hufnagle | e9681e1 | 2016-09-23 16:44:03 -0700 | [diff] [blame] | 1381 | * {@link Environment#isExternalStorageEmulated(File)}), its contents are |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1382 | * backed by a private user data partition, which means there is little |
| 1383 | * benefit to storing data here instead of the private directory returned by |
| 1384 | * {@link #getCacheDir()}. |
| 1385 | * <p> |
| 1386 | * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1387 | * 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] | 1388 | * accessible to the calling app. This only applies to paths generated for |
| 1389 | * package name of the calling application. To access paths belonging to |
| 1390 | * other packages, |
| 1391 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} and/or |
| 1392 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} are required. |
| 1393 | * <p> |
| 1394 | * On devices with multiple users (as described by {@link UserManager}), |
| 1395 | * each user has their own isolated shared storage. Applications only have |
| 1396 | * access to the shared storage for the user they're running as. |
| 1397 | * <p> |
| 1398 | * The returned path may change over time if different shared storage media |
| 1399 | * is inserted, so only relative paths should be persisted. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1400 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1401 | * @return the absolute path to application-specific directory. May return |
| 1402 | * {@code null} if shared storage is not currently available. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1403 | * @see #getCacheDir |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1404 | * @see #getExternalCacheDirs() |
| 1405 | * @see Environment#getExternalStorageState(File) |
| 1406 | * @see Environment#isExternalStorageEmulated(File) |
| 1407 | * @see Environment#isExternalStorageRemovable(File) |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1408 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1409 | @Nullable |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1410 | public abstract File getExternalCacheDir(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1411 | |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1412 | /** |
Fyodor Kupolov | 6122129 | 2016-09-02 15:21:03 -0700 | [diff] [blame] | 1413 | * Returns absolute path to application-specific directory in the preloaded cache. |
| 1414 | * <p>Files stored in the cache directory can be deleted when the device runs low on storage. |
| 1415 | * There is no guarantee when these files will be deleted. |
| 1416 | * @hide |
| 1417 | */ |
| 1418 | @Nullable |
| 1419 | @SystemApi |
| 1420 | public abstract File getPreloadsFileCache(); |
| 1421 | |
| 1422 | /** |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1423 | * Returns absolute paths to application-specific directories on all |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1424 | * shared/external storage devices where the application can place cache |
| 1425 | * files it owns. These files are internal to the application, and not |
| 1426 | * typically visible to the user as media. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1427 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1428 | * This is like {@link #getCacheDir()} in that these files will be deleted |
| 1429 | * when the application is uninstalled, however there are some important |
| 1430 | * differences: |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1431 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1432 | * <li>The platform does not always monitor the space available in shared |
| 1433 | * storage, and thus may not automatically delete these files. Apps should |
| 1434 | * always manage the maximum space used in this location. Currently the only |
| 1435 | * time files here will be deleted by the platform is when running on |
| 1436 | * {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} or later and |
| 1437 | * {@link Environment#isExternalStorageEmulated(File)} returns true. |
| 1438 | * <li>Shared storage may not always be available, since removable media can |
| 1439 | * be ejected by the user. Media state can be checked using |
| 1440 | * {@link Environment#getExternalStorageState(File)}. |
| 1441 | * <li>There is no security enforced with these files. For example, any |
| 1442 | * application holding |
| 1443 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 1444 | * these files. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1445 | * </ul> |
| 1446 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1447 | * If a shared storage device is emulated (as determined by |
| 1448 | * {@link Environment#isExternalStorageEmulated(File)}), it's contents are |
| 1449 | * backed by a private user data partition, which means there is little |
| 1450 | * benefit to storing data here instead of the private directory returned by |
| 1451 | * {@link #getCacheDir()}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1452 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1453 | * Shared storage devices returned here are considered a stable part of the |
| 1454 | * device, including physical media slots under a protective cover. The |
| 1455 | * returned paths do not include transient devices, such as USB flash drives |
| 1456 | * connected to handheld devices. |
| 1457 | * <p> |
| 1458 | * 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] | 1459 | * example, an app may choose to store large files on the device with the |
| 1460 | * most available space, as measured by {@link StatFs}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1461 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1462 | * No additional permissions are required for the calling app to read or |
| 1463 | * write files under the returned path. Write access outside of these paths |
| 1464 | * on secondary external storage devices is not available. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1465 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1466 | * The returned paths may change over time if different shared storage media |
| 1467 | * is inserted, so only relative paths should be persisted. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1468 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1469 | * @return the absolute paths to application-specific directories. Some |
| 1470 | * individual paths may be {@code null} if that shared storage is |
| 1471 | * not currently available. The first path returned is the same as |
| 1472 | * {@link #getExternalCacheDir()}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1473 | * @see #getExternalCacheDir() |
Jeff Sharkey | 4ca728c | 2014-01-10 16:27:19 -0800 | [diff] [blame] | 1474 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1475 | * @see Environment#isExternalStorageEmulated(File) |
| 1476 | * @see Environment#isExternalStorageRemovable(File) |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1477 | */ |
| 1478 | public abstract File[] getExternalCacheDirs(); |
| 1479 | |
| 1480 | /** |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1481 | * Returns absolute paths to application-specific directories on all |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1482 | * shared/external storage devices where the application can place media |
| 1483 | * files. These files are scanned and made available to other apps through |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1484 | * {@link MediaStore}. |
| 1485 | * <p> |
| 1486 | * This is like {@link #getExternalFilesDirs} in that these files will be |
| 1487 | * deleted when the application is uninstalled, however there are some |
| 1488 | * important differences: |
| 1489 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1490 | * <li>Shared storage may not always be available, since removable media can |
| 1491 | * be ejected by the user. Media state can be checked using |
| 1492 | * {@link Environment#getExternalStorageState(File)}. |
| 1493 | * <li>There is no security enforced with these files. For example, any |
| 1494 | * application holding |
| 1495 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 1496 | * these files. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1497 | * </ul> |
| 1498 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1499 | * Shared storage devices returned here are considered a stable part of the |
| 1500 | * device, including physical media slots under a protective cover. The |
| 1501 | * returned paths do not include transient devices, such as USB flash drives |
| 1502 | * connected to handheld devices. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1503 | * <p> |
| 1504 | * An application may store data on any or all of the returned devices. For |
| 1505 | * example, an app may choose to store large files on the device with the |
| 1506 | * most available space, as measured by {@link StatFs}. |
| 1507 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1508 | * No additional permissions are required for the calling app to read or |
| 1509 | * write files under the returned path. Write access outside of these paths |
| 1510 | * on secondary external storage devices is not available. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1511 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1512 | * The returned paths may change over time if different shared storage media |
| 1513 | * is inserted, so only relative paths should be persisted. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1514 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1515 | * @return the absolute paths to application-specific directories. Some |
| 1516 | * individual paths may be {@code null} if that shared storage is |
| 1517 | * not currently available. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1518 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1519 | * @see Environment#isExternalStorageEmulated(File) |
| 1520 | * @see Environment#isExternalStorageRemovable(File) |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1521 | */ |
| 1522 | public abstract File[] getExternalMediaDirs(); |
| 1523 | |
| 1524 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1525 | * Returns an array of strings naming the private files associated with |
| 1526 | * this Context's application package. |
| 1527 | * |
| 1528 | * @return Array of strings naming the private files. |
| 1529 | * |
| 1530 | * @see #openFileInput |
| 1531 | * @see #openFileOutput |
| 1532 | * @see #deleteFile |
| 1533 | */ |
| 1534 | public abstract String[] fileList(); |
| 1535 | |
| 1536 | /** |
| 1537 | * Retrieve, creating if needed, a new directory in which the application |
| 1538 | * can place its own custom data files. You can use the returned File |
| 1539 | * object to create and access files in this directory. Note that files |
| 1540 | * created through a File object will only be accessible by your own |
| 1541 | * application; you can only set the mode of the entire directory, not |
| 1542 | * of individual files. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1543 | * <p> |
| 1544 | * The returned path may change over time if the calling app is moved to an |
| 1545 | * adopted storage device, so only relative paths should be persisted. |
| 1546 | * <p> |
| 1547 | * Apps require no extra permissions to read or write to the returned path, |
| 1548 | * since this path lives in their private storage. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1549 | * |
Nick Kralevich | 92091fa | 2012-12-12 16:24:31 -0800 | [diff] [blame] | 1550 | * @param name Name of the directory to retrieve. This is a directory |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1551 | * that is created as part of your application data. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1552 | * @param mode Operating mode. |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1553 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1554 | * @return A {@link File} object for the requested directory. The directory |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1555 | * 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] | 1556 | * |
| 1557 | * @see #openFileOutput(String, int) |
| 1558 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1559 | public abstract File getDir(String name, @FileMode int mode); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1560 | |
| 1561 | /** |
| 1562 | * Open a new private SQLiteDatabase associated with this Context's |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1563 | * 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] | 1564 | * |
| 1565 | * @param name The name (unique in the application package) of the database. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1566 | * @param mode Operating mode. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1567 | * @param factory An optional factory class that is called to instantiate a |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1568 | * cursor when query is called. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1569 | * @return The contents of a newly created database with the given name. |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1570 | * @throws android.database.sqlite.SQLiteException if the database file |
| 1571 | * could not be opened. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1572 | * @see #MODE_PRIVATE |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 1573 | * @see #MODE_ENABLE_WRITE_AHEAD_LOGGING |
Sunny Goyal | a21e6b2 | 2015-12-02 09:51:02 -0800 | [diff] [blame] | 1574 | * @see #MODE_NO_LOCALIZED_COLLATORS |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1575 | * @see #deleteDatabase |
| 1576 | */ |
| 1577 | public abstract SQLiteDatabase openOrCreateDatabase(String name, |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1578 | @DatabaseMode int mode, CursorFactory factory); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1579 | |
| 1580 | /** |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1581 | * Open a new private SQLiteDatabase associated with this Context's |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1582 | * application package. Creates the database file if it doesn't exist. |
| 1583 | * <p> |
| 1584 | * Accepts input param: a concrete instance of {@link DatabaseErrorHandler} |
| 1585 | * to be used to handle corruption when sqlite reports database corruption. |
| 1586 | * </p> |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1587 | * |
| 1588 | * @param name The name (unique in the application package) of the database. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1589 | * @param mode Operating mode. |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1590 | * @param factory An optional factory class that is called to instantiate a |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1591 | * cursor when query is called. |
| 1592 | * @param errorHandler the {@link DatabaseErrorHandler} to be used when |
| 1593 | * sqlite reports database corruption. if null, |
| 1594 | * {@link android.database.DefaultDatabaseErrorHandler} is |
| 1595 | * assumed. |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1596 | * @return The contents of a newly created database with the given name. |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1597 | * @throws android.database.sqlite.SQLiteException if the database file |
| 1598 | * could not be opened. |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1599 | * @see #MODE_PRIVATE |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 1600 | * @see #MODE_ENABLE_WRITE_AHEAD_LOGGING |
Sunny Goyal | a21e6b2 | 2015-12-02 09:51:02 -0800 | [diff] [blame] | 1601 | * @see #MODE_NO_LOCALIZED_COLLATORS |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1602 | * @see #deleteDatabase |
| 1603 | */ |
| 1604 | public abstract SQLiteDatabase openOrCreateDatabase(String name, |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1605 | @DatabaseMode int mode, CursorFactory factory, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1606 | @Nullable DatabaseErrorHandler errorHandler); |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1607 | |
| 1608 | /** |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 1609 | * Move an existing database file from the given source storage context to |
| 1610 | * this context. This is typically used to migrate data between storage |
| 1611 | * locations after an upgrade, such as migrating to device protected |
| 1612 | * storage. |
Jeff Sharkey | d21cad1 | 2016-05-20 11:30:07 -0600 | [diff] [blame] | 1613 | * <p> |
| 1614 | * The database must be closed before being moved. |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 1615 | * |
| 1616 | * @param sourceContext The source context which contains the existing |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 1617 | * database to move. |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 1618 | * @param name The name of the database file. |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 1619 | * @return {@code true} if the move was successful or if the database didn't |
| 1620 | * exist in the source context, otherwise {@code false}. |
| 1621 | * @see #createDeviceProtectedStorageContext() |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 1622 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 1623 | public abstract boolean moveDatabaseFrom(Context sourceContext, String name); |
| 1624 | |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 1625 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1626 | * Delete an existing private SQLiteDatabase associated with this Context's |
| 1627 | * application package. |
| 1628 | * |
| 1629 | * @param name The name (unique in the application package) of the |
| 1630 | * database. |
| 1631 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1632 | * @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] | 1633 | * |
| 1634 | * @see #openOrCreateDatabase |
| 1635 | */ |
| 1636 | public abstract boolean deleteDatabase(String name); |
| 1637 | |
| 1638 | /** |
| 1639 | * Returns the absolute path on the filesystem where a database created with |
| 1640 | * {@link #openOrCreateDatabase} is stored. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1641 | * <p> |
| 1642 | * The returned path may change over time if the calling app is moved to an |
| 1643 | * 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] | 1644 | * |
| 1645 | * @param name The name of the database for which you would like to get |
| 1646 | * its path. |
| 1647 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1648 | * @return An absolute path to the given database. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1649 | * |
| 1650 | * @see #openOrCreateDatabase |
| 1651 | */ |
| 1652 | public abstract File getDatabasePath(String name); |
| 1653 | |
| 1654 | /** |
| 1655 | * Returns an array of strings naming the private databases associated with |
| 1656 | * this Context's application package. |
| 1657 | * |
| 1658 | * @return Array of strings naming the private databases. |
| 1659 | * |
| 1660 | * @see #openOrCreateDatabase |
| 1661 | * @see #deleteDatabase |
| 1662 | */ |
| 1663 | public abstract String[] databaseList(); |
| 1664 | |
| 1665 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1666 | * @deprecated Use {@link android.app.WallpaperManager#getDrawable |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1667 | * WallpaperManager.get()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1668 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1669 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1670 | public abstract Drawable getWallpaper(); |
| 1671 | |
| 1672 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1673 | * @deprecated Use {@link android.app.WallpaperManager#peekDrawable |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1674 | * WallpaperManager.peek()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1675 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1676 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1677 | public abstract Drawable peekWallpaper(); |
| 1678 | |
| 1679 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1680 | * @deprecated Use {@link android.app.WallpaperManager#getDesiredMinimumWidth() |
| 1681 | * WallpaperManager.getDesiredMinimumWidth()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1682 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1683 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1684 | public abstract int getWallpaperDesiredMinimumWidth(); |
| 1685 | |
| 1686 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1687 | * @deprecated Use {@link android.app.WallpaperManager#getDesiredMinimumHeight() |
| 1688 | * WallpaperManager.getDesiredMinimumHeight()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1689 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1690 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1691 | public abstract int getWallpaperDesiredMinimumHeight(); |
| 1692 | |
| 1693 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1694 | * @deprecated Use {@link android.app.WallpaperManager#setBitmap(Bitmap) |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1695 | * WallpaperManager.set()} instead. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 1696 | * <p>This method requires the caller to hold the permission |
| 1697 | * {@link android.Manifest.permission#SET_WALLPAPER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1698 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1699 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1700 | public abstract void setWallpaper(Bitmap bitmap) throws IOException; |
| 1701 | |
| 1702 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1703 | * @deprecated Use {@link android.app.WallpaperManager#setStream(InputStream) |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1704 | * WallpaperManager.set()} instead. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 1705 | * <p>This method requires the caller to hold the permission |
| 1706 | * {@link android.Manifest.permission#SET_WALLPAPER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1707 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1708 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1709 | public abstract void setWallpaper(InputStream data) throws IOException; |
| 1710 | |
| 1711 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1712 | * @deprecated Use {@link android.app.WallpaperManager#clear |
| 1713 | * WallpaperManager.clear()} instead. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 1714 | * <p>This method requires the caller to hold the permission |
| 1715 | * {@link android.Manifest.permission#SET_WALLPAPER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1716 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1717 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1718 | public abstract void clearWallpaper() throws IOException; |
| 1719 | |
| 1720 | /** |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1721 | * Same as {@link #startActivity(Intent, Bundle)} with no options |
| 1722 | * specified. |
| 1723 | * |
| 1724 | * @param intent The description of the activity to start. |
| 1725 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1726 | * @throws ActivityNotFoundException |
Svet Ganov | 1ed0e55 | 2015-06-11 01:15:43 -0700 | [diff] [blame] | 1727 | *` |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1728 | * @see #startActivity(Intent, Bundle) |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1729 | * @see PackageManager#resolveActivity |
| 1730 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1731 | public abstract void startActivity(@RequiresPermission Intent intent); |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1732 | |
| 1733 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1734 | * Version of {@link #startActivity(Intent)} that allows you to specify the |
| 1735 | * 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] | 1736 | * that are not pre-installed on the system image. |
Amith Yamasani | 8264408 | 2012-08-03 13:09:11 -0700 | [diff] [blame] | 1737 | * @param intent The description of the activity to start. |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 1738 | * @param user The UserHandle of the user to start this activity for. |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1739 | * @throws ActivityNotFoundException |
Amith Yamasani | 8264408 | 2012-08-03 13:09:11 -0700 | [diff] [blame] | 1740 | * @hide |
| 1741 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 1742 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) |
Philip P. Moltmann | 4e615e6 | 2018-08-28 14:57:49 -0700 | [diff] [blame] | 1743 | @SystemApi |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1744 | public void startActivityAsUser(@RequiresPermission Intent intent, UserHandle user) { |
Amith Yamasani | 8264408 | 2012-08-03 13:09:11 -0700 | [diff] [blame] | 1745 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 1746 | } |
| 1747 | |
| 1748 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1749 | * Launch a new activity. You will not receive any information about when |
| 1750 | * the activity exits. |
| 1751 | * |
| 1752 | * <p>Note that if this method is being called from outside of an |
| 1753 | * {@link android.app.Activity} Context, then the Intent must include |
| 1754 | * the {@link Intent#FLAG_ACTIVITY_NEW_TASK} launch flag. This is because, |
| 1755 | * without being started from an existing Activity, there is no existing |
| 1756 | * task in which to place the new activity and thus it needs to be placed |
| 1757 | * in its own separate task. |
| 1758 | * |
| 1759 | * <p>This method throws {@link ActivityNotFoundException} |
| 1760 | * if there was no Activity found to run the given Intent. |
| 1761 | * |
| 1762 | * @param intent The description of the activity to start. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1763 | * @param options Additional options for how the Activity should be started. |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 1764 | * May be null if there are no options. See {@link android.app.ActivityOptions} |
| 1765 | * for how to build the Bundle supplied here; there are no supported definitions |
| 1766 | * for building it manually. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1767 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1768 | * @throws ActivityNotFoundException |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1769 | * |
Scott Main | 60dd520 | 2012-06-23 00:01:22 -0700 | [diff] [blame] | 1770 | * @see #startActivity(Intent) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1771 | * @see PackageManager#resolveActivity |
| 1772 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1773 | public abstract void startActivity(@RequiresPermission Intent intent, |
| 1774 | @Nullable Bundle options); |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1775 | |
| 1776 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1777 | * Version of {@link #startActivity(Intent, Bundle)} that allows you to specify the |
| 1778 | * 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] | 1779 | * that are not pre-installed on the system image. |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 1780 | * @param intent The description of the activity to start. |
| 1781 | * @param options Additional options for how the Activity should be started. |
| 1782 | * May be null if there are no options. See {@link android.app.ActivityOptions} |
| 1783 | * for how to build the Bundle supplied here; there are no supported definitions |
| 1784 | * for building it manually. |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 1785 | * @param userId The UserHandle of the user to start this activity for. |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1786 | * @throws ActivityNotFoundException |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 1787 | * @hide |
| 1788 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 1789 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 1790 | @UnsupportedAppUsage |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1791 | public void startActivityAsUser(@RequiresPermission Intent intent, @Nullable Bundle options, |
| 1792 | UserHandle userId) { |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 1793 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 1794 | } |
| 1795 | |
| 1796 | /** |
Clara Bayarri | d5bf3ed | 2015-03-27 17:32:45 +0000 | [diff] [blame] | 1797 | * Version of {@link #startActivity(Intent, Bundle)} that returns a result to the caller. This |
| 1798 | * is only supported for Views and Fragments. |
| 1799 | * @param who The identifier for the calling element that will receive the result. |
| 1800 | * @param intent The intent to start. |
| 1801 | * @param requestCode The code that will be returned with onActivityResult() identifying this |
| 1802 | * request. |
| 1803 | * @param options Additional options for how the Activity should be started. |
| 1804 | * May be null if there are no options. See {@link android.app.ActivityOptions} |
| 1805 | * for how to build the Bundle supplied here; there are no supported definitions |
| 1806 | * for building it manually. |
| 1807 | * @hide |
| 1808 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 1809 | @UnsupportedAppUsage |
Clara Bayarri | d5bf3ed | 2015-03-27 17:32:45 +0000 | [diff] [blame] | 1810 | public void startActivityForResult( |
| 1811 | @NonNull String who, Intent intent, int requestCode, @Nullable Bundle options) { |
| 1812 | throw new RuntimeException("This method is only implemented for Activity-based Contexts. " |
| 1813 | + "Check canStartActivityForResult() before calling."); |
| 1814 | } |
| 1815 | |
| 1816 | /** |
| 1817 | * Identifies whether this Context instance will be able to process calls to |
| 1818 | * {@link #startActivityForResult(String, Intent, int, Bundle)}. |
| 1819 | * @hide |
| 1820 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 1821 | @UnsupportedAppUsage |
Clara Bayarri | d5bf3ed | 2015-03-27 17:32:45 +0000 | [diff] [blame] | 1822 | public boolean canStartActivityForResult() { |
| 1823 | return false; |
| 1824 | } |
| 1825 | |
| 1826 | /** |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1827 | * Same as {@link #startActivities(Intent[], Bundle)} with no options |
| 1828 | * specified. |
| 1829 | * |
| 1830 | * @param intents An array of Intents to be started. |
| 1831 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1832 | * @throws ActivityNotFoundException |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1833 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1834 | * @see #startActivities(Intent[], Bundle) |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1835 | * @see PackageManager#resolveActivity |
| 1836 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1837 | public abstract void startActivities(@RequiresPermission Intent[] intents); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1838 | |
| 1839 | /** |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1840 | * Launch multiple new activities. This is generally the same as calling |
| 1841 | * {@link #startActivity(Intent)} for the first Intent in the array, |
| 1842 | * that activity during its creation calling {@link #startActivity(Intent)} |
| 1843 | * for the second entry, etc. Note that unlike that approach, generally |
| 1844 | * none of the activities except the last in the array will be created |
| 1845 | * at this point, but rather will be created when the user first visits |
| 1846 | * them (due to pressing back from the activity on top). |
| 1847 | * |
| 1848 | * <p>This method throws {@link ActivityNotFoundException} |
| 1849 | * if there was no Activity found for <em>any</em> given Intent. In this |
| 1850 | * case the state of the activity stack is undefined (some Intents in the |
| 1851 | * list may be on it, some not), so you probably want to avoid such situations. |
| 1852 | * |
| 1853 | * @param intents An array of Intents to be started. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1854 | * @param options Additional options for how the Activity should be started. |
Elliot Waite | 54de774 | 2017-01-11 15:30:35 -0800 | [diff] [blame] | 1855 | * See {@link android.content.Context#startActivity(Intent, Bundle)} |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 1856 | * Context.startActivity(Intent, Bundle)} for more details. |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1857 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1858 | * @throws ActivityNotFoundException |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1859 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1860 | * @see #startActivities(Intent[]) |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1861 | * @see PackageManager#resolveActivity |
| 1862 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1863 | public abstract void startActivities(@RequiresPermission Intent[] intents, Bundle options); |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1864 | |
| 1865 | /** |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1866 | * @hide |
| 1867 | * Launch multiple new activities. This is generally the same as calling |
| 1868 | * {@link #startActivity(Intent)} for the first Intent in the array, |
| 1869 | * that activity during its creation calling {@link #startActivity(Intent)} |
| 1870 | * for the second entry, etc. Note that unlike that approach, generally |
| 1871 | * none of the activities except the last in the array will be created |
| 1872 | * at this point, but rather will be created when the user first visits |
| 1873 | * them (due to pressing back from the activity on top). |
| 1874 | * |
| 1875 | * <p>This method throws {@link ActivityNotFoundException} |
| 1876 | * if there was no Activity found for <em>any</em> given Intent. In this |
| 1877 | * case the state of the activity stack is undefined (some Intents in the |
| 1878 | * list may be on it, some not), so you probably want to avoid such situations. |
| 1879 | * |
| 1880 | * @param intents An array of Intents to be started. |
| 1881 | * @param options Additional options for how the Activity should be started. |
| 1882 | * @param userHandle The user for whom to launch the activities |
Elliot Waite | 54de774 | 2017-01-11 15:30:35 -0800 | [diff] [blame] | 1883 | * See {@link android.content.Context#startActivity(Intent, Bundle)} |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1884 | * Context.startActivity(Intent, Bundle)} for more details. |
| 1885 | * |
Selim Cinek | 7fa385a | 2018-01-24 08:35:28 -0800 | [diff] [blame] | 1886 | * @return The corresponding flag {@link ActivityManager#START_CANCELED}, |
| 1887 | * {@link ActivityManager#START_SUCCESS} etc. indicating whether the launch was |
| 1888 | * successful. |
| 1889 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1890 | * @throws ActivityNotFoundException |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1891 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1892 | * @see #startActivities(Intent[]) |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1893 | * @see PackageManager#resolveActivity |
| 1894 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 1895 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) |
Selim Cinek | 7fa385a | 2018-01-24 08:35:28 -0800 | [diff] [blame] | 1896 | public int startActivitiesAsUser(Intent[] intents, Bundle options, UserHandle userHandle) { |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1897 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 1898 | } |
| 1899 | |
| 1900 | /** |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1901 | * Same as {@link #startIntentSender(IntentSender, Intent, int, int, int, Bundle)} |
| 1902 | * with no options specified. |
| 1903 | * |
| 1904 | * @param intent The IntentSender to launch. |
| 1905 | * @param fillInIntent If non-null, this will be provided as the |
| 1906 | * intent parameter to {@link IntentSender#sendIntent}. |
| 1907 | * @param flagsMask Intent flags in the original IntentSender that you |
| 1908 | * would like to change. |
| 1909 | * @param flagsValues Desired values for any bits set in |
| 1910 | * <var>flagsMask</var> |
| 1911 | * @param extraFlags Always set to 0. |
| 1912 | * |
| 1913 | * @see #startActivity(Intent) |
| 1914 | * @see #startIntentSender(IntentSender, Intent, int, int, int, Bundle) |
| 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) throws IntentSender.SendIntentException; |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1919 | |
| 1920 | /** |
| 1921 | * Like {@link #startActivity(Intent, Bundle)}, but taking a IntentSender |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1922 | * 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] | 1923 | * as if you had called the regular {@link #startActivity(Intent)} |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1924 | * here; otherwise, its associated action will be executed (such as |
| 1925 | * sending a broadcast) as if you had called |
| 1926 | * {@link IntentSender#sendIntent IntentSender.sendIntent} on it. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1927 | * |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1928 | * @param intent The IntentSender to launch. |
| 1929 | * @param fillInIntent If non-null, this will be provided as the |
| 1930 | * intent parameter to {@link IntentSender#sendIntent}. |
| 1931 | * @param flagsMask Intent flags in the original IntentSender that you |
| 1932 | * would like to change. |
| 1933 | * @param flagsValues Desired values for any bits set in |
| 1934 | * <var>flagsMask</var> |
| 1935 | * @param extraFlags Always set to 0. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1936 | * @param options Additional options for how the Activity should be started. |
Elliot Waite | 54de774 | 2017-01-11 15:30:35 -0800 | [diff] [blame] | 1937 | * See {@link android.content.Context#startActivity(Intent, Bundle)} |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 1938 | * Context.startActivity(Intent, Bundle)} for more details. If options |
| 1939 | * have also been supplied by the IntentSender, options given here will |
| 1940 | * override any that conflict with those given by the IntentSender. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1941 | * |
| 1942 | * @see #startActivity(Intent, Bundle) |
| 1943 | * @see #startIntentSender(IntentSender, Intent, int, int, int) |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1944 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1945 | public abstract void startIntentSender(IntentSender intent, @Nullable Intent fillInIntent, |
| 1946 | @Intent.MutableFlags int flagsMask, @Intent.MutableFlags int flagsValues, |
| 1947 | int extraFlags, @Nullable Bundle options) throws IntentSender.SendIntentException; |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1948 | |
| 1949 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1950 | * Broadcast the given intent to all interested BroadcastReceivers. This |
| 1951 | * call is asynchronous; it returns immediately, and you will continue |
| 1952 | * executing while the receivers are run. No results are propagated from |
| 1953 | * receivers and receivers can not abort the broadcast. If you want |
| 1954 | * to allow receivers to propagate results or abort the broadcast, you must |
| 1955 | * send an ordered broadcast using |
| 1956 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 1957 | * |
| 1958 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1959 | * |
| 1960 | * @param intent The Intent to broadcast; all receivers matching this |
| 1961 | * Intent will receive the broadcast. |
| 1962 | * |
| 1963 | * @see android.content.BroadcastReceiver |
| 1964 | * @see #registerReceiver |
| 1965 | * @see #sendBroadcast(Intent, String) |
| 1966 | * @see #sendOrderedBroadcast(Intent, String) |
| 1967 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 1968 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1969 | public abstract void sendBroadcast(@RequiresPermission Intent intent); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1970 | |
| 1971 | /** |
| 1972 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
| 1973 | * an optional required permission to be enforced. This |
| 1974 | * call is asynchronous; it returns immediately, and you will continue |
| 1975 | * executing while the receivers are run. No results are propagated from |
| 1976 | * receivers and receivers can not abort the broadcast. If you want |
| 1977 | * to allow receivers to propagate results or abort the broadcast, you must |
| 1978 | * send an ordered broadcast using |
| 1979 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 1980 | * |
| 1981 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 1982 | * |
| 1983 | * @param intent The Intent to broadcast; all receivers matching this |
| 1984 | * Intent will receive the broadcast. |
Brad Fitzpatrick | 26b71be | 2010-12-07 14:52:58 -0800 | [diff] [blame] | 1985 | * @param receiverPermission (optional) String naming a permission that |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1986 | * a receiver must hold in order to receive your broadcast. |
| 1987 | * If null, no permission is required. |
| 1988 | * |
| 1989 | * @see android.content.BroadcastReceiver |
| 1990 | * @see #registerReceiver |
| 1991 | * @see #sendBroadcast(Intent) |
| 1992 | * @see #sendOrderedBroadcast(Intent, String) |
| 1993 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 1994 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1995 | public abstract void sendBroadcast(@RequiresPermission Intent intent, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1996 | @Nullable String receiverPermission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1997 | |
Fyodor Kupolov | d4fd8c7 | 2015-07-13 19:19:25 -0700 | [diff] [blame] | 1998 | |
| 1999 | /** |
| 2000 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
| 2001 | * an array of required permissions to be enforced. This call is asynchronous; it returns |
| 2002 | * immediately, and you will continue executing while the receivers are run. No results are |
| 2003 | * propagated from receivers and receivers can not abort the broadcast. If you want to allow |
| 2004 | * receivers to propagate results or abort the broadcast, you must send an ordered broadcast |
| 2005 | * using {@link #sendOrderedBroadcast(Intent, String)}. |
| 2006 | * |
| 2007 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2008 | * |
| 2009 | * @param intent The Intent to broadcast; all receivers matching this |
| 2010 | * Intent will receive the broadcast. |
| 2011 | * @param receiverPermissions Array of names of permissions that a receiver must hold |
| 2012 | * in order to receive your broadcast. |
| 2013 | * If null or empty, no permissions are required. |
| 2014 | * |
| 2015 | * @see android.content.BroadcastReceiver |
| 2016 | * @see #registerReceiver |
| 2017 | * @see #sendBroadcast(Intent) |
| 2018 | * @see #sendOrderedBroadcast(Intent, String) |
| 2019 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2020 | * @hide |
| 2021 | */ |
| 2022 | public abstract void sendBroadcastMultiplePermissions(Intent intent, |
| 2023 | String[] receiverPermissions); |
| 2024 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2025 | /** |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 2026 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
Tyler Gunn | f955e56 | 2018-04-26 14:43:31 -0700 | [diff] [blame] | 2027 | * an array of required permissions to be enforced. This call is asynchronous; it returns |
| 2028 | * immediately, and you will continue executing while the receivers are run. No results are |
| 2029 | * propagated from receivers and receivers can not abort the broadcast. If you want to allow |
| 2030 | * receivers to propagate results or abort the broadcast, you must send an ordered broadcast |
| 2031 | * using {@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 user The user to send the broadcast to. |
| 2038 | * @param receiverPermissions Array of names of permissions that a receiver must hold |
| 2039 | * in order to receive your broadcast. |
| 2040 | * If null or empty, no permissions are required. |
| 2041 | * |
| 2042 | * @see android.content.BroadcastReceiver |
| 2043 | * @see #registerReceiver |
| 2044 | * @see #sendBroadcast(Intent) |
| 2045 | * @see #sendOrderedBroadcast(Intent, String) |
| 2046 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2047 | * @hide |
| 2048 | */ |
| 2049 | public abstract void sendBroadcastAsUserMultiplePermissions(Intent intent, UserHandle user, |
| 2050 | String[] receiverPermissions); |
| 2051 | |
| 2052 | /** |
| 2053 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 2054 | * an optional required permission to be enforced. This |
| 2055 | * call is asynchronous; it returns immediately, and you will continue |
| 2056 | * executing while the receivers are run. No results are propagated from |
| 2057 | * receivers and receivers can not abort the broadcast. If you want |
| 2058 | * to allow receivers to propagate results or abort the broadcast, you must |
| 2059 | * send an ordered broadcast using |
| 2060 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2061 | * |
| 2062 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2063 | * |
| 2064 | * @param intent The Intent to broadcast; all receivers matching this |
| 2065 | * Intent will receive the broadcast. |
| 2066 | * @param receiverPermission (optional) String naming a permission that |
| 2067 | * a receiver must hold in order to receive your broadcast. |
| 2068 | * If null, no permission is required. |
| 2069 | * @param options (optional) Additional sending options, generated from a |
| 2070 | * {@link android.app.BroadcastOptions}. |
| 2071 | * |
| 2072 | * @see android.content.BroadcastReceiver |
| 2073 | * @see #registerReceiver |
| 2074 | * @see #sendBroadcast(Intent) |
| 2075 | * @see #sendOrderedBroadcast(Intent, String) |
| 2076 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2077 | * @hide |
| 2078 | */ |
| 2079 | @SystemApi |
| 2080 | public abstract void sendBroadcast(Intent intent, |
| 2081 | @Nullable String receiverPermission, |
| 2082 | @Nullable Bundle options); |
| 2083 | |
| 2084 | /** |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2085 | * Like {@link #sendBroadcast(Intent, String)}, but also allows specification |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2086 | * of an associated app op as per {@link android.app.AppOpsManager}. |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2087 | * @hide |
| 2088 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 2089 | @UnsupportedAppUsage |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2090 | public abstract void sendBroadcast(Intent intent, |
| 2091 | String receiverPermission, int appOp); |
| 2092 | |
| 2093 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2094 | * Broadcast the given intent to all interested BroadcastReceivers, delivering |
| 2095 | * them one at a time to allow more preferred receivers to consume the |
| 2096 | * broadcast before it is delivered to less preferred receivers. This |
| 2097 | * call is asynchronous; it returns immediately, and you will continue |
| 2098 | * executing while the receivers are run. |
| 2099 | * |
| 2100 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2101 | * |
| 2102 | * @param intent The Intent to broadcast; all receivers matching this |
| 2103 | * Intent will receive the broadcast. |
| 2104 | * @param receiverPermission (optional) String naming a permissions that |
| 2105 | * a receiver must hold in order to receive your broadcast. |
| 2106 | * If null, no permission is required. |
| 2107 | * |
| 2108 | * @see android.content.BroadcastReceiver |
| 2109 | * @see #registerReceiver |
| 2110 | * @see #sendBroadcast(Intent) |
| 2111 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2112 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2113 | public abstract void sendOrderedBroadcast(@RequiresPermission Intent intent, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2114 | @Nullable String receiverPermission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2115 | |
| 2116 | /** |
| 2117 | * Version of {@link #sendBroadcast(Intent)} that allows you to |
| 2118 | * receive data back from the broadcast. This is accomplished by |
| 2119 | * supplying your own BroadcastReceiver when calling, which will be |
| 2120 | * treated as a final receiver at the end of the broadcast -- its |
| 2121 | * {@link BroadcastReceiver#onReceive} method will be called with |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2122 | * 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] | 2123 | * be serialized in the same way as calling |
| 2124 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2125 | * |
| 2126 | * <p>Like {@link #sendBroadcast(Intent)}, this method is |
| 2127 | * asynchronous; it will return before |
| 2128 | * resultReceiver.onReceive() is called. |
| 2129 | * |
| 2130 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2131 | * |
| 2132 | * @param intent The Intent to broadcast; all receivers matching this |
| 2133 | * Intent will receive the broadcast. |
| 2134 | * @param receiverPermission String naming a permissions that |
| 2135 | * a receiver must hold in order to receive your broadcast. |
| 2136 | * If null, no permission is required. |
| 2137 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2138 | * receiver of the broadcast. |
| 2139 | * @param scheduler A custom Handler with which to schedule the |
| 2140 | * resultReceiver callback; if null it will be |
| 2141 | * scheduled in the Context's main thread. |
| 2142 | * @param initialCode An initial value for the result code. Often |
| 2143 | * Activity.RESULT_OK. |
| 2144 | * @param initialData An initial value for the result data. Often |
| 2145 | * null. |
| 2146 | * @param initialExtras An initial value for the result extras. Often |
| 2147 | * null. |
| 2148 | * |
| 2149 | * @see #sendBroadcast(Intent) |
| 2150 | * @see #sendBroadcast(Intent, String) |
| 2151 | * @see #sendOrderedBroadcast(Intent, String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2152 | * @see android.content.BroadcastReceiver |
| 2153 | * @see #registerReceiver |
| 2154 | * @see android.app.Activity#RESULT_OK |
| 2155 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2156 | public abstract void sendOrderedBroadcast(@RequiresPermission @NonNull Intent intent, |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 2157 | @Nullable String receiverPermission, @Nullable BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2158 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2159 | @Nullable Bundle initialExtras); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2160 | |
| 2161 | /** |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 2162 | * Version of {@link #sendBroadcast(Intent)} that allows you to |
| 2163 | * receive data back from the broadcast. This is accomplished by |
| 2164 | * supplying your own BroadcastReceiver when calling, which will be |
| 2165 | * treated as a final receiver at the end of the broadcast -- its |
| 2166 | * {@link BroadcastReceiver#onReceive} method will be called with |
| 2167 | * the result values collected from the other receivers. The broadcast will |
| 2168 | * be serialized in the same way as calling |
| 2169 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2170 | * |
| 2171 | * <p>Like {@link #sendBroadcast(Intent)}, this method is |
| 2172 | * asynchronous; it will return before |
| 2173 | * resultReceiver.onReceive() is called. |
| 2174 | * |
| 2175 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2176 | * |
| 2177 | * |
| 2178 | * @param intent The Intent to broadcast; all receivers matching this |
| 2179 | * Intent will receive the broadcast. |
| 2180 | * @param receiverPermission String naming a permissions that |
| 2181 | * a receiver must hold in order to receive your broadcast. |
| 2182 | * If null, no permission is required. |
| 2183 | * @param options (optional) Additional sending options, generated from a |
| 2184 | * {@link android.app.BroadcastOptions}. |
| 2185 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2186 | * receiver of the broadcast. |
| 2187 | * @param scheduler A custom Handler with which to schedule the |
| 2188 | * resultReceiver callback; if null it will be |
| 2189 | * scheduled in the Context's main thread. |
| 2190 | * @param initialCode An initial value for the result code. Often |
| 2191 | * Activity.RESULT_OK. |
| 2192 | * @param initialData An initial value for the result data. Often |
| 2193 | * null. |
| 2194 | * @param initialExtras An initial value for the result extras. Often |
| 2195 | * null. |
| 2196 | * @see #sendBroadcast(Intent) |
| 2197 | * @see #sendBroadcast(Intent, String) |
| 2198 | * @see #sendOrderedBroadcast(Intent, String) |
| 2199 | * @see android.content.BroadcastReceiver |
| 2200 | * @see #registerReceiver |
| 2201 | * @see android.app.Activity#RESULT_OK |
| 2202 | * @hide |
| 2203 | */ |
| 2204 | @SystemApi |
| 2205 | public abstract void sendOrderedBroadcast(@NonNull Intent intent, |
| 2206 | @Nullable String receiverPermission, @Nullable Bundle options, |
| 2207 | @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, |
| 2208 | int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras); |
| 2209 | |
| 2210 | /** |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2211 | * Like {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, android.os.Handler, |
| 2212 | * int, String, android.os.Bundle)}, but also allows specification |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2213 | * of an associated app op as per {@link android.app.AppOpsManager}. |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2214 | * @hide |
| 2215 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 2216 | @UnsupportedAppUsage |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2217 | public abstract void sendOrderedBroadcast(Intent intent, |
| 2218 | String receiverPermission, int appOp, BroadcastReceiver resultReceiver, |
| 2219 | Handler scheduler, int initialCode, String initialData, |
| 2220 | Bundle initialExtras); |
| 2221 | |
| 2222 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2223 | * Version of {@link #sendBroadcast(Intent)} that allows you to specify the |
| 2224 | * 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] | 2225 | * that are not pre-installed on the system image. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2226 | * @param intent The intent to broadcast |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 2227 | * @param user UserHandle to send the intent to. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2228 | * @see #sendBroadcast(Intent) |
| 2229 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2230 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2231 | public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent, |
| 2232 | UserHandle user); |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2233 | |
| 2234 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2235 | * Version of {@link #sendBroadcast(Intent, String)} that allows you to specify the |
| 2236 | * 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] | 2237 | * that are not pre-installed on the system image. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2238 | * |
| 2239 | * @param intent The Intent to broadcast; all receivers matching this |
| 2240 | * Intent will receive the broadcast. |
| 2241 | * @param user UserHandle to send the intent to. |
| 2242 | * @param receiverPermission (optional) String naming a permission that |
| 2243 | * a receiver must hold in order to receive your broadcast. |
| 2244 | * If null, no permission is required. |
| 2245 | * |
| 2246 | * @see #sendBroadcast(Intent, String) |
| 2247 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2248 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2249 | public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent, |
| 2250 | UserHandle user, @Nullable String receiverPermission); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2251 | |
Chad Brubaker | 52c8edc | 2016-07-25 14:30:26 -0700 | [diff] [blame] | 2252 | /** |
| 2253 | * Version of {@link #sendBroadcast(Intent, String, Bundle)} that allows you to specify the |
| 2254 | * 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] | 2255 | * that are not pre-installed on the system image. |
Chad Brubaker | 52c8edc | 2016-07-25 14:30:26 -0700 | [diff] [blame] | 2256 | * |
| 2257 | * @param intent The Intent to broadcast; all receivers matching this |
| 2258 | * Intent will receive the broadcast. |
| 2259 | * @param user UserHandle to send the intent to. |
| 2260 | * @param receiverPermission (optional) String naming a permission that |
| 2261 | * a receiver must hold in order to receive your broadcast. |
| 2262 | * If null, no permission is required. |
| 2263 | * @param options (optional) Additional sending options, generated from a |
| 2264 | * {@link android.app.BroadcastOptions}. |
| 2265 | * |
| 2266 | * @see #sendBroadcast(Intent, String, Bundle) |
| 2267 | * @hide |
| 2268 | */ |
| 2269 | @SystemApi |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2270 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Chad Brubaker | 52c8edc | 2016-07-25 14:30:26 -0700 | [diff] [blame] | 2271 | public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent, |
| 2272 | UserHandle user, @Nullable String receiverPermission, @Nullable Bundle options); |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 2273 | |
| 2274 | /** |
| 2275 | * Version of {@link #sendBroadcast(Intent, String)} that allows you to specify the |
| 2276 | * 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] | 2277 | * that are not pre-installed on the system image. |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 2278 | * |
| 2279 | * @param intent The Intent to broadcast; all receivers matching this |
| 2280 | * Intent will receive the broadcast. |
| 2281 | * @param user UserHandle to send the intent to. |
| 2282 | * @param receiverPermission (optional) String naming a permission that |
| 2283 | * a receiver must hold in order to receive your broadcast. |
| 2284 | * If null, no permission is required. |
| 2285 | * @param appOp The app op associated with the broadcast. |
| 2286 | * |
| 2287 | * @see #sendBroadcast(Intent, String) |
| 2288 | * |
| 2289 | * @hide |
| 2290 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2291 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 2292 | @UnsupportedAppUsage |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2293 | public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent, |
| 2294 | UserHandle user, @Nullable String receiverPermission, int appOp); |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 2295 | |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2296 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2297 | * Version of |
| 2298 | * {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)} |
| 2299 | * that allows you to specify the |
| 2300 | * 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] | 2301 | * that are not pre-installed on the system image. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2302 | * |
| 2303 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2304 | * |
| 2305 | * @param intent The Intent to broadcast; all receivers matching this |
| 2306 | * Intent will receive the broadcast. |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 2307 | * @param user UserHandle to send the intent to. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2308 | * @param receiverPermission String naming a permissions that |
| 2309 | * a receiver must hold in order to receive your broadcast. |
| 2310 | * If null, no permission is required. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2311 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2312 | * receiver of the broadcast. |
| 2313 | * @param scheduler A custom Handler with which to schedule the |
| 2314 | * resultReceiver callback; if null it will be |
| 2315 | * scheduled in the Context's main thread. |
| 2316 | * @param initialCode An initial value for the result code. Often |
| 2317 | * Activity.RESULT_OK. |
| 2318 | * @param initialData An initial value for the result data. Often |
| 2319 | * null. |
| 2320 | * @param initialExtras An initial value for the result extras. Often |
| 2321 | * null. |
| 2322 | * |
| 2323 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2324 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2325 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2326 | public abstract void sendOrderedBroadcastAsUser(@RequiresPermission Intent intent, |
| 2327 | UserHandle user, @Nullable String receiverPermission, BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2328 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2329 | @Nullable Bundle initialExtras); |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2330 | |
| 2331 | /** |
Amith Yamasani | 3cf7572 | 2014-05-16 12:37:29 -0700 | [diff] [blame] | 2332 | * Similar to above but takes an appOp as well, to enforce restrictions. |
| 2333 | * @see #sendOrderedBroadcastAsUser(Intent, UserHandle, String, |
| 2334 | * BroadcastReceiver, Handler, int, String, Bundle) |
| 2335 | * @hide |
| 2336 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2337 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 2338 | @UnsupportedAppUsage |
Amith Yamasani | 3cf7572 | 2014-05-16 12:37:29 -0700 | [diff] [blame] | 2339 | public abstract void sendOrderedBroadcastAsUser(Intent intent, UserHandle user, |
| 2340 | @Nullable String receiverPermission, int appOp, BroadcastReceiver resultReceiver, |
| 2341 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2342 | @Nullable Bundle initialExtras); |
| 2343 | |
| 2344 | /** |
Dianne Hackborn | fd854ee | 2015-07-13 18:00:37 -0700 | [diff] [blame] | 2345 | * Similar to above but takes an appOp as well, to enforce restrictions, and an options Bundle. |
| 2346 | * @see #sendOrderedBroadcastAsUser(Intent, UserHandle, String, |
| 2347 | * BroadcastReceiver, Handler, int, String, Bundle) |
| 2348 | * @hide |
| 2349 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2350 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 2351 | @UnsupportedAppUsage |
Dianne Hackborn | fd854ee | 2015-07-13 18:00:37 -0700 | [diff] [blame] | 2352 | public abstract void sendOrderedBroadcastAsUser(Intent intent, UserHandle user, |
| 2353 | @Nullable String receiverPermission, int appOp, @Nullable Bundle options, |
| 2354 | BroadcastReceiver resultReceiver, @Nullable Handler scheduler, int initialCode, |
| 2355 | @Nullable String initialData, @Nullable Bundle initialExtras); |
| 2356 | |
| 2357 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2358 | * <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] | 2359 | * Intent you are sending stays around after the broadcast is complete, |
| 2360 | * so that others can quickly retrieve that data through the return |
| 2361 | * value of {@link #registerReceiver(BroadcastReceiver, IntentFilter)}. In |
| 2362 | * all other ways, this behaves the same as |
| 2363 | * {@link #sendBroadcast(Intent)}. |
| 2364 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2365 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2366 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2367 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2368 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2369 | * desired. |
| 2370 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2371 | * @param intent The Intent to broadcast; all receivers matching this |
| 2372 | * Intent will receive the broadcast, and the Intent will be held to |
| 2373 | * be re-broadcast to future receivers. |
| 2374 | * |
| 2375 | * @see #sendBroadcast(Intent) |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2376 | * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2377 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2378 | @Deprecated |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 2379 | @RequiresPermission(android.Manifest.permission.BROADCAST_STICKY) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2380 | public abstract void sendStickyBroadcast(@RequiresPermission Intent intent); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2381 | |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2382 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2383 | * <p>Version of {@link #sendStickyBroadcast} that allows you to |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2384 | * receive data back from the broadcast. This is accomplished by |
| 2385 | * supplying your own BroadcastReceiver when calling, which will be |
| 2386 | * treated as a final receiver at the end of the broadcast -- its |
| 2387 | * {@link BroadcastReceiver#onReceive} method will be called with |
| 2388 | * the result values collected from the other receivers. The broadcast will |
| 2389 | * be serialized in the same way as calling |
| 2390 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2391 | * |
| 2392 | * <p>Like {@link #sendBroadcast(Intent)}, this method is |
| 2393 | * asynchronous; it will return before |
| 2394 | * resultReceiver.onReceive() is called. Note that the sticky data |
| 2395 | * stored is only the data you initially supply to the broadcast, not |
| 2396 | * the result of any changes made by the receivers. |
| 2397 | * |
| 2398 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2399 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2400 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2401 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2402 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2403 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2404 | * desired. |
| 2405 | * |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2406 | * @param intent The Intent to broadcast; all receivers matching this |
| 2407 | * Intent will receive the broadcast. |
| 2408 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2409 | * receiver of the broadcast. |
| 2410 | * @param scheduler A custom Handler with which to schedule the |
| 2411 | * resultReceiver callback; if null it will be |
| 2412 | * scheduled in the Context's main thread. |
| 2413 | * @param initialCode An initial value for the result code. Often |
| 2414 | * Activity.RESULT_OK. |
| 2415 | * @param initialData An initial value for the result data. Often |
| 2416 | * null. |
| 2417 | * @param initialExtras An initial value for the result extras. Often |
| 2418 | * null. |
| 2419 | * |
| 2420 | * @see #sendBroadcast(Intent) |
| 2421 | * @see #sendBroadcast(Intent, String) |
| 2422 | * @see #sendOrderedBroadcast(Intent, String) |
| 2423 | * @see #sendStickyBroadcast(Intent) |
| 2424 | * @see android.content.BroadcastReceiver |
| 2425 | * @see #registerReceiver |
| 2426 | * @see android.app.Activity#RESULT_OK |
| 2427 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2428 | @Deprecated |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 2429 | @RequiresPermission(android.Manifest.permission.BROADCAST_STICKY) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2430 | public abstract void sendStickyOrderedBroadcast(@RequiresPermission Intent intent, |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2431 | BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2432 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2433 | @Nullable Bundle initialExtras); |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2434 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2435 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2436 | * <p>Remove the data previously sent with {@link #sendStickyBroadcast}, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2437 | * so that it is as if the sticky broadcast had never happened. |
| 2438 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2439 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2440 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2441 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2442 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2443 | * desired. |
| 2444 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2445 | * @param intent The Intent that was previously broadcast. |
| 2446 | * |
| 2447 | * @see #sendStickyBroadcast |
| 2448 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2449 | @Deprecated |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 2450 | @RequiresPermission(android.Manifest.permission.BROADCAST_STICKY) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2451 | public abstract void removeStickyBroadcast(@RequiresPermission Intent intent); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2452 | |
| 2453 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2454 | * <p>Version of {@link #sendStickyBroadcast(Intent)} that allows you to specify the |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2455 | * 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] | 2456 | * that are not pre-installed on the system image. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2457 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2458 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2459 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2460 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2461 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2462 | * desired. |
| 2463 | * |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2464 | * @param intent The Intent to broadcast; all receivers matching this |
| 2465 | * Intent will receive the broadcast, and the Intent will be held to |
| 2466 | * be re-broadcast to future receivers. |
| 2467 | * @param user UserHandle to send the intent to. |
| 2468 | * |
| 2469 | * @see #sendBroadcast(Intent) |
| 2470 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2471 | @Deprecated |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2472 | @RequiresPermission(allOf = { |
| 2473 | android.Manifest.permission.INTERACT_ACROSS_USERS, |
| 2474 | android.Manifest.permission.BROADCAST_STICKY |
| 2475 | }) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2476 | public abstract void sendStickyBroadcastAsUser(@RequiresPermission Intent intent, |
| 2477 | UserHandle user); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2478 | |
| 2479 | /** |
Dianne Hackborn | e0e413e | 2015-12-09 17:22:26 -0800 | [diff] [blame] | 2480 | * @hide |
| 2481 | * This is just here for sending CONNECTIVITY_ACTION. |
| 2482 | */ |
| 2483 | @Deprecated |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2484 | @RequiresPermission(allOf = { |
| 2485 | android.Manifest.permission.INTERACT_ACROSS_USERS, |
| 2486 | android.Manifest.permission.BROADCAST_STICKY |
| 2487 | }) |
Dianne Hackborn | e0e413e | 2015-12-09 17:22:26 -0800 | [diff] [blame] | 2488 | public abstract void sendStickyBroadcastAsUser(@RequiresPermission Intent intent, |
| 2489 | UserHandle user, Bundle options); |
| 2490 | |
| 2491 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2492 | * <p>Version of |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2493 | * {@link #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)} |
| 2494 | * that allows you to specify the |
| 2495 | * 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] | 2496 | * that are not pre-installed on the system image. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2497 | * |
| 2498 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2499 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2500 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2501 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2502 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2503 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2504 | * desired. |
| 2505 | * |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2506 | * @param intent The Intent to broadcast; all receivers matching this |
| 2507 | * Intent will receive the broadcast. |
| 2508 | * @param user UserHandle to send the intent to. |
| 2509 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2510 | * receiver of the broadcast. |
| 2511 | * @param scheduler A custom Handler with which to schedule the |
| 2512 | * resultReceiver callback; if null it will be |
| 2513 | * scheduled in the Context's main thread. |
| 2514 | * @param initialCode An initial value for the result code. Often |
| 2515 | * Activity.RESULT_OK. |
| 2516 | * @param initialData An initial value for the result data. Often |
| 2517 | * null. |
| 2518 | * @param initialExtras An initial value for the result extras. Often |
| 2519 | * null. |
| 2520 | * |
| 2521 | * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle) |
| 2522 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2523 | @Deprecated |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2524 | @RequiresPermission(allOf = { |
| 2525 | android.Manifest.permission.INTERACT_ACROSS_USERS, |
| 2526 | android.Manifest.permission.BROADCAST_STICKY |
| 2527 | }) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2528 | public abstract void sendStickyOrderedBroadcastAsUser(@RequiresPermission Intent intent, |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2529 | UserHandle user, BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2530 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2531 | @Nullable Bundle initialExtras); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2532 | |
| 2533 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2534 | * <p>Version of {@link #removeStickyBroadcast(Intent)} that allows you to specify the |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2535 | * 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] | 2536 | * that are not pre-installed on the system image. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2537 | * |
| 2538 | * <p>You must hold the {@link android.Manifest.permission#BROADCAST_STICKY} |
| 2539 | * permission in order to use this API. If you do not hold that |
| 2540 | * permission, {@link SecurityException} will be thrown. |
| 2541 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2542 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2543 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2544 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2545 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2546 | * desired. |
| 2547 | * |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2548 | * @param intent The Intent that was previously broadcast. |
| 2549 | * @param user UserHandle to remove the sticky broadcast from. |
| 2550 | * |
| 2551 | * @see #sendStickyBroadcastAsUser |
| 2552 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2553 | @Deprecated |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2554 | @RequiresPermission(allOf = { |
| 2555 | android.Manifest.permission.INTERACT_ACROSS_USERS, |
| 2556 | android.Manifest.permission.BROADCAST_STICKY |
| 2557 | }) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2558 | public abstract void removeStickyBroadcastAsUser(@RequiresPermission Intent intent, |
| 2559 | UserHandle user); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2560 | |
| 2561 | /** |
Chris Tate | a34df8a2 | 2009-04-02 23:15:58 -0700 | [diff] [blame] | 2562 | * 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] | 2563 | * <var>receiver</var> will be called with any broadcast Intent that |
| 2564 | * matches <var>filter</var>, in the main application thread. |
| 2565 | * |
| 2566 | * <p>The system may broadcast Intents that are "sticky" -- these stay |
Kweku Adams | 86f39a4 | 2016-11-16 12:50:38 -0800 | [diff] [blame] | 2567 | * 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] | 2568 | * registrations. If your IntentFilter matches one of these sticky |
| 2569 | * Intents, that Intent will be returned by this function |
| 2570 | * <strong>and</strong> sent to your <var>receiver</var> as if it had just |
| 2571 | * been broadcast. |
| 2572 | * |
| 2573 | * <p>There may be multiple sticky Intents that match <var>filter</var>, |
| 2574 | * in which case each of these will be sent to <var>receiver</var>. In |
| 2575 | * this case, only one of these can be returned directly by the function; |
| 2576 | * which of these that is returned is arbitrarily decided by the system. |
| 2577 | * |
| 2578 | * <p>If you know the Intent your are registering for is sticky, you can |
| 2579 | * supply null for your <var>receiver</var>. In this case, no receiver is |
| 2580 | * registered -- the function simply returns the sticky Intent that |
| 2581 | * matches <var>filter</var>. In the case of multiple matches, the same |
| 2582 | * rules as described above apply. |
| 2583 | * |
| 2584 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2585 | * |
Dianne Hackborn | 6c418d5 | 2011-06-29 14:05:33 -0700 | [diff] [blame] | 2586 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 2587 | * registered with this method will correctly respect the |
| 2588 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 2589 | * Prior to that, it would be ignored and delivered to all matching registered |
| 2590 | * receivers. Be careful if using this for security.</p> |
| 2591 | * |
Chris Tate | a34df8a2 | 2009-04-02 23:15:58 -0700 | [diff] [blame] | 2592 | * <p class="note">Note: this method <em>cannot be called from a |
| 2593 | * {@link BroadcastReceiver} component;</em> that is, from a BroadcastReceiver |
| 2594 | * that is declared in an application's manifest. It is okay, however, to call |
| 2595 | * this method from another BroadcastReceiver that has itself been registered |
| 2596 | * at run time with {@link #registerReceiver}, since the lifetime of such a |
| 2597 | * 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] | 2598 | * |
| 2599 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2600 | * @param filter Selects the Intent broadcasts to be received. |
| 2601 | * |
| 2602 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2603 | * or null if there are none. |
| 2604 | * |
| 2605 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
| 2606 | * @see #sendBroadcast |
| 2607 | * @see #unregisterReceiver |
| 2608 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2609 | @Nullable |
| 2610 | public abstract Intent registerReceiver(@Nullable BroadcastReceiver receiver, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2611 | IntentFilter filter); |
| 2612 | |
| 2613 | /** |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2614 | * Register to receive intent broadcasts, with the receiver optionally being |
| 2615 | * exposed to Instant Apps. See |
| 2616 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter)} for more |
| 2617 | * information. By default Instant Apps cannot interact with receivers in other |
| 2618 | * applications, this allows you to expose a receiver that Instant Apps can |
| 2619 | * interact with. |
| 2620 | * |
| 2621 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2622 | * |
| 2623 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 2624 | * registered with this method will correctly respect the |
| 2625 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 2626 | * Prior to that, it would be ignored and delivered to all matching registered |
| 2627 | * receivers. Be careful if using this for security.</p> |
| 2628 | * |
| 2629 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2630 | * @param filter Selects the Intent broadcasts to be received. |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2631 | * @param flags Additional options for the receiver. May be 0 or |
| 2632 | * {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2633 | * |
| 2634 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2635 | * or null if there are none. |
| 2636 | * |
| 2637 | * @see #registerReceiver(BroadcastReceiver, IntentFilter) |
| 2638 | * @see #sendBroadcast |
| 2639 | * @see #unregisterReceiver |
| 2640 | */ |
| 2641 | @Nullable |
| 2642 | public abstract Intent registerReceiver(@Nullable BroadcastReceiver receiver, |
| 2643 | IntentFilter filter, |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2644 | @RegisterReceiverFlags int flags); |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2645 | |
| 2646 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2647 | * Register to receive intent broadcasts, to run in the context of |
| 2648 | * <var>scheduler</var>. See |
| 2649 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter)} for more |
| 2650 | * information. This allows you to enforce permissions on who can |
| 2651 | * broadcast intents to your receiver, or have the receiver run in |
| 2652 | * a different thread than the main application thread. |
| 2653 | * |
| 2654 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2655 | * |
Dianne Hackborn | 6c418d5 | 2011-06-29 14:05:33 -0700 | [diff] [blame] | 2656 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 2657 | * registered with this method will correctly respect the |
| 2658 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 2659 | * Prior to that, it would be ignored and delivered to all matching registered |
| 2660 | * receivers. Be careful if using this for security.</p> |
| 2661 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2662 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2663 | * @param filter Selects the Intent broadcasts to be received. |
| 2664 | * @param broadcastPermission String naming a permissions that a |
| 2665 | * broadcaster must hold in order to send an Intent to you. If null, |
| 2666 | * no permission is required. |
| 2667 | * @param scheduler Handler identifying the thread that will receive |
| 2668 | * the Intent. If null, the main thread of the process will be used. |
| 2669 | * |
| 2670 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2671 | * or null if there are none. |
| 2672 | * |
| 2673 | * @see #registerReceiver(BroadcastReceiver, IntentFilter) |
| 2674 | * @see #sendBroadcast |
| 2675 | * @see #unregisterReceiver |
| 2676 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2677 | @Nullable |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2678 | public abstract Intent registerReceiver(BroadcastReceiver receiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2679 | IntentFilter filter, @Nullable String broadcastPermission, |
| 2680 | @Nullable Handler scheduler); |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2681 | |
| 2682 | /** |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2683 | * Register to receive intent broadcasts, to run in the context of |
| 2684 | * <var>scheduler</var>. See |
| 2685 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter, int)} and |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2686 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler)} |
| 2687 | * for more information. |
| 2688 | * |
| 2689 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2690 | * |
| 2691 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 2692 | * registered with this method will correctly respect the |
| 2693 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 2694 | * Prior to that, it would be ignored and delivered to all matching registered |
| 2695 | * receivers. Be careful if using this for security.</p> |
| 2696 | * |
| 2697 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2698 | * @param filter Selects the Intent broadcasts to be received. |
| 2699 | * @param broadcastPermission String naming a permissions that a |
| 2700 | * broadcaster must hold in order to send an Intent to you. If null, |
| 2701 | * no permission is required. |
| 2702 | * @param scheduler Handler identifying the thread that will receive |
| 2703 | * 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] | 2704 | * @param flags Additional options for the receiver. May be 0 or |
| 2705 | * {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2706 | * |
| 2707 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2708 | * or null if there are none. |
| 2709 | * |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2710 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, int) |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2711 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
| 2712 | * @see #sendBroadcast |
| 2713 | * @see #unregisterReceiver |
| 2714 | */ |
| 2715 | @Nullable |
| 2716 | public abstract Intent registerReceiver(BroadcastReceiver receiver, |
| 2717 | IntentFilter filter, @Nullable String broadcastPermission, |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2718 | @Nullable Handler scheduler, @RegisterReceiverFlags int flags); |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2719 | |
| 2720 | /** |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2721 | * @hide |
| 2722 | * Same as {@link #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
| 2723 | * but for a specific user. This receiver will receiver broadcasts that |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2724 | * are sent to the requested user. |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2725 | * |
| 2726 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2727 | * @param user UserHandle to send the intent to. |
| 2728 | * @param filter Selects the Intent broadcasts to be received. |
| 2729 | * @param broadcastPermission String naming a permissions that a |
| 2730 | * broadcaster must hold in order to send an Intent to you. If null, |
| 2731 | * no permission is required. |
| 2732 | * @param scheduler Handler identifying the thread that will receive |
| 2733 | * the Intent. If null, the main thread of the process will be used. |
| 2734 | * |
| 2735 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2736 | * or null if there are none. |
| 2737 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 2738 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2739 | * @see #sendBroadcast |
| 2740 | * @see #unregisterReceiver |
| 2741 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2742 | @Nullable |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2743 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 2744 | @UnsupportedAppUsage |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2745 | public abstract Intent registerReceiverAsUser(BroadcastReceiver receiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2746 | UserHandle user, IntentFilter filter, @Nullable String broadcastPermission, |
| 2747 | @Nullable Handler scheduler); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2748 | |
| 2749 | /** |
| 2750 | * Unregister a previously registered BroadcastReceiver. <em>All</em> |
| 2751 | * filters that have been registered for this BroadcastReceiver will be |
| 2752 | * removed. |
| 2753 | * |
| 2754 | * @param receiver The BroadcastReceiver to unregister. |
| 2755 | * |
| 2756 | * @see #registerReceiver |
| 2757 | */ |
| 2758 | public abstract void unregisterReceiver(BroadcastReceiver receiver); |
| 2759 | |
| 2760 | /** |
| 2761 | * Request that a given application service be started. The Intent |
Hans Boehm | fb9f6ac | 2016-05-05 13:09:28 -0700 | [diff] [blame] | 2762 | * should either contain the complete class name of a specific service |
| 2763 | * implementation to start, or a specific package name to target. If the |
| 2764 | * Intent is less specified, it logs a warning about this. In this case any of the |
| 2765 | * multiple matching services may be used. If this service |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2766 | * is not already running, it will be instantiated and started (creating a |
| 2767 | * process for it if needed); if it is running then it remains running. |
| 2768 | * |
| 2769 | * <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] | 2770 | * 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] | 2771 | * with the <var>intent</var> given here. This provides a convenient way |
| 2772 | * to submit jobs to a service without having to bind and call on to its |
| 2773 | * interface. |
| 2774 | * |
| 2775 | * <p>Using startService() overrides the default service lifetime that is |
| 2776 | * managed by {@link #bindService}: it requires the service to remain |
| 2777 | * running until {@link #stopService} is called, regardless of whether |
| 2778 | * any clients are connected to it. Note that calls to startService() |
Hans Boehm | fb9f6ac | 2016-05-05 13:09:28 -0700 | [diff] [blame] | 2779 | * 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] | 2780 | * a single call to {@link #stopService} will stop it. |
| 2781 | * |
| 2782 | * <p>The system attempts to keep running services around as much as |
| 2783 | * possible. The only time they should be stopped is if the current |
| 2784 | * foreground application is using so many resources that the service needs |
| 2785 | * to be killed. If any errors happen in the service's process, it will |
| 2786 | * automatically be restarted. |
| 2787 | * |
| 2788 | * <p>This function will throw {@link SecurityException} if you do not |
| 2789 | * have permission to start the given service. |
| 2790 | * |
Chris Craik | 1e35352 | 2016-04-18 10:20:50 -0700 | [diff] [blame] | 2791 | * <p class="note"><strong>Note:</strong> Each call to startService() |
| 2792 | * results in significant work done by the system to manage service |
| 2793 | * lifecycle surrounding the processing of the intent, which can take |
| 2794 | * multiple milliseconds of CPU time. Due to this cost, startService() |
| 2795 | * should not be used for frequent intent delivery to a service, and only |
| 2796 | * for scheduling significant work. Use {@link #bindService bound services} |
| 2797 | * for high frequency calls. |
| 2798 | * </p> |
| 2799 | * |
Mark Lu | 94ebbe0 | 2016-12-13 16:29:51 -0800 | [diff] [blame] | 2800 | * @param service Identifies the service to be started. The Intent must be |
| 2801 | * fully explicit (supplying a component name). Additional values |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2802 | * may be included in the Intent extras to supply arguments along with |
| 2803 | * this specific start call. |
| 2804 | * |
| 2805 | * @return If the service is being started or is already running, the |
| 2806 | * {@link ComponentName} of the actual service that was started is |
| 2807 | * returned; else if the service does not exist null is returned. |
| 2808 | * |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2809 | * @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] | 2810 | * or the service can not be found. |
| 2811 | * @throws IllegalStateException If the application is in a state where the service |
| 2812 | * 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] | 2813 | * |
| 2814 | * @see #stopService |
| 2815 | * @see #bindService |
| 2816 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2817 | @Nullable |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2818 | public abstract ComponentName startService(Intent service); |
| 2819 | |
| 2820 | /** |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2821 | * Similar to {@link #startService(Intent)}, but with an implicit promise that the |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 2822 | * Service will call {@link android.app.Service#startForeground(int, android.app.Notification) |
| 2823 | * 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] | 2824 | * an amount of time comparable to the ANR interval to do this, otherwise the system |
| 2825 | * will automatically stop the service and declare the app ANR. |
| 2826 | * |
| 2827 | * <p>Unlike the ordinary {@link #startService(Intent)}, this method can be used |
| 2828 | * at any time, regardless of whether the app hosting the service is in a foreground |
| 2829 | * state. |
| 2830 | * |
| 2831 | * @param service Identifies the service to be started. The Intent must be |
| 2832 | * fully explicit (supplying a component name). Additional values |
| 2833 | * may be included in the Intent extras to supply arguments along with |
| 2834 | * this specific start call. |
| 2835 | * |
| 2836 | * @return If the service is being started or is already running, the |
| 2837 | * {@link ComponentName} of the actual service that was started is |
| 2838 | * returned; else if the service does not exist null is returned. |
| 2839 | * |
| 2840 | * @throws SecurityException If the caller does not have permission to access the service |
| 2841 | * or the service can not be found. |
| 2842 | * |
| 2843 | * @see #stopService |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 2844 | * @see android.app.Service#startForeground(int, android.app.Notification) |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2845 | */ |
| 2846 | @Nullable |
| 2847 | public abstract ComponentName startForegroundService(Intent service); |
| 2848 | |
| 2849 | /** |
| 2850 | * @hide like {@link #startForegroundService(Intent)} but for a specific user. |
| 2851 | */ |
| 2852 | @Nullable |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2853 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2854 | public abstract ComponentName startForegroundServiceAsUser(Intent service, UserHandle user); |
| 2855 | |
| 2856 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2857 | * Request that a given application service be stopped. If the service is |
| 2858 | * not running, nothing happens. Otherwise it is stopped. Note that calls |
| 2859 | * to startService() are not counted -- this stops the service no matter |
| 2860 | * how many times it was started. |
| 2861 | * |
| 2862 | * <p>Note that if a stopped service still has {@link ServiceConnection} |
| 2863 | * objects bound to it with the {@link #BIND_AUTO_CREATE} set, it will |
| 2864 | * not be destroyed until all of these bindings are removed. See |
| 2865 | * the {@link android.app.Service} documentation for more details on a |
| 2866 | * service's lifecycle. |
| 2867 | * |
| 2868 | * <p>This function will throw {@link SecurityException} if you do not |
| 2869 | * have permission to stop the given service. |
| 2870 | * |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 2871 | * @param service Description of the service to be stopped. The Intent must be either |
| 2872 | * fully explicit (supplying a component name) or specify a specific package |
kopriva | 219f7dc | 2018-10-09 13:42:28 -0700 | [diff] [blame] | 2873 | * name it is targeted to. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2874 | * |
| 2875 | * @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] | 2876 | * 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] | 2877 | * |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2878 | * @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] | 2879 | * or the service can not be found. |
| 2880 | * @throws IllegalStateException If the application is in a state where the service |
| 2881 | * 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] | 2882 | * |
| 2883 | * @see #startService |
| 2884 | */ |
| 2885 | public abstract boolean stopService(Intent service); |
| 2886 | |
| 2887 | /** |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 2888 | * @hide like {@link #startService(Intent)} but for a specific user. |
| 2889 | */ |
Christopher Tate | 42a386b | 2016-11-07 12:21:21 -0800 | [diff] [blame] | 2890 | @Nullable |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2891 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 2892 | @UnsupportedAppUsage |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 2893 | public abstract ComponentName startServiceAsUser(Intent service, UserHandle user); |
| 2894 | |
| 2895 | /** |
| 2896 | * @hide like {@link #stopService(Intent)} but for a specific user. |
| 2897 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2898 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 2899 | public abstract boolean stopServiceAsUser(Intent service, UserHandle user); |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 2900 | |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 2901 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2902 | * Connect to an application service, creating it if needed. This defines |
| 2903 | * a dependency between your application and the service. The given |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 2904 | * <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] | 2905 | * told if it dies and restarts. The service will be considered required |
| 2906 | * by the system only for as long as the calling context exists. For |
| 2907 | * example, if this Context is an Activity that is stopped, the service will |
| 2908 | * not be required to continue running until the Activity is resumed. |
| 2909 | * |
Christopher Tate | 5d73b6d | 2017-10-06 16:15:34 -0700 | [diff] [blame] | 2910 | * <p>If the service does not support binding, it may return {@code null} from |
| 2911 | * its {@link android.app.Service#onBind(Intent) onBind()} method. If it does, then |
| 2912 | * the ServiceConnection's |
| 2913 | * {@link ServiceConnection#onNullBinding(ComponentName) onNullBinding()} method |
| 2914 | * will be invoked instead of |
| 2915 | * {@link ServiceConnection#onServiceConnected(ComponentName, IBinder) onServiceConnected()}. |
| 2916 | * |
| 2917 | * <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] | 2918 | * have permission to bind to the given service. |
| 2919 | * |
Christopher Tate | 5d73b6d | 2017-10-06 16:15:34 -0700 | [diff] [blame] | 2920 | * <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] | 2921 | * {@link BroadcastReceiver} component</em>. A pattern you can use to |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 2922 | * 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] | 2923 | * {@link #startService} with the arguments containing the command to be |
| 2924 | * sent, with the service calling its |
| 2925 | * {@link android.app.Service#stopSelf(int)} method when done executing |
| 2926 | * that command. See the API demo App/Service/Service Start Arguments |
| 2927 | * Controller for an illustration of this. It is okay, however, to use |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 2928 | * 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] | 2929 | * {@link #registerReceiver}, since the lifetime of this BroadcastReceiver |
| 2930 | * is tied to another object (the one that registered it).</p> |
| 2931 | * |
Mark Lu | 94ebbe0 | 2016-12-13 16:29:51 -0800 | [diff] [blame] | 2932 | * @param service Identifies the service to connect to. The Intent must |
| 2933 | * specify an explicit component name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2934 | * @param conn Receives information as the service is started and stopped. |
Christopher Tate | 79b3317 | 2012-06-18 14:54:21 -0700 | [diff] [blame] | 2935 | * This must be a valid ServiceConnection object; it must not be null. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2936 | * @param flags Operation options for the binding. May be 0, |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 2937 | * {@link #BIND_AUTO_CREATE}, {@link #BIND_DEBUG_UNBIND}, |
| 2938 | * {@link #BIND_NOT_FOREGROUND}, {@link #BIND_ABOVE_CLIENT}, |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 2939 | * {@link #BIND_ALLOW_OOM_MANAGEMENT}, {@link #BIND_WAIVE_PRIORITY}. |
| 2940 | * {@link #BIND_IMPORTANT}, or |
| 2941 | * {@link #BIND_ADJUST_WITH_ACTIVITY}. |
Kevin Hufnagle | 34acbc9b | 2017-06-29 15:58:48 -0700 | [diff] [blame] | 2942 | * @return {@code true} if the system is in the process of bringing up a |
| 2943 | * service that your client has permission to bind to; {@code false} |
| 2944 | * if the system couldn't find the service or if your client doesn't |
| 2945 | * have permission to bind to it. If this value is {@code true}, you |
| 2946 | * should later call {@link #unbindService} to release the |
| 2947 | * connection. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2948 | * |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2949 | * @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] | 2950 | * or the service can not be found. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2951 | * |
| 2952 | * @see #unbindService |
| 2953 | * @see #startService |
| 2954 | * @see #BIND_AUTO_CREATE |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2955 | * @see #BIND_DEBUG_UNBIND |
| 2956 | * @see #BIND_NOT_FOREGROUND |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 2957 | * @see #BIND_ABOVE_CLIENT |
| 2958 | * @see #BIND_ALLOW_OOM_MANAGEMENT |
| 2959 | * @see #BIND_WAIVE_PRIORITY |
| 2960 | * @see #BIND_IMPORTANT |
| 2961 | * @see #BIND_ADJUST_WITH_ACTIVITY |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2962 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2963 | public abstract boolean bindService(@RequiresPermission Intent service, |
| 2964 | @NonNull ServiceConnection conn, @BindServiceFlags int flags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2965 | |
| 2966 | /** |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 2967 | * Variation of {@link #bindService} that, in the specific case of isolated |
| 2968 | * services, allows the caller to generate multiple instances of a service |
| 2969 | * from a single component declaration. |
| 2970 | * |
| 2971 | * @param service Identifies the service to connect to. The Intent must |
| 2972 | * specify an explicit component name. |
| 2973 | * @param conn Receives information as the service is started and stopped. |
| 2974 | * This must be a valid ServiceConnection object; it must not be null. |
| 2975 | * @param flags Operation options for the binding as per {@link #bindService}. |
| 2976 | * @param instanceName Unique identifier for the service instance. Each unique |
| 2977 | * name here will result in a different service instance being created. |
| 2978 | * @return Returns success of binding as per {@link #bindService}. |
| 2979 | * |
| 2980 | * @throws SecurityException If the caller does not have permission to access the service |
| 2981 | * |
| 2982 | * @see #bindService |
| 2983 | */ |
Adrian Roos | fe6aeaf | 2019-01-22 16:58:56 +0100 | [diff] [blame] | 2984 | public boolean bindIsolatedService(@RequiresPermission Intent service, |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 2985 | @NonNull ServiceConnection conn, @BindServiceFlags int flags, |
Adrian Roos | fe6aeaf | 2019-01-22 16:58:56 +0100 | [diff] [blame] | 2986 | @NonNull String instanceName) { |
| 2987 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 2988 | } |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 2989 | |
| 2990 | /** |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2991 | * Same as {@link #bindService(Intent, ServiceConnection, int)}, but with an explicit userHandle |
Amith Yamasani | 37ce3a8 | 2012-02-06 12:04:42 -0800 | [diff] [blame] | 2992 | * argument for use by system server and other multi-user aware code. |
| 2993 | * @hide |
| 2994 | */ |
Amith Yamasani | c85029f | 2014-09-11 16:47:17 -0700 | [diff] [blame] | 2995 | @SystemApi |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 2996 | @SuppressWarnings("unused") |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2997 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2998 | public boolean bindServiceAsUser(@RequiresPermission Intent service, ServiceConnection conn, |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 2999 | int flags, UserHandle user) { |
Amith Yamasani | 37ce3a8 | 2012-02-06 12:04:42 -0800 | [diff] [blame] | 3000 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 3001 | } |
| 3002 | |
| 3003 | /** |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3004 | * Same as {@link #bindServiceAsUser(Intent, ServiceConnection, int, UserHandle)}, but with an |
Adrian Roos | 691546e | 2016-02-09 10:13:41 -0800 | [diff] [blame] | 3005 | * explicit non-null Handler to run the ServiceConnection callbacks on. |
| 3006 | * |
| 3007 | * @hide |
| 3008 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 3009 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 3010 | @UnsupportedAppUsage |
Adrian Roos | 691546e | 2016-02-09 10:13:41 -0800 | [diff] [blame] | 3011 | public boolean bindServiceAsUser(Intent service, ServiceConnection conn, int flags, |
| 3012 | Handler handler, UserHandle user) { |
| 3013 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 3014 | } |
| 3015 | |
| 3016 | /** |
Dianne Hackborn | a631d56 | 2018-11-20 15:58:15 -0800 | [diff] [blame] | 3017 | * For a service previously bound with {@link #bindService} or a related method, change |
| 3018 | * how the system manages that service's process in relation to other processes. This |
| 3019 | * doesn't modify the original bind flags that were passed in when binding, but adjusts |
| 3020 | * how the process will be managed in some cases based on those flags. Currently only |
| 3021 | * works on isolated processes (will be ignored for non-isolated processes). |
| 3022 | * |
Dianne Hackborn | 2f55e5a | 2018-11-30 16:31:31 -0800 | [diff] [blame] | 3023 | * <p>Note that this call does not take immediate effect, but will be applied the next |
| 3024 | * time the impacted process is adjusted for some other reason. Typically you would |
| 3025 | * call this before then calling a new {@link #bindIsolatedService} on the service |
| 3026 | * of interest, with that binding causing the process to be shuffled accordingly.</p> |
| 3027 | * |
Dianne Hackborn | a631d56 | 2018-11-20 15:58:15 -0800 | [diff] [blame] | 3028 | * @param conn The connection interface previously supplied to bindService(). This |
| 3029 | * parameter must not be null. |
| 3030 | * @param group A group to put this connection's process in. Upon calling here, this |
| 3031 | * will override any previous group that was set for that process. The group |
| 3032 | * tells the system about processes that are logically grouped together, so |
| 3033 | * should be managed as one unit of importance (such as when being considered |
| 3034 | * a recently used app). All processes in the same app with the same group |
| 3035 | * are considered to be related. Supplying 0 reverts to the default behavior |
| 3036 | * of not grouping. |
| 3037 | * @param importance Additional importance of the processes within a group. Upon calling |
| 3038 | * here, this will override any previous group that was set for that |
| 3039 | * process. This fine-tunes process killing of all processes within |
| 3040 | * a related groups -- higher importance values will be killed before |
| 3041 | * lower ones. |
| 3042 | */ |
Adrian Roos | fe6aeaf | 2019-01-22 16:58:56 +0100 | [diff] [blame] | 3043 | public void updateServiceGroup(@NonNull ServiceConnection conn, int group, |
| 3044 | int importance) { |
| 3045 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 3046 | } |
Dianne Hackborn | a631d56 | 2018-11-20 15:58:15 -0800 | [diff] [blame] | 3047 | |
| 3048 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3049 | * Disconnect from an application service. You will no longer receive |
| 3050 | * calls as the service is restarted, and the service is now allowed to |
| 3051 | * stop at any time. |
| 3052 | * |
| 3053 | * @param conn The connection interface previously supplied to |
Christopher Tate | 79b3317 | 2012-06-18 14:54:21 -0700 | [diff] [blame] | 3054 | * bindService(). This parameter must not be null. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3055 | * |
| 3056 | * @see #bindService |
| 3057 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3058 | public abstract void unbindService(@NonNull ServiceConnection conn); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3059 | |
| 3060 | /** |
| 3061 | * Start executing an {@link android.app.Instrumentation} class. The given |
| 3062 | * Instrumentation component will be run by killing its target application |
| 3063 | * (if currently running), starting the target process, instantiating the |
| 3064 | * instrumentation component, and then letting it drive the application. |
| 3065 | * |
| 3066 | * <p>This function is not synchronous -- it returns as soon as the |
| 3067 | * instrumentation has started and while it is running. |
| 3068 | * |
| 3069 | * <p>Instrumentation is normally only allowed to run against a package |
| 3070 | * that is either unsigned or signed with a signature that the |
| 3071 | * the instrumentation package is also signed with (ensuring the target |
| 3072 | * trusts the instrumentation). |
| 3073 | * |
| 3074 | * @param className Name of the Instrumentation component to be run. |
| 3075 | * @param profileFile Optional path to write profiling data as the |
| 3076 | * instrumentation runs, or null for no profiling. |
| 3077 | * @param arguments Additional optional arguments to pass to the |
| 3078 | * instrumentation, or null. |
| 3079 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3080 | * @return {@code true} if the instrumentation was successfully started, |
| 3081 | * else {@code false} if it could not be found. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3082 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3083 | public abstract boolean startInstrumentation(@NonNull ComponentName className, |
| 3084 | @Nullable String profileFile, @Nullable Bundle arguments); |
| 3085 | |
| 3086 | /** @hide */ |
Jeff Sharkey | 5db9a91 | 2017-12-08 17:32:32 -0700 | [diff] [blame] | 3087 | @StringDef(suffix = { "_SERVICE" }, value = { |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3088 | POWER_SERVICE, |
| 3089 | WINDOW_SERVICE, |
| 3090 | LAYOUT_INFLATER_SERVICE, |
| 3091 | ACCOUNT_SERVICE, |
| 3092 | ACTIVITY_SERVICE, |
| 3093 | ALARM_SERVICE, |
| 3094 | NOTIFICATION_SERVICE, |
| 3095 | ACCESSIBILITY_SERVICE, |
| 3096 | CAPTIONING_SERVICE, |
| 3097 | KEYGUARD_SERVICE, |
| 3098 | LOCATION_SERVICE, |
| 3099 | //@hide: COUNTRY_DETECTOR, |
| 3100 | SEARCH_SERVICE, |
| 3101 | SENSOR_SERVICE, |
Chad Brubaker | 90f391f | 2018-10-19 10:26:19 -0700 | [diff] [blame] | 3102 | SENSOR_PRIVACY_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3103 | STORAGE_SERVICE, |
Jeff Sharkey | e8cece9 | 2017-01-04 11:33:33 -0700 | [diff] [blame] | 3104 | STORAGE_STATS_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3105 | WALLPAPER_SERVICE, |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 3106 | TIME_ZONE_RULES_MANAGER_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3107 | VIBRATOR_SERVICE, |
| 3108 | //@hide: STATUS_BAR_SERVICE, |
| 3109 | CONNECTIVITY_SERVICE, |
Chalard Jean | 8c141bd | 2018-12-04 20:20:56 +0900 | [diff] [blame] | 3110 | //@hide: IP_MEMORY_STORE_SERVICE, |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 3111 | IPSEC_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3112 | //@hide: UPDATE_LOCK_SERVICE, |
| 3113 | //@hide: NETWORKMANAGEMENT_SERVICE, |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3114 | NETWORK_STATS_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3115 | //@hide: NETWORK_POLICY_SERVICE, |
| 3116 | WIFI_SERVICE, |
Etan Cohen | 0413327 | 2016-10-26 11:22:06 -0700 | [diff] [blame] | 3117 | WIFI_AWARE_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3118 | WIFI_P2P_SERVICE, |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 3119 | WIFI_SCANNING_SERVICE, |
Robert Quattlebaum | 87a7104 | 2017-05-15 15:45:20 -0700 | [diff] [blame] | 3120 | //@hide: LOWPAN_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3121 | //@hide: WIFI_RTT_SERVICE, |
Lorenzo Colitti | bd8a374 | 2014-05-22 11:51:27 -0700 | [diff] [blame] | 3122 | //@hide: ETHERNET_SERVICE, |
Etan Cohen | 46efb48 | 2017-12-07 13:50:57 -0800 | [diff] [blame] | 3123 | WIFI_RTT_RANGING_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3124 | NSD_SERVICE, |
| 3125 | AUDIO_SERVICE, |
Jim Miller | ce7eb6d | 2015-04-03 19:29:13 -0700 | [diff] [blame] | 3126 | FINGERPRINT_SERVICE, |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 3127 | //@hide: FACE_SERVICE, |
Kevin Chyn | 05c2150 | 2018-09-18 13:07:19 -0700 | [diff] [blame] | 3128 | BIOMETRIC_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3129 | MEDIA_ROUTER_SERVICE, |
| 3130 | TELEPHONY_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3131 | TELEPHONY_SUBSCRIPTION_SERVICE, |
Jonathan Basseri | 9a1c9b6 | 2015-02-25 13:01:52 -0800 | [diff] [blame] | 3132 | CARRIER_CONFIG_SERVICE, |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 3133 | TELECOM_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3134 | CLIPBOARD_SERVICE, |
| 3135 | INPUT_METHOD_SERVICE, |
| 3136 | TEXT_SERVICES_MANAGER_SERVICE, |
Abodunrinwa Toki | 3de110b | 2017-05-04 16:29:04 +0100 | [diff] [blame] | 3137 | TEXT_CLASSIFICATION_SERVICE, |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 3138 | APPWIDGET_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3139 | //@hide: VOICE_INTERACTION_MANAGER_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3140 | //@hide: BACKUP_SERVICE, |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 3141 | ROLLBACK_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3142 | DROPBOX_SERVICE, |
Dianne Hackborn | 1958e5e | 2015-06-12 18:11:41 -0700 | [diff] [blame] | 3143 | //@hide: DEVICE_IDLE_CONTROLLER, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3144 | DEVICE_POLICY_SERVICE, |
| 3145 | UI_MODE_SERVICE, |
| 3146 | DOWNLOAD_SERVICE, |
| 3147 | NFC_SERVICE, |
| 3148 | BLUETOOTH_SERVICE, |
| 3149 | //@hide: SIP_SERVICE, |
| 3150 | USB_SERVICE, |
Amith Yamasani | 4f58263 | 2014-02-19 14:31:52 -0800 | [diff] [blame] | 3151 | LAUNCHER_APPS_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3152 | //@hide: SERIAL_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3153 | //@hide: HDMI_CONTROL_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3154 | INPUT_SERVICE, |
| 3155 | DISPLAY_SERVICE, |
Christine Franks | 39b0311 | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 3156 | //@hide COLOR_DISPLAY_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3157 | USER_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3158 | RESTRICTIONS_SERVICE, |
| 3159 | APP_OPS_SERVICE, |
Hai Zhang | b777668 | 2018-09-25 15:10:57 -0700 | [diff] [blame] | 3160 | ROLE_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3161 | CAMERA_SERVICE, |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 3162 | PRINT_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3163 | CONSUMER_IR_SERVICE, |
| 3164 | //@hide: TRUST_SERVICE, |
| 3165 | TV_INPUT_SERVICE, |
| 3166 | //@hide: NETWORK_SCORE_SERVICE, |
| 3167 | USAGE_STATS_SERVICE, |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 3168 | MEDIA_SESSION_SERVICE, |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 3169 | BATTERY_SERVICE, |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 3170 | JOB_SCHEDULER_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3171 | //@hide: PERSISTENT_DATA_BLOCK_SERVICE, |
Andrew Scull | 3b8b46f | 2017-02-13 18:12:15 +0000 | [diff] [blame] | 3172 | //@hide: OEM_LOCK_SERVICE, |
Michael Wright | 446e019 | 2014-12-22 09:38:43 -0800 | [diff] [blame] | 3173 | MEDIA_PROJECTION_SERVICE, |
Mike Lockwood | 67f8e8b | 2014-12-01 13:54:59 -0800 | [diff] [blame] | 3174 | MIDI_SERVICE, |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 3175 | RADIO_SERVICE, |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 3176 | HARDWARE_PROPERTIES_SERVICE, |
Arunesh Mishra | a772e5f | 2016-01-25 10:33:11 -0800 | [diff] [blame] | 3177 | //@hide: SOUND_TRIGGER_SERVICE, |
Makoto Onuki | 6f7362d9 | 2016-03-04 13:39:41 -0800 | [diff] [blame] | 3178 | SHORTCUT_SERVICE, |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 3179 | //@hide: CONTEXTHUB_SERVICE, |
Joe Onorato | 1754d74 | 2016-11-21 17:51:35 -0800 | [diff] [blame] | 3180 | SYSTEM_HEALTH_SERVICE, |
Tor Norbye | 8246c07 | 2017-07-07 10:21:09 -0700 | [diff] [blame] | 3181 | //@hide: INCIDENT_SERVICE, |
Joe Onorato | e21ab7e | 2018-12-18 15:00:25 -0800 | [diff] [blame] | 3182 | //@hide: INCIDENT_COMPANION_SERVICE, |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 3183 | //@hide: STATS_COMPANION_SERVICE, |
Tony Mak | 9240c7f | 2017-12-29 11:02:02 +0000 | [diff] [blame] | 3184 | COMPANION_DEVICE_SERVICE, |
Tao Bao | 07342dc | 2017-01-24 15:08:21 -0800 | [diff] [blame] | 3185 | CROSS_PROFILE_APPS_SERVICE, |
| 3186 | //@hide: SYSTEM_UPDATE_SERVICE, |
Neil Fuller | feeee68 | 2018-05-30 14:35:24 +0100 | [diff] [blame] | 3187 | //@hide: TIME_DETECTOR_SERVICE, |
Philip P. Moltmann | 039678e | 2018-09-18 13:04:38 -0700 | [diff] [blame] | 3188 | PERMISSION_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3189 | }) |
| 3190 | @Retention(RetentionPolicy.SOURCE) |
| 3191 | public @interface ServiceName {} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3192 | |
| 3193 | /** |
| 3194 | * Return the handle to a system-level service by name. The class of the |
| 3195 | * returned object varies by the requested name. Currently available names |
| 3196 | * are: |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3197 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3198 | * <dl> |
| 3199 | * <dt> {@link #WINDOW_SERVICE} ("window") |
| 3200 | * <dd> The top-level window manager in which you can place custom |
| 3201 | * windows. The returned object is a {@link android.view.WindowManager}. |
| 3202 | * <dt> {@link #LAYOUT_INFLATER_SERVICE} ("layout_inflater") |
| 3203 | * <dd> A {@link android.view.LayoutInflater} for inflating layout resources |
| 3204 | * in this context. |
| 3205 | * <dt> {@link #ACTIVITY_SERVICE} ("activity") |
| 3206 | * <dd> A {@link android.app.ActivityManager} for interacting with the |
| 3207 | * global activity state of the system. |
| 3208 | * <dt> {@link #POWER_SERVICE} ("power") |
| 3209 | * <dd> A {@link android.os.PowerManager} for controlling power |
| 3210 | * management. |
| 3211 | * <dt> {@link #ALARM_SERVICE} ("alarm") |
| 3212 | * <dd> A {@link android.app.AlarmManager} for receiving intents at the |
| 3213 | * time of your choosing. |
| 3214 | * <dt> {@link #NOTIFICATION_SERVICE} ("notification") |
| 3215 | * <dd> A {@link android.app.NotificationManager} for informing the user |
| 3216 | * of background events. |
| 3217 | * <dt> {@link #KEYGUARD_SERVICE} ("keyguard") |
| 3218 | * <dd> A {@link android.app.KeyguardManager} for controlling keyguard. |
| 3219 | * <dt> {@link #LOCATION_SERVICE} ("location") |
| 3220 | * <dd> A {@link android.location.LocationManager} for controlling location |
| 3221 | * (e.g., GPS) updates. |
| 3222 | * <dt> {@link #SEARCH_SERVICE} ("search") |
| 3223 | * <dd> A {@link android.app.SearchManager} for handling search. |
| 3224 | * <dt> {@link #VIBRATOR_SERVICE} ("vibrator") |
| 3225 | * <dd> A {@link android.os.Vibrator} for interacting with the vibrator |
| 3226 | * hardware. |
| 3227 | * <dt> {@link #CONNECTIVITY_SERVICE} ("connection") |
| 3228 | * <dd> A {@link android.net.ConnectivityManager ConnectivityManager} for |
| 3229 | * handling management of network connections. |
Nathan Harold | d999d22 | 2017-09-11 19:53:33 -0700 | [diff] [blame] | 3230 | * <dt> {@link #IPSEC_SERVICE} ("ipsec") |
| 3231 | * <dd> A {@link android.net.IpSecManager IpSecManager} for managing IPSec on |
| 3232 | * sockets and networks. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3233 | * <dt> {@link #WIFI_SERVICE} ("wifi") |
Paul Stewart | 0e164b1 | 2016-08-08 10:20:13 -0700 | [diff] [blame] | 3234 | * <dd> A {@link android.net.wifi.WifiManager WifiManager} for management of Wi-Fi |
| 3235 | * connectivity. On releases before NYC, it should only be obtained from an application |
| 3236 | * context, and not from any other derived context to avoid memory leaks within the calling |
| 3237 | * process. |
Etan Cohen | 6a4b323 | 2017-01-09 21:47:32 -0800 | [diff] [blame] | 3238 | * <dt> {@link #WIFI_AWARE_SERVICE} ("wifiaware") |
| 3239 | * <dd> A {@link android.net.wifi.aware.WifiAwareManager WifiAwareManager} for management of |
| 3240 | * Wi-Fi Aware discovery and connectivity. |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 3241 | * <dt> {@link #WIFI_P2P_SERVICE} ("wifip2p") |
| 3242 | * <dd> A {@link android.net.wifi.p2p.WifiP2pManager WifiP2pManager} for management of |
| 3243 | * Wi-Fi Direct connectivity. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3244 | * <dt> {@link #INPUT_METHOD_SERVICE} ("input_method") |
| 3245 | * <dd> An {@link android.view.inputmethod.InputMethodManager InputMethodManager} |
| 3246 | * for management of input methods. |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 3247 | * <dt> {@link #UI_MODE_SERVICE} ("uimode") |
| 3248 | * <dd> An {@link android.app.UiModeManager} for controlling UI modes. |
Steve Howard | 7083c42 | 2010-07-28 16:01:23 -0700 | [diff] [blame] | 3249 | * <dt> {@link #DOWNLOAD_SERVICE} ("download") |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 3250 | * <dd> A {@link android.app.DownloadManager} for requesting HTTP downloads |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 3251 | * <dt> {@link #BATTERY_SERVICE} ("batterymanager") |
Todd Poynor | 99f7e12 | 2014-04-15 16:03:42 -0700 | [diff] [blame] | 3252 | * <dd> A {@link android.os.BatteryManager} for managing battery state |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 3253 | * <dt> {@link #JOB_SCHEDULER_SERVICE} ("taskmanager") |
| 3254 | * <dd> A {@link android.app.job.JobScheduler} for managing scheduled tasks |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3255 | * <dt> {@link #NETWORK_STATS_SERVICE} ("netstats") |
| 3256 | * <dd> A {@link android.app.usage.NetworkStatsManager NetworkStatsManager} for querying network |
| 3257 | * usage statistics. |
Polina Bondarenko | 8333c73 | 2016-03-09 18:08:42 +0100 | [diff] [blame] | 3258 | * <dt> {@link #HARDWARE_PROPERTIES_SERVICE} ("hardware_properties") |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 3259 | * <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] | 3260 | * </dl> |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3261 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3262 | * <p>Note: System services obtained via this API may be closely associated with |
| 3263 | * the Context in which they are obtained from. In general, do not share the |
| 3264 | * service objects between various different contexts (Activities, Applications, |
| 3265 | * Services, Providers, etc.) |
| 3266 | * |
Svet Ganov | 8f90bcc | 2017-12-22 23:29:24 -0800 | [diff] [blame] | 3267 | * <p>Note: Instant apps, for which {@link PackageManager#isInstantApp()} returns true, |
| 3268 | * don't have access to the following system services: {@link #DEVICE_POLICY_SERVICE}, |
Donald Chai | ee4c91c | 2018-09-19 14:42:41 -0700 | [diff] [blame] | 3269 | * {@link #FINGERPRINT_SERVICE}, {@link #KEYGUARD_SERVICE}, {@link #SHORTCUT_SERVICE}, |
| 3270 | * {@link #USB_SERVICE}, {@link #WALLPAPER_SERVICE}, {@link #WIFI_P2P_SERVICE}, |
| 3271 | * {@link #WIFI_SERVICE}, {@link #WIFI_AWARE_SERVICE}. For these services this method will |
| 3272 | * return <code>null</code>. Generally, if you are running as an instant app you should always |
| 3273 | * check whether the result of this method is null. |
Svet Ganov | 8f90bcc | 2017-12-22 23:29:24 -0800 | [diff] [blame] | 3274 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3275 | * @param name The name of the desired service. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3276 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3277 | * @return The service or null if the name does not exist. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3278 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3279 | * @see #WINDOW_SERVICE |
| 3280 | * @see android.view.WindowManager |
| 3281 | * @see #LAYOUT_INFLATER_SERVICE |
| 3282 | * @see android.view.LayoutInflater |
| 3283 | * @see #ACTIVITY_SERVICE |
| 3284 | * @see android.app.ActivityManager |
| 3285 | * @see #POWER_SERVICE |
| 3286 | * @see android.os.PowerManager |
| 3287 | * @see #ALARM_SERVICE |
| 3288 | * @see android.app.AlarmManager |
| 3289 | * @see #NOTIFICATION_SERVICE |
| 3290 | * @see android.app.NotificationManager |
| 3291 | * @see #KEYGUARD_SERVICE |
| 3292 | * @see android.app.KeyguardManager |
| 3293 | * @see #LOCATION_SERVICE |
| 3294 | * @see android.location.LocationManager |
| 3295 | * @see #SEARCH_SERVICE |
| 3296 | * @see android.app.SearchManager |
| 3297 | * @see #SENSOR_SERVICE |
| 3298 | * @see android.hardware.SensorManager |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 3299 | * @see #STORAGE_SERVICE |
San Mehat | b104340 | 2010-02-05 08:26:50 -0800 | [diff] [blame] | 3300 | * @see android.os.storage.StorageManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3301 | * @see #VIBRATOR_SERVICE |
| 3302 | * @see android.os.Vibrator |
| 3303 | * @see #CONNECTIVITY_SERVICE |
| 3304 | * @see android.net.ConnectivityManager |
| 3305 | * @see #WIFI_SERVICE |
| 3306 | * @see android.net.wifi.WifiManager |
| 3307 | * @see #AUDIO_SERVICE |
| 3308 | * @see android.media.AudioManager |
Dianne Hackborn | b58b8f8 | 2012-06-11 15:08:39 -0700 | [diff] [blame] | 3309 | * @see #MEDIA_ROUTER_SERVICE |
| 3310 | * @see android.media.MediaRouter |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3311 | * @see #TELEPHONY_SERVICE |
| 3312 | * @see android.telephony.TelephonyManager |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 3313 | * @see #TELEPHONY_SUBSCRIPTION_SERVICE |
| 3314 | * @see android.telephony.SubscriptionManager |
Jonathan Basseri | 9a1c9b6 | 2015-02-25 13:01:52 -0800 | [diff] [blame] | 3315 | * @see #CARRIER_CONFIG_SERVICE |
| 3316 | * @see android.telephony.CarrierConfigManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3317 | * @see #INPUT_METHOD_SERVICE |
| 3318 | * @see android.view.inputmethod.InputMethodManager |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 3319 | * @see #UI_MODE_SERVICE |
| 3320 | * @see android.app.UiModeManager |
Steve Howard | 7083c42 | 2010-07-28 16:01:23 -0700 | [diff] [blame] | 3321 | * @see #DOWNLOAD_SERVICE |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 3322 | * @see android.app.DownloadManager |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 3323 | * @see #BATTERY_SERVICE |
| 3324 | * @see android.os.BatteryManager |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 3325 | * @see #JOB_SCHEDULER_SERVICE |
| 3326 | * @see android.app.job.JobScheduler |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3327 | * @see #NETWORK_STATS_SERVICE |
| 3328 | * @see android.app.usage.NetworkStatsManager |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 3329 | * @see android.os.HardwarePropertiesManager |
| 3330 | * @see #HARDWARE_PROPERTIES_SERVICE |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3331 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 3332 | public abstract @Nullable Object getSystemService(@ServiceName @NonNull String name); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3333 | |
| 3334 | /** |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3335 | * Return the handle to a system-level service by class. |
| 3336 | * <p> |
| 3337 | * Currently available classes are: |
| 3338 | * {@link android.view.WindowManager}, {@link android.view.LayoutInflater}, |
| 3339 | * {@link android.app.ActivityManager}, {@link android.os.PowerManager}, |
| 3340 | * {@link android.app.AlarmManager}, {@link android.app.NotificationManager}, |
| 3341 | * {@link android.app.KeyguardManager}, {@link android.location.LocationManager}, |
| 3342 | * {@link android.app.SearchManager}, {@link android.os.Vibrator}, |
| 3343 | * {@link android.net.ConnectivityManager}, |
| 3344 | * {@link android.net.wifi.WifiManager}, |
| 3345 | * {@link android.media.AudioManager}, {@link android.media.MediaRouter}, |
| 3346 | * {@link android.telephony.TelephonyManager}, {@link android.telephony.SubscriptionManager}, |
| 3347 | * {@link android.view.inputmethod.InputMethodManager}, |
| 3348 | * {@link android.app.UiModeManager}, {@link android.app.DownloadManager}, |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3349 | * {@link android.os.BatteryManager}, {@link android.app.job.JobScheduler}, |
| 3350 | * {@link android.app.usage.NetworkStatsManager}. |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3351 | * </p><p> |
| 3352 | * Note: System services obtained via this API may be closely associated with |
| 3353 | * the Context in which they are obtained from. In general, do not share the |
| 3354 | * service objects between various different contexts (Activities, Applications, |
| 3355 | * Services, Providers, etc.) |
| 3356 | * </p> |
| 3357 | * |
Svet Ganov | 8f90bcc | 2017-12-22 23:29:24 -0800 | [diff] [blame] | 3358 | * <p>Note: Instant apps, for which {@link PackageManager#isInstantApp()} returns true, |
| 3359 | * don't have access to the following system services: {@link #DEVICE_POLICY_SERVICE}, |
Donald Chai | ee4c91c | 2018-09-19 14:42:41 -0700 | [diff] [blame] | 3360 | * {@link #FINGERPRINT_SERVICE}, {@link #KEYGUARD_SERVICE}, {@link #SHORTCUT_SERVICE}, |
| 3361 | * {@link #USB_SERVICE}, {@link #WALLPAPER_SERVICE}, {@link #WIFI_P2P_SERVICE}, |
| 3362 | * {@link #WIFI_SERVICE}, {@link #WIFI_AWARE_SERVICE}. For these services this method will |
| 3363 | * return <code>null</code>. Generally, if you are running as an instant app you should always |
| 3364 | * check whether the result of this method is null. |
Svet Ganov | 8f90bcc | 2017-12-22 23:29:24 -0800 | [diff] [blame] | 3365 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3366 | * @param serviceClass The class of the desired service. |
| 3367 | * @return The service or null if the class is not a supported system service. |
| 3368 | */ |
| 3369 | @SuppressWarnings("unchecked") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 3370 | public final @Nullable <T> T getSystemService(@NonNull Class<T> serviceClass) { |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3371 | // Because subclasses may override getSystemService(String) we cannot |
| 3372 | // perform a lookup by class alone. We must first map the class to its |
| 3373 | // service name then invoke the string-based method. |
| 3374 | String serviceName = getSystemServiceName(serviceClass); |
| 3375 | return serviceName != null ? (T)getSystemService(serviceName) : null; |
| 3376 | } |
| 3377 | |
| 3378 | /** |
| 3379 | * Gets the name of the system-level service that is represented by the specified class. |
| 3380 | * |
| 3381 | * @param serviceClass The class of the desired service. |
| 3382 | * @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] | 3383 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 3384 | public abstract @Nullable String getSystemServiceName(@NonNull Class<?> serviceClass); |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3385 | |
| 3386 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3387 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3388 | * {@link android.os.PowerManager} for controlling power management, |
| 3389 | * including "wake locks," which let you keep the device on while |
| 3390 | * you're running long tasks. |
| 3391 | */ |
| 3392 | public static final String POWER_SERVICE = "power"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3393 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3394 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3395 | * Use with {@link #getSystemService(String)} to retrieve a |
Tao Bao | e8a403d | 2015-12-31 07:44:55 -0800 | [diff] [blame] | 3396 | * {@link android.os.RecoverySystem} for accessing the recovery system |
| 3397 | * service. |
| 3398 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3399 | * @see #getSystemService(String) |
Tao Bao | e8a403d | 2015-12-31 07:44:55 -0800 | [diff] [blame] | 3400 | * @hide |
| 3401 | */ |
| 3402 | public static final String RECOVERY_SERVICE = "recovery"; |
| 3403 | |
| 3404 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3405 | * Use with {@link #getSystemService(String)} to retrieve a |
Tao Bao | 07342dc | 2017-01-24 15:08:21 -0800 | [diff] [blame] | 3406 | * {@link android.os.SystemUpdateManager} for accessing the system update |
| 3407 | * manager service. |
| 3408 | * |
| 3409 | * @see #getSystemService(String) |
| 3410 | * @hide |
| 3411 | */ |
| 3412 | @SystemApi |
| 3413 | public static final String SYSTEM_UPDATE_SERVICE = "system_update"; |
| 3414 | |
| 3415 | /** |
| 3416 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3417 | * {@link android.view.WindowManager} for accessing the system's window |
| 3418 | * manager. |
| 3419 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3420 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3421 | * @see android.view.WindowManager |
| 3422 | */ |
| 3423 | public static final String WINDOW_SERVICE = "window"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3424 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3425 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3426 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3427 | * {@link android.view.LayoutInflater} for inflating layout resources in this |
| 3428 | * context. |
| 3429 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3430 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3431 | * @see android.view.LayoutInflater |
| 3432 | */ |
| 3433 | public static final String LAYOUT_INFLATER_SERVICE = "layout_inflater"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3434 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3435 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3436 | * Use with {@link #getSystemService(String)} to retrieve a |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 3437 | * {@link android.accounts.AccountManager} for receiving intents at a |
| 3438 | * time of your choosing. |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 3439 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3440 | * @see #getSystemService(String) |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 3441 | * @see android.accounts.AccountManager |
| 3442 | */ |
| 3443 | public static final String ACCOUNT_SERVICE = "account"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3444 | |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 3445 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3446 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3447 | * {@link android.app.ActivityManager} for interacting with the global |
| 3448 | * system state. |
| 3449 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3450 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3451 | * @see android.app.ActivityManager |
| 3452 | */ |
| 3453 | public static final String ACTIVITY_SERVICE = "activity"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3454 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3455 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3456 | * Use with {@link #getSystemService(String)} to retrieve a |
Wale Ogunwale | 65ebd95 | 2018-04-25 15:41:44 -0700 | [diff] [blame] | 3457 | * {@link android.app.ActivityTaskManager} for interacting with the global system state. |
| 3458 | * |
| 3459 | * @see #getSystemService(String) |
| 3460 | * @see android.app.ActivityTaskManager |
| 3461 | * @hide |
| 3462 | */ |
| 3463 | public static final String ACTIVITY_TASK_SERVICE = "activity_task"; |
| 3464 | |
| 3465 | /** |
| 3466 | * Use with {@link #getSystemService(String)} to retrieve a |
Wale Ogunwale | 6d50dcc | 2018-07-21 23:00:40 -0700 | [diff] [blame] | 3467 | * {@link android.app.UriGrantsManager} for interacting with the global system state. |
| 3468 | * |
| 3469 | * @see #getSystemService(String) |
| 3470 | * @see android.app.UriGrantsManager |
| 3471 | * @hide |
| 3472 | */ |
| 3473 | public static final String URI_GRANTS_SERVICE = "uri_grants"; |
| 3474 | |
| 3475 | /** |
| 3476 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3477 | * {@link android.app.AlarmManager} for receiving intents at a |
| 3478 | * time of your choosing. |
| 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.app.AlarmManager |
| 3482 | */ |
| 3483 | public static final String ALARM_SERVICE = "alarm"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -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 |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3487 | * {@link android.app.NotificationManager} for informing the user of |
| 3488 | * background events. |
| 3489 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3490 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3491 | * @see android.app.NotificationManager |
| 3492 | */ |
| 3493 | public static final String NOTIFICATION_SERVICE = "notification"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3494 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3495 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3496 | * Use with {@link #getSystemService(String)} to retrieve a |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 3497 | * {@link android.view.accessibility.AccessibilityManager} for giving the user |
| 3498 | * feedback for UI events through the registered event listeners. |
| 3499 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3500 | * @see #getSystemService(String) |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 3501 | * @see android.view.accessibility.AccessibilityManager |
| 3502 | */ |
| 3503 | public static final String ACCESSIBILITY_SERVICE = "accessibility"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3504 | |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 3505 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3506 | * Use with {@link #getSystemService(String)} to retrieve a |
Alan Viverette | 69ce69b | 2013-08-29 12:23:48 -0700 | [diff] [blame] | 3507 | * {@link android.view.accessibility.CaptioningManager} for obtaining |
| 3508 | * captioning properties and listening for changes in captioning |
| 3509 | * preferences. |
| 3510 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3511 | * @see #getSystemService(String) |
Alan Viverette | 69ce69b | 2013-08-29 12:23:48 -0700 | [diff] [blame] | 3512 | * @see android.view.accessibility.CaptioningManager |
| 3513 | */ |
| 3514 | public static final String CAPTIONING_SERVICE = "captioning"; |
| 3515 | |
| 3516 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3517 | * Use with {@link #getSystemService(String)} to retrieve a |
kopriva | 5495dbb | 2018-09-13 14:18:34 -0700 | [diff] [blame] | 3518 | * {@link android.app.KeyguardManager} for controlling keyguard. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3519 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3520 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3521 | * @see android.app.KeyguardManager |
| 3522 | */ |
| 3523 | public static final String KEYGUARD_SERVICE = "keyguard"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3524 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3525 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3526 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3527 | * android.location.LocationManager} for controlling location |
| 3528 | * updates. |
| 3529 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3530 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3531 | * @see android.location.LocationManager |
| 3532 | */ |
| 3533 | public static final String LOCATION_SERVICE = "location"; |
Bai Tao | a58a875 | 2010-07-13 15:32:16 +0800 | [diff] [blame] | 3534 | |
| 3535 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3536 | * Use with {@link #getSystemService(String)} to retrieve a |
Bai Tao | a58a875 | 2010-07-13 15:32:16 +0800 | [diff] [blame] | 3537 | * {@link android.location.CountryDetector} for detecting the country that |
| 3538 | * the user is in. |
| 3539 | * |
| 3540 | * @hide |
| 3541 | */ |
Mathew Inwood | 8c854f8 | 2018-09-14 12:35:36 +0100 | [diff] [blame] | 3542 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Bai Tao | a58a875 | 2010-07-13 15:32:16 +0800 | [diff] [blame] | 3543 | public static final String COUNTRY_DETECTOR = "country_detector"; |
| 3544 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3545 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3546 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3547 | * android.app.SearchManager} for handling searches. |
| 3548 | * |
Erik Wolsheimer | ac5cecd | 2017-12-05 13:11:50 -0800 | [diff] [blame] | 3549 | * <p> |
| 3550 | * {@link Configuration#UI_MODE_TYPE_WATCH} does not support |
| 3551 | * {@link android.app.SearchManager}. |
| 3552 | * |
| 3553 | * @see #getSystemService |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3554 | * @see android.app.SearchManager |
| 3555 | */ |
| 3556 | public static final String SEARCH_SERVICE = "search"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3557 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3558 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3559 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3560 | * android.hardware.SensorManager} for accessing sensors. |
| 3561 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3562 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3563 | * @see android.hardware.SensorManager |
| 3564 | */ |
| 3565 | public static final String SENSOR_SERVICE = "sensor"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3566 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3567 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3568 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Chad Brubaker | 90f391f | 2018-10-19 10:26:19 -0700 | [diff] [blame] | 3569 | * android.hardware.SensorPrivacyManager} for accessing sensor privacy |
| 3570 | * functions. |
| 3571 | * |
| 3572 | * @see #getSystemService(String) |
| 3573 | * @see android.hardware.SensorPrivacyManager |
| 3574 | * |
| 3575 | * @hide |
| 3576 | */ |
| 3577 | public static final String SENSOR_PRIVACY_SERVICE = "sensor_privacy"; |
| 3578 | |
| 3579 | /** |
| 3580 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Kenny Root | 02c8730 | 2010-07-01 08:10:18 -0700 | [diff] [blame] | 3581 | * android.os.storage.StorageManager} for accessing system storage |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 3582 | * functions. |
| 3583 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3584 | * @see #getSystemService(String) |
San Mehat | b104340 | 2010-02-05 08:26:50 -0800 | [diff] [blame] | 3585 | * @see android.os.storage.StorageManager |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 3586 | */ |
| 3587 | public static final String STORAGE_SERVICE = "storage"; |
| 3588 | |
| 3589 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3590 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Jeff Sharkey | e8cece9 | 2017-01-04 11:33:33 -0700 | [diff] [blame] | 3591 | * android.app.usage.StorageStatsManager} for accessing system storage |
| 3592 | * statistics. |
| 3593 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3594 | * @see #getSystemService(String) |
Jeff Sharkey | e8cece9 | 2017-01-04 11:33:33 -0700 | [diff] [blame] | 3595 | * @see android.app.usage.StorageStatsManager |
| 3596 | */ |
| 3597 | public static final String STORAGE_STATS_SERVICE = "storagestats"; |
| 3598 | |
| 3599 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3600 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3601 | * com.android.server.WallpaperService for accessing wallpapers. |
| 3602 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3603 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3604 | */ |
| 3605 | public static final String WALLPAPER_SERVICE = "wallpaper"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3606 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3607 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3608 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3609 | * android.os.Vibrator} for interacting with the vibration hardware. |
| 3610 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3611 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3612 | * @see android.os.Vibrator |
| 3613 | */ |
| 3614 | public static final String VIBRATOR_SERVICE = "vibrator"; |
Robert Greenwalt | 9e696c2 | 2010-04-01 14:45:18 -0700 | [diff] [blame] | 3615 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3616 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3617 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3618 | * android.app.StatusBarManager} for interacting with the status bar. |
| 3619 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3620 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3621 | * @see android.app.StatusBarManager |
Evan Laird | edd016f | 2019-01-23 18:36:29 -0500 | [diff] [blame] | 3622 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3623 | * @hide |
| 3624 | */ |
Evan Laird | edd016f | 2019-01-23 18:36:29 -0500 | [diff] [blame] | 3625 | @SystemApi |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3626 | public static final String STATUS_BAR_SERVICE = "statusbar"; |
| 3627 | |
| 3628 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3629 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3630 | * android.net.ConnectivityManager} for handling management of |
| 3631 | * network connections. |
| 3632 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3633 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3634 | * @see android.net.ConnectivityManager |
| 3635 | */ |
| 3636 | public static final String CONNECTIVITY_SERVICE = "connectivity"; |
| 3637 | |
| 3638 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3639 | * Use with {@link #getSystemService(String)} to retrieve a |
Remi NGUYEN VAN | 3193598 | 2019-01-28 11:40:08 +0900 | [diff] [blame] | 3640 | * {@link android.net.INetd} for communicating with the network stack |
| 3641 | * @hide |
| 3642 | * @see #getSystemService(String) |
| 3643 | * @hide |
| 3644 | */ |
| 3645 | @SystemApi |
| 3646 | public static final String NETD_SERVICE = "netd"; |
| 3647 | |
| 3648 | /** |
Remi NGUYEN VAN | 310da6f | 2019-02-14 18:04:20 +0900 | [diff] [blame] | 3649 | * Use with {@link android.os.ServiceManager.getService()} to retrieve a |
| 3650 | * {@link NetworkStackClient} IBinder for communicating with the network stack |
Remi NGUYEN VAN | c094a54 | 2018-12-07 16:52:24 +0900 | [diff] [blame] | 3651 | * @hide |
Remi NGUYEN VAN | 310da6f | 2019-02-14 18:04:20 +0900 | [diff] [blame] | 3652 | * @see NetworkStackClient |
Remi NGUYEN VAN | c094a54 | 2018-12-07 16:52:24 +0900 | [diff] [blame] | 3653 | */ |
| 3654 | public static final String NETWORK_STACK_SERVICE = "network_stack"; |
| 3655 | |
| 3656 | /** |
| 3657 | * Use with {@link #getSystemService(String)} to retrieve a |
Chalard Jean | 8c141bd | 2018-12-04 20:20:56 +0900 | [diff] [blame] | 3658 | * {@link android.net.IpMemoryStore} to store and read information about |
| 3659 | * known networks. |
| 3660 | * @hide |
| 3661 | */ |
| 3662 | public static final String IP_MEMORY_STORE_SERVICE = "ipmemorystore"; |
| 3663 | |
| 3664 | /** |
| 3665 | * Use with {@link #getSystemService(String)} to retrieve a |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 3666 | * {@link android.net.IpSecManager} for encrypting Sockets or Networks with |
| 3667 | * IPSec. |
| 3668 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3669 | * @see #getSystemService(String) |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 3670 | */ |
| 3671 | public static final String IPSEC_SERVICE = "ipsec"; |
| 3672 | |
| 3673 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3674 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Christopher Tate | 8662cab5 | 2012-02-23 14:59:36 -0800 | [diff] [blame] | 3675 | * android.os.IUpdateLock} for managing runtime sequences that |
| 3676 | * must not be interrupted by headless OTA application or similar. |
| 3677 | * |
| 3678 | * @hide |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3679 | * @see #getSystemService(String) |
Christopher Tate | 8662cab5 | 2012-02-23 14:59:36 -0800 | [diff] [blame] | 3680 | * @see android.os.UpdateLock |
| 3681 | */ |
| 3682 | public static final String UPDATE_LOCK_SERVICE = "updatelock"; |
| 3683 | |
| 3684 | /** |
Dianne Hackborn | 35f72be | 2013-09-16 10:57:39 -0700 | [diff] [blame] | 3685 | * Constant for the internal network management service, not really a Context service. |
Dianne Hackborn | 0a6a80f | 2013-09-16 15:20:27 -0700 | [diff] [blame] | 3686 | * @hide |
San Mehat | d1df8ac | 2010-01-26 06:17:26 -0800 | [diff] [blame] | 3687 | */ |
| 3688 | public static final String NETWORKMANAGEMENT_SERVICE = "network_management"; |
| 3689 | |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [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 |
Jason Monk | 8f5f7ff | 2017-10-17 14:12:42 -0400 | [diff] [blame] | 3692 | * {@link com.android.server.slice.SliceManagerService} for managing slices. |
| 3693 | * @hide |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3694 | * @see #getSystemService(String) |
Jason Monk | 8f5f7ff | 2017-10-17 14:12:42 -0400 | [diff] [blame] | 3695 | */ |
| 3696 | public static final String SLICE_SERVICE = "slice"; |
| 3697 | |
| 3698 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3699 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3700 | * android.app.usage.NetworkStatsManager} for querying network usage stats. |
| 3701 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3702 | * @see #getSystemService(String) |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3703 | * @see android.app.usage.NetworkStatsManager |
| 3704 | */ |
Jeff Sharkey | 7527990 | 2011-05-24 18:39:45 -0700 | [diff] [blame] | 3705 | public static final String NETWORK_STATS_SERVICE = "netstats"; |
| 3706 | /** {@hide} */ |
Jeff Sharkey | eedcb95 | 2011-05-17 14:55:15 -0700 | [diff] [blame] | 3707 | public static final String NETWORK_POLICY_SERVICE = "netpolicy"; |
Ricky Wai | 1a6e667 | 2017-10-27 14:46:01 +0100 | [diff] [blame] | 3708 | /** {@hide} */ |
| 3709 | public static final String NETWORK_WATCHLIST_SERVICE = "network_watchlist"; |
Jeff Sharkey | eedcb95 | 2011-05-17 14:55:15 -0700 | [diff] [blame] | 3710 | |
San Mehat | d1df8ac | 2010-01-26 06:17:26 -0800 | [diff] [blame] | 3711 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3712 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3713 | * android.net.wifi.WifiManager} for handling management of |
| 3714 | * Wi-Fi access. |
| 3715 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3716 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3717 | * @see android.net.wifi.WifiManager |
| 3718 | */ |
| 3719 | public static final String WIFI_SERVICE = "wifi"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3720 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3721 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3722 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 3723 | * android.net.wifi.p2p.WifiP2pManager} for handling management of |
Irfan Sheriff | 651cdfc | 2011-09-07 00:31:20 -0700 | [diff] [blame] | 3724 | * Wi-Fi peer-to-peer connections. |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 3725 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3726 | * @see #getSystemService(String) |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 3727 | * @see android.net.wifi.p2p.WifiP2pManager |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 3728 | */ |
| 3729 | public static final String WIFI_P2P_SERVICE = "wifip2p"; |
| 3730 | |
| 3731 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3732 | * Use with {@link #getSystemService(String)} to retrieve a |
Etan Cohen | 0413327 | 2016-10-26 11:22:06 -0700 | [diff] [blame] | 3733 | * {@link android.net.wifi.aware.WifiAwareManager} for handling management of |
| 3734 | * Wi-Fi Aware. |
Etan Cohen | 20d329b | 2015-09-29 13:49:02 -0700 | [diff] [blame] | 3735 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3736 | * @see #getSystemService(String) |
Etan Cohen | 0413327 | 2016-10-26 11:22:06 -0700 | [diff] [blame] | 3737 | * @see android.net.wifi.aware.WifiAwareManager |
Etan Cohen | 20d329b | 2015-09-29 13:49:02 -0700 | [diff] [blame] | 3738 | */ |
Etan Cohen | 0413327 | 2016-10-26 11:22:06 -0700 | [diff] [blame] | 3739 | public static final String WIFI_AWARE_SERVICE = "wifiaware"; |
Etan Cohen | 20d329b | 2015-09-29 13:49:02 -0700 | [diff] [blame] | 3740 | |
| 3741 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3742 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 3743 | * android.net.wifi.WifiScanner} for scanning the wifi universe |
| 3744 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3745 | * @see #getSystemService(String) |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 3746 | * @see android.net.wifi.WifiScanner |
| 3747 | * @hide |
| 3748 | */ |
Wei Wang | 35d552f | 2014-07-08 21:37:01 -0700 | [diff] [blame] | 3749 | @SystemApi |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 3750 | public static final String WIFI_SCANNING_SERVICE = "wifiscanner"; |
| 3751 | |
| 3752 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3753 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Vinit Deshpande | 7686c06 | 2014-06-30 15:25:01 -0700 | [diff] [blame] | 3754 | * android.net.wifi.RttManager} for ranging devices with wifi |
| 3755 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3756 | * @see #getSystemService(String) |
Vinit Deshpande | 7686c06 | 2014-06-30 15:25:01 -0700 | [diff] [blame] | 3757 | * @see android.net.wifi.RttManager |
| 3758 | * @hide |
| 3759 | */ |
| 3760 | @SystemApi |
Etan Cohen | d0acccd | 2018-01-31 08:36:33 -0800 | [diff] [blame] | 3761 | @Deprecated |
Vinit Deshpande | 7686c06 | 2014-06-30 15:25:01 -0700 | [diff] [blame] | 3762 | public static final String WIFI_RTT_SERVICE = "rttmanager"; |
| 3763 | |
| 3764 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3765 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Etan Cohen | 17ba472 | 2017-08-21 10:52:17 -0700 | [diff] [blame] | 3766 | * android.net.wifi.rtt.WifiRttManager} for ranging devices with wifi |
| 3767 | * |
| 3768 | * Note: this is a replacement for WIFI_RTT_SERVICE above. It will |
| 3769 | * be renamed once final implementation in place. |
| 3770 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3771 | * @see #getSystemService(String) |
Etan Cohen | 17ba472 | 2017-08-21 10:52:17 -0700 | [diff] [blame] | 3772 | * @see android.net.wifi.rtt.WifiRttManager |
Etan Cohen | 17ba472 | 2017-08-21 10:52:17 -0700 | [diff] [blame] | 3773 | */ |
Etan Cohen | 091d777 | 2018-01-04 17:47:37 -0800 | [diff] [blame] | 3774 | public static final String WIFI_RTT_RANGING_SERVICE = "wifirtt"; |
Etan Cohen | 17ba472 | 2017-08-21 10:52:17 -0700 | [diff] [blame] | 3775 | |
| 3776 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3777 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Robert Quattlebaum | 87a7104 | 2017-05-15 15:45:20 -0700 | [diff] [blame] | 3778 | * android.net.lowpan.LowpanManager} for handling management of |
| 3779 | * LoWPAN access. |
| 3780 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3781 | * @see #getSystemService(String) |
Robert Quattlebaum | 87a7104 | 2017-05-15 15:45:20 -0700 | [diff] [blame] | 3782 | * @see android.net.lowpan.LowpanManager |
| 3783 | * |
| 3784 | * @hide |
| 3785 | */ |
| 3786 | public static final String LOWPAN_SERVICE = "lowpan"; |
| 3787 | |
| 3788 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3789 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Dianne Hackborn | fee756f | 2014-07-16 17:31:10 -0700 | [diff] [blame] | 3790 | * android.net.EthernetManager} for handling management of |
Lorenzo Colitti | f9ff2c9 | 2014-05-21 16:32:11 -0700 | [diff] [blame] | 3791 | * Ethernet access. |
| 3792 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3793 | * @see #getSystemService(String) |
Dianne Hackborn | fee756f | 2014-07-16 17:31:10 -0700 | [diff] [blame] | 3794 | * @see android.net.EthernetManager |
Lorenzo Colitti | f9ff2c9 | 2014-05-21 16:32:11 -0700 | [diff] [blame] | 3795 | * |
| 3796 | * @hide |
| 3797 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 3798 | @UnsupportedAppUsage |
Lorenzo Colitti | f9ff2c9 | 2014-05-21 16:32:11 -0700 | [diff] [blame] | 3799 | public static final String ETHERNET_SERVICE = "ethernet"; |
| 3800 | |
| 3801 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3802 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Irfan Sheriff | 60309fc | 2012-04-24 14:52:37 -0700 | [diff] [blame] | 3803 | * android.net.nsd.NsdManager} for handling management of network service |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 3804 | * discovery |
| 3805 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3806 | * @see #getSystemService(String) |
Irfan Sheriff | 60309fc | 2012-04-24 14:52:37 -0700 | [diff] [blame] | 3807 | * @see android.net.nsd.NsdManager |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 3808 | */ |
| 3809 | public static final String NSD_SERVICE = "servicediscovery"; |
| 3810 | |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 3811 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3812 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3813 | * {@link android.media.AudioManager} for handling management of volume, |
| 3814 | * ringer modes and audio routing. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3815 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3816 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3817 | * @see android.media.AudioManager |
| 3818 | */ |
| 3819 | public static final String AUDIO_SERVICE = "audio"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3820 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3821 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3822 | * Use with {@link #getSystemService(String)} to retrieve a |
Jim Miller | ce7eb6d | 2015-04-03 19:29:13 -0700 | [diff] [blame] | 3823 | * {@link android.hardware.fingerprint.FingerprintManager} for handling management |
Jim Miller | 08fa40c | 2014-04-29 18:18:47 -0700 | [diff] [blame] | 3824 | * of fingerprints. |
| 3825 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3826 | * @see #getSystemService(String) |
Jim Miller | ce7eb6d | 2015-04-03 19:29:13 -0700 | [diff] [blame] | 3827 | * @see android.hardware.fingerprint.FingerprintManager |
Jim Miller | 08fa40c | 2014-04-29 18:18:47 -0700 | [diff] [blame] | 3828 | */ |
| 3829 | public static final String FINGERPRINT_SERVICE = "fingerprint"; |
| 3830 | |
| 3831 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3832 | * Use with {@link #getSystemService(String)} to retrieve a |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 3833 | * {@link android.hardware.face.FaceManager} for handling management |
| 3834 | * of face authentication. |
| 3835 | * |
| 3836 | * @hide |
| 3837 | * @see #getSystemService |
| 3838 | * @see android.hardware.face.FaceManager |
| 3839 | */ |
| 3840 | public static final String FACE_SERVICE = "face"; |
| 3841 | |
| 3842 | /** |
Kevin Chyn | 05c2150 | 2018-09-18 13:07:19 -0700 | [diff] [blame] | 3843 | * Use with {@link #getSystemService(String)} to retrieve a |
Kevin Chyn | 51676d2 | 2018-11-05 18:00:43 -0800 | [diff] [blame] | 3844 | * {@link android.hardware.iris.IrisManager} for handling management |
| 3845 | * of iris authentication. |
| 3846 | * |
| 3847 | * @hide |
| 3848 | * @see #getSystemService |
| 3849 | * @see android.hardware.iris.IrisManager |
| 3850 | */ |
| 3851 | public static final String IRIS_SERVICE = "iris"; |
| 3852 | |
| 3853 | /** |
| 3854 | * Use with {@link #getSystemService(String)} to retrieve a |
Kevin Chyn | 05c2150 | 2018-09-18 13:07:19 -0700 | [diff] [blame] | 3855 | * {@link android.hardware.biometrics.BiometricManager} for handling management |
| 3856 | * of face authentication. |
| 3857 | * |
| 3858 | * @see #getSystemService |
| 3859 | * @see android.hardware.biometrics.BiometricManager |
| 3860 | */ |
| 3861 | public static final String BIOMETRIC_SERVICE = "biometric"; |
| 3862 | |
| 3863 | /** |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 3864 | * Use with {@link #getSystemService} to retrieve a |
Dianne Hackborn | b58b8f8 | 2012-06-11 15:08:39 -0700 | [diff] [blame] | 3865 | * {@link android.media.MediaRouter} for controlling and managing |
| 3866 | * routing of media. |
| 3867 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3868 | * @see #getSystemService(String) |
Dianne Hackborn | b58b8f8 | 2012-06-11 15:08:39 -0700 | [diff] [blame] | 3869 | * @see android.media.MediaRouter |
| 3870 | */ |
| 3871 | public static final String MEDIA_ROUTER_SERVICE = "media_router"; |
| 3872 | |
| 3873 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3874 | * Use with {@link #getSystemService(String)} to retrieve a |
RoboErik | 42ea7ee | 2014-05-16 16:27:35 -0700 | [diff] [blame] | 3875 | * {@link android.media.session.MediaSessionManager} for managing media Sessions. |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 3876 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3877 | * @see #getSystemService(String) |
RoboErik | 42ea7ee | 2014-05-16 16:27:35 -0700 | [diff] [blame] | 3878 | * @see android.media.session.MediaSessionManager |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 3879 | */ |
| 3880 | public static final String MEDIA_SESSION_SERVICE = "media_session"; |
| 3881 | |
| 3882 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3883 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3884 | * {@link android.telephony.TelephonyManager} for handling management the |
| 3885 | * telephony features of the device. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3886 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3887 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3888 | * @see android.telephony.TelephonyManager |
| 3889 | */ |
| 3890 | public static final String TELEPHONY_SERVICE = "phone"; |
| 3891 | |
| 3892 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3893 | * Use with {@link #getSystemService(String)} to retrieve a |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 3894 | * {@link android.telephony.SubscriptionManager} for handling management the |
| 3895 | * telephony subscriptions of the device. |
| 3896 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3897 | * @see #getSystemService(String) |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 3898 | * @see android.telephony.SubscriptionManager |
| 3899 | */ |
| 3900 | public static final String TELEPHONY_SUBSCRIPTION_SERVICE = "telephony_subscription_service"; |
| 3901 | |
| 3902 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3903 | * Use with {@link #getSystemService(String)} to retrieve a |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 3904 | * {@link android.telecom.TelecomManager} to manage telecom-related features |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 3905 | * of the device. |
| 3906 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3907 | * @see #getSystemService(String) |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 3908 | * @see android.telecom.TelecomManager |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 3909 | */ |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 3910 | public static final String TELECOM_SERVICE = "telecom"; |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 3911 | |
| 3912 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3913 | * Use with {@link #getSystemService(String)} to retrieve a |
Jonathan Basseri | 9a1c9b6 | 2015-02-25 13:01:52 -0800 | [diff] [blame] | 3914 | * {@link android.telephony.CarrierConfigManager} for reading carrier configuration values. |
| 3915 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3916 | * @see #getSystemService(String) |
Jonathan Basseri | 9a1c9b6 | 2015-02-25 13:01:52 -0800 | [diff] [blame] | 3917 | * @see android.telephony.CarrierConfigManager |
| 3918 | */ |
| 3919 | public static final String CARRIER_CONFIG_SERVICE = "carrier_config"; |
| 3920 | |
| 3921 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3922 | * Use with {@link #getSystemService(String)} to retrieve a |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 3923 | * {@link android.telephony.euicc.EuiccManager} to manage the device eUICC (embedded SIM). |
| 3924 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3925 | * @see #getSystemService(String) |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 3926 | * @see android.telephony.euicc.EuiccManager |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 3927 | */ |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 3928 | public static final String EUICC_SERVICE = "euicc"; |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 3929 | |
| 3930 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3931 | * Use with {@link #getSystemService(String)} to retrieve a |
Holly Jiuyu Sun | 5c11024 | 2017-12-21 18:44:59 -0800 | [diff] [blame] | 3932 | * {@link android.telephony.euicc.EuiccCardManager} to access the device eUICC (embedded SIM). |
| 3933 | * |
| 3934 | * @see #getSystemService(String) |
| 3935 | * @see android.telephony.euicc.EuiccCardManager |
Holly Jiuyu Sun | 5c11024 | 2017-12-21 18:44:59 -0800 | [diff] [blame] | 3936 | * @hide |
| 3937 | */ |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 3938 | @SystemApi |
| 3939 | public static final String EUICC_CARD_SERVICE = "euicc_card"; |
Holly Jiuyu Sun | 5c11024 | 2017-12-21 18:44:59 -0800 | [diff] [blame] | 3940 | |
| 3941 | /** |
| 3942 | * Use with {@link #getSystemService(String)} to retrieve a |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3943 | * {@link android.content.ClipboardManager} for accessing and modifying |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3944 | * the contents of the global clipboard. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3945 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3946 | * @see #getSystemService(String) |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3947 | * @see android.content.ClipboardManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3948 | */ |
| 3949 | public static final String CLIPBOARD_SERVICE = "clipboard"; |
| 3950 | |
| 3951 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3952 | * Use with {@link #getSystemService(String)} to retrieve a |
Abodunrinwa Toki | f001fef | 2017-01-04 23:51:42 +0000 | [diff] [blame] | 3953 | * {@link TextClassificationManager} for text classification services. |
Abodunrinwa Toki | 8158af5 | 2016-11-23 20:41:09 +0000 | [diff] [blame] | 3954 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3955 | * @see #getSystemService(String) |
Abodunrinwa Toki | f001fef | 2017-01-04 23:51:42 +0000 | [diff] [blame] | 3956 | * @see TextClassificationManager |
Abodunrinwa Toki | 8158af5 | 2016-11-23 20:41:09 +0000 | [diff] [blame] | 3957 | */ |
| 3958 | public static final String TEXT_CLASSIFICATION_SERVICE = "textclassification"; |
| 3959 | |
| 3960 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3961 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3962 | * {@link android.view.inputmethod.InputMethodManager} for accessing input |
| 3963 | * methods. |
| 3964 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3965 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3966 | */ |
| 3967 | public static final String INPUT_METHOD_SERVICE = "input_method"; |
| 3968 | |
| 3969 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3970 | * Use with {@link #getSystemService(String)} to retrieve a |
satok | 988323c | 2011-06-22 16:38:13 +0900 | [diff] [blame] | 3971 | * {@link android.view.textservice.TextServicesManager} for accessing |
| 3972 | * text services. |
| 3973 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3974 | * @see #getSystemService(String) |
satok | 988323c | 2011-06-22 16:38:13 +0900 | [diff] [blame] | 3975 | */ |
| 3976 | public static final String TEXT_SERVICES_MANAGER_SERVICE = "textservices"; |
| 3977 | |
| 3978 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3979 | * Use with {@link #getSystemService(String)} to retrieve a |
Dan Egnor | e38d58b | 2009-12-30 19:29:03 -0800 | [diff] [blame] | 3980 | * {@link android.appwidget.AppWidgetManager} for accessing AppWidgets. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3981 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3982 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3983 | */ |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 3984 | public static final String APPWIDGET_SERVICE = "appwidget"; |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 3985 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3986 | /** |
Dianne Hackborn | 91097de | 2014-04-04 18:02:06 -0700 | [diff] [blame] | 3987 | * Official published name of the (internal) voice interaction manager service. |
| 3988 | * |
| 3989 | * @hide |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3990 | * @see #getSystemService(String) |
Dianne Hackborn | 91097de | 2014-04-04 18:02:06 -0700 | [diff] [blame] | 3991 | */ |
| 3992 | public static final String VOICE_INTERACTION_MANAGER_SERVICE = "voiceinteraction"; |
| 3993 | |
| 3994 | /** |
Felipe Leme | 640f30a | 2017-03-06 15:44:06 -0800 | [diff] [blame] | 3995 | * Official published name of the (internal) autofill service. |
Felipe Leme | 5381aa4 | 2016-10-13 09:02:32 -0700 | [diff] [blame] | 3996 | * |
| 3997 | * @hide |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3998 | * @see #getSystemService(String) |
Felipe Leme | 5381aa4 | 2016-10-13 09:02:32 -0700 | [diff] [blame] | 3999 | */ |
Felipe Leme | 640f30a | 2017-03-06 15:44:06 -0800 | [diff] [blame] | 4000 | public static final String AUTOFILL_MANAGER_SERVICE = "autofill"; |
Felipe Leme | 5381aa4 | 2016-10-13 09:02:32 -0700 | [diff] [blame] | 4001 | |
| 4002 | /** |
Felipe Leme | 749b889 | 2018-12-03 16:30:30 -0800 | [diff] [blame] | 4003 | * Official published name of the content capture service. |
Felipe Leme | e348dc3 | 2018-11-05 12:35:29 -0800 | [diff] [blame] | 4004 | * |
| 4005 | * @hide |
| 4006 | * @see #getSystemService(String) |
| 4007 | */ |
Felipe Leme | 749b889 | 2018-12-03 16:30:30 -0800 | [diff] [blame] | 4008 | public static final String CONTENT_CAPTURE_MANAGER_SERVICE = "content_capture"; |
Felipe Leme | e348dc3 | 2018-11-05 12:35:29 -0800 | [diff] [blame] | 4009 | |
| 4010 | /** |
Winson Chung | 3fb0f25 | 2019-01-08 17:41:55 -0800 | [diff] [blame] | 4011 | * Used for getting content selections and classifications for task snapshots. |
| 4012 | * |
| 4013 | * @hide |
| 4014 | * @see #getSystemService(String) |
| 4015 | */ |
| 4016 | @SystemApi |
| 4017 | public static final String CONTENT_SUGGESTIONS_SERVICE = "content_suggestions"; |
| 4018 | |
| 4019 | /** |
Sunny Goyal | 54e9134 | 2018-11-14 11:59:02 -0800 | [diff] [blame] | 4020 | * Official published name of the app prediction service. |
| 4021 | * |
| 4022 | * @hide |
| 4023 | * @see #getSystemService(String) |
| 4024 | */ |
| 4025 | @SystemApi |
| 4026 | public static final String APP_PREDICTION_SERVICE = "app_prediction"; |
| 4027 | |
| 4028 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4029 | * Use with {@link #getSystemService(String)} to access the |
Arunesh Mishra | a772e5f | 2016-01-25 10:33:11 -0800 | [diff] [blame] | 4030 | * {@link com.android.server.voiceinteraction.SoundTriggerService}. |
| 4031 | * |
| 4032 | * @hide |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4033 | * @see #getSystemService(String) |
Arunesh Mishra | a772e5f | 2016-01-25 10:33:11 -0800 | [diff] [blame] | 4034 | */ |
| 4035 | public static final String SOUND_TRIGGER_SERVICE = "soundtrigger"; |
| 4036 | |
Philip P. Moltmann | 039678e | 2018-09-18 13:04:38 -0700 | [diff] [blame] | 4037 | /** |
| 4038 | * Official published name of the (internal) permission service. |
| 4039 | * |
| 4040 | * @see #getSystemService(String) |
| 4041 | * @hide |
| 4042 | */ |
| 4043 | @SystemApi |
| 4044 | public static final String PERMISSION_SERVICE = "permission"; |
Arunesh Mishra | a772e5f | 2016-01-25 10:33:11 -0800 | [diff] [blame] | 4045 | |
| 4046 | /** |
Philip P. Moltmann | bc054d8 | 2018-12-21 09:41:58 -0800 | [diff] [blame] | 4047 | * Official published name of the (internal) permission controller service. |
| 4048 | * |
| 4049 | * @see #getSystemService(String) |
| 4050 | * @hide |
| 4051 | */ |
| 4052 | public static final String PERMISSION_CONTROLLER_SERVICE = "permission_controller"; |
| 4053 | |
| 4054 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4055 | * Use with {@link #getSystemService(String)} to retrieve an |
Christopher Tate | 4528186 | 2010-03-05 15:46:30 -0800 | [diff] [blame] | 4056 | * {@link android.app.backup.IBackupManager IBackupManager} for communicating |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 4057 | * with the backup mechanism. |
Dianne Hackborn | 7f20543 | 2009-07-28 00:13:47 -0700 | [diff] [blame] | 4058 | * @hide |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4059 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4060 | * @see #getSystemService(String) |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 4061 | */ |
Christopher Tate | d5cf722 | 2014-07-29 16:53:09 -0700 | [diff] [blame] | 4062 | @SystemApi |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 4063 | public static final String BACKUP_SERVICE = "backup"; |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 4064 | |
| 4065 | /** |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 4066 | * Use with {@link #getSystemService(String)} to retrieve an |
| 4067 | * {@link android.content.rollback.RollbackManager} for communicating |
| 4068 | * with the rollback manager |
| 4069 | * |
| 4070 | * @see #getSystemService(String) |
Richard Uhler | c739c8c | 2018-12-12 11:03:34 +0000 | [diff] [blame] | 4071 | * @hide |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 4072 | */ |
Richard Uhler | c739c8c | 2018-12-12 11:03:34 +0000 | [diff] [blame] | 4073 | @SystemApi |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 4074 | public static final String ROLLBACK_SERVICE = "rollback"; |
| 4075 | |
| 4076 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4077 | * Use with {@link #getSystemService(String)} to retrieve a |
Dan Egnor | 1337b01 | 2010-01-04 11:01:44 -0800 | [diff] [blame] | 4078 | * {@link android.os.DropBoxManager} instance for recording |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 4079 | * diagnostic logs. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4080 | * @see #getSystemService(String) |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 4081 | */ |
| 4082 | public static final String DROPBOX_SERVICE = "dropbox"; |
| 4083 | |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 4084 | /** |
Philip P. Moltmann | f80809f | 2018-04-04 11:20:44 -0700 | [diff] [blame] | 4085 | * System service name for the DeviceIdleManager. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4086 | * @see #getSystemService(String) |
Dianne Hackborn | 1958e5e | 2015-06-12 18:11:41 -0700 | [diff] [blame] | 4087 | * @hide |
| 4088 | */ |
| 4089 | public static final String DEVICE_IDLE_CONTROLLER = "deviceidle"; |
| 4090 | |
| 4091 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4092 | * Use with {@link #getSystemService(String)} to retrieve a |
Dianne Hackborn | 87bba1e | 2010-02-26 17:25:54 -0800 | [diff] [blame] | 4093 | * {@link android.app.admin.DevicePolicyManager} for working with global |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 4094 | * device policy management. |
| 4095 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4096 | * @see #getSystemService(String) |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 4097 | */ |
| 4098 | public static final String DEVICE_POLICY_SERVICE = "device_policy"; |
| 4099 | |
| 4100 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4101 | * Use with {@link #getSystemService(String)} to retrieve a |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 4102 | * {@link android.app.UiModeManager} for controlling UI modes. |
| 4103 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4104 | * @see #getSystemService(String) |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 4105 | */ |
| 4106 | public static final String UI_MODE_SERVICE = "uimode"; |
| 4107 | |
| 4108 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4109 | * Use with {@link #getSystemService(String)} to retrieve a |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 4110 | * {@link android.app.DownloadManager} for requesting HTTP downloads. |
Steve Howard | a270936 | 2010-07-02 17:12:48 -0700 | [diff] [blame] | 4111 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4112 | * @see #getSystemService(String) |
Steve Howard | a270936 | 2010-07-02 17:12:48 -0700 | [diff] [blame] | 4113 | */ |
| 4114 | public static final String DOWNLOAD_SERVICE = "download"; |
| 4115 | |
| 4116 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4117 | * Use with {@link #getSystemService(String)} to retrieve a |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 4118 | * {@link android.os.BatteryManager} for managing battery state. |
| 4119 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4120 | * @see #getSystemService(String) |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 4121 | */ |
| 4122 | public static final String BATTERY_SERVICE = "batterymanager"; |
| 4123 | |
| 4124 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4125 | * Use with {@link #getSystemService(String)} to retrieve a |
Nick Pelly | 50b4d8f | 2010-12-07 22:40:28 -0800 | [diff] [blame] | 4126 | * {@link android.nfc.NfcManager} for using NFC. |
| 4127 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4128 | * @see #getSystemService(String) |
Nick Pelly | 50b4d8f | 2010-12-07 22:40:28 -0800 | [diff] [blame] | 4129 | */ |
| 4130 | public static final String NFC_SERVICE = "nfc"; |
| 4131 | |
| 4132 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4133 | * Use with {@link #getSystemService(String)} to retrieve a |
Florian Salbrechter | 084da9b | 2015-03-25 11:00:55 +0000 | [diff] [blame] | 4134 | * {@link android.bluetooth.BluetoothManager} for using Bluetooth. |
Jaikumar Ganesh | 1abb1cb | 2012-01-25 16:14:50 -0800 | [diff] [blame] | 4135 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4136 | * @see #getSystemService(String) |
Jaikumar Ganesh | 1abb1cb | 2012-01-25 16:14:50 -0800 | [diff] [blame] | 4137 | */ |
| 4138 | public static final String BLUETOOTH_SERVICE = "bluetooth"; |
| 4139 | |
| 4140 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4141 | * Use with {@link #getSystemService(String)} to retrieve a |
Chung-yih Wang | 2d94231 | 2010-08-05 12:17:37 +0800 | [diff] [blame] | 4142 | * {@link android.net.sip.SipManager} for accessing the SIP related service. |
| 4143 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4144 | * @see #getSystemService(String) |
Chung-yih Wang | 2d94231 | 2010-08-05 12:17:37 +0800 | [diff] [blame] | 4145 | */ |
| 4146 | /** @hide */ |
| 4147 | public static final String SIP_SERVICE = "sip"; |
| 4148 | |
| 4149 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4150 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Mike Lockwood | c4308f0 | 2011-03-01 08:04:54 -0800 | [diff] [blame] | 4151 | * 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] | 4152 | * and for controlling this device's behavior as a USB device. |
| 4153 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4154 | * @see #getSystemService(String) |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4155 | * @see android.hardware.usb.UsbManager |
Mike Lockwood | e7d511e | 2010-12-30 13:39:37 -0500 | [diff] [blame] | 4156 | */ |
| 4157 | public static final String USB_SERVICE = "usb"; |
| 4158 | |
| 4159 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4160 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Kenny Root | f74bfde | 2018-01-18 15:42:48 -0800 | [diff] [blame] | 4161 | * Use with {@link #getSystemService} to retrieve a {@link |
| 4162 | * android.debug.AdbManager} for access to ADB debug functions. |
| 4163 | * |
| 4164 | * @see #getSystemService(String) |
| 4165 | * @see android.debug.AdbManager |
| 4166 | * |
| 4167 | * @hide |
| 4168 | */ |
| 4169 | public static final String ADB_SERVICE = "adb"; |
| 4170 | |
| 4171 | /** |
| 4172 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Mike Lockwood | b01e8bf | 2011-08-29 20:11:07 -0400 | [diff] [blame] | 4173 | * android.hardware.SerialManager} for access to serial ports. |
| 4174 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4175 | * @see #getSystemService(String) |
Dianne Hackborn | 35f72be | 2013-09-16 10:57:39 -0700 | [diff] [blame] | 4176 | * @see android.hardware.SerialManager |
Mike Lockwood | b01e8bf | 2011-08-29 20:11:07 -0400 | [diff] [blame] | 4177 | * |
| 4178 | * @hide |
| 4179 | */ |
| 4180 | public static final String SERIAL_SERVICE = "serial"; |
| 4181 | |
| 4182 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4183 | * Use with {@link #getSystemService(String)} to retrieve a |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 4184 | * {@link android.hardware.hdmi.HdmiControlManager} for controlling and managing |
| 4185 | * HDMI-CEC protocol. |
| 4186 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4187 | * @see #getSystemService(String) |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 4188 | * @see android.hardware.hdmi.HdmiControlManager |
Jinsuk Kim | 66d1eb2 | 2014-06-06 16:12:18 +0900 | [diff] [blame] | 4189 | * @hide |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 4190 | */ |
Jinsuk Kim | 66d1eb2 | 2014-06-06 16:12:18 +0900 | [diff] [blame] | 4191 | @SystemApi |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 4192 | public static final String HDMI_CONTROL_SERVICE = "hdmi_control"; |
Jinsuk Kim | fbcd503 | 2014-03-21 16:25:13 +0900 | [diff] [blame] | 4193 | |
| 4194 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4195 | * Use with {@link #getSystemService(String)} to retrieve a |
Jeff Brown | 9df6e7a | 2012-04-05 11:49:26 -0700 | [diff] [blame] | 4196 | * {@link android.hardware.input.InputManager} for interacting with input devices. |
| 4197 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4198 | * @see #getSystemService(String) |
Jeff Brown | 9df6e7a | 2012-04-05 11:49:26 -0700 | [diff] [blame] | 4199 | * @see android.hardware.input.InputManager |
| 4200 | */ |
| 4201 | public static final String INPUT_SERVICE = "input"; |
| 4202 | |
| 4203 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4204 | * Use with {@link #getSystemService(String)} to retrieve a |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 4205 | * {@link android.hardware.display.DisplayManager} for interacting with display devices. |
| 4206 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4207 | * @see #getSystemService(String) |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 4208 | * @see android.hardware.display.DisplayManager |
| 4209 | */ |
| 4210 | public static final String DISPLAY_SERVICE = "display"; |
| 4211 | |
| 4212 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4213 | * Use with {@link #getSystemService(String)} to retrieve a |
Christine Franks | 39b0311 | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 4214 | * {@link android.hardware.display.ColorDisplayManager} for controlling color transforms. |
| 4215 | * |
| 4216 | * @see #getSystemService(String) |
| 4217 | * @see android.hardware.display.ColorDisplayManager |
| 4218 | * @hide |
| 4219 | */ |
| 4220 | public static final String COLOR_DISPLAY_SERVICE = "color_display"; |
| 4221 | |
| 4222 | /** |
| 4223 | * Use with {@link #getSystemService(String)} to retrieve a |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 4224 | * {@link android.os.UserManager} for managing users on devices that support multiple users. |
| 4225 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4226 | * @see #getSystemService(String) |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 4227 | * @see android.os.UserManager |
| 4228 | */ |
| 4229 | public static final String USER_SERVICE = "user"; |
| 4230 | |
| 4231 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4232 | * Use with {@link #getSystemService(String)} to retrieve a |
Amith Yamasani | 4f58263 | 2014-02-19 14:31:52 -0800 | [diff] [blame] | 4233 | * {@link android.content.pm.LauncherApps} for querying and monitoring launchable apps across |
| 4234 | * profiles of a user. |
| 4235 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4236 | * @see #getSystemService(String) |
Amith Yamasani | 4f58263 | 2014-02-19 14:31:52 -0800 | [diff] [blame] | 4237 | * @see android.content.pm.LauncherApps |
| 4238 | */ |
| 4239 | public static final String LAUNCHER_APPS_SERVICE = "launcherapps"; |
| 4240 | |
| 4241 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4242 | * Use with {@link #getSystemService(String)} to retrieve a |
Amith Yamasani | f20d640 | 2014-05-24 15:34:37 -0700 | [diff] [blame] | 4243 | * {@link android.content.RestrictionsManager} for retrieving application restrictions |
| 4244 | * and requesting permissions for restricted operations. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4245 | * @see #getSystemService(String) |
Amith Yamasani | f20d640 | 2014-05-24 15:34:37 -0700 | [diff] [blame] | 4246 | * @see android.content.RestrictionsManager |
| 4247 | */ |
| 4248 | public static final String RESTRICTIONS_SERVICE = "restrictions"; |
| 4249 | |
| 4250 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4251 | * Use with {@link #getSystemService(String)} to retrieve a |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 4252 | * {@link android.app.AppOpsManager} for tracking application operations |
| 4253 | * on the device. |
| 4254 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4255 | * @see #getSystemService(String) |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 4256 | * @see android.app.AppOpsManager |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 4257 | */ |
| 4258 | public static final String APP_OPS_SERVICE = "appops"; |
| 4259 | |
| 4260 | /** |
Hai Zhang | b777668 | 2018-09-25 15:10:57 -0700 | [diff] [blame] | 4261 | * Use with {@link #getSystemService(String)} to retrieve a {@link android.app.role.RoleManager} |
| 4262 | * for managing roles. |
| 4263 | * |
| 4264 | * @see #getSystemService(String) |
| 4265 | * @see android.app.role.RoleManager |
| 4266 | */ |
| 4267 | public static final String ROLE_SERVICE = "role"; |
| 4268 | |
| 4269 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4270 | * Use with {@link #getSystemService(String)} to retrieve a |
Eino-Ville Talvala | 2f1a2e4 | 2013-07-25 17:12:05 -0700 | [diff] [blame] | 4271 | * {@link android.hardware.camera2.CameraManager} for interacting with |
Eino-Ville Talvala | b267554 | 2012-12-12 13:29:45 -0800 | [diff] [blame] | 4272 | * camera devices. |
| 4273 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4274 | * @see #getSystemService(String) |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 4275 | * @see android.hardware.camera2.CameraManager |
Eino-Ville Talvala | b267554 | 2012-12-12 13:29:45 -0800 | [diff] [blame] | 4276 | */ |
| 4277 | public static final String CAMERA_SERVICE = "camera"; |
| 4278 | |
| 4279 | /** |
Svetoslav Ganov | 4b9a4d1 | 2013-06-11 15:20:06 -0700 | [diff] [blame] | 4280 | * {@link android.print.PrintManager} for printing and managing |
Jeff Brown | 511cd35 | 2013-08-23 17:43:37 -0700 | [diff] [blame] | 4281 | * printers and print tasks. |
Svetoslav Ganov | 4b9a4d1 | 2013-06-11 15:20:06 -0700 | [diff] [blame] | 4282 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4283 | * @see #getSystemService(String) |
Svetoslav Ganov | 4b9a4d1 | 2013-06-11 15:20:06 -0700 | [diff] [blame] | 4284 | * @see android.print.PrintManager |
| 4285 | */ |
| 4286 | public static final String PRINT_SERVICE = "print"; |
| 4287 | |
| 4288 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4289 | * Use with {@link #getSystemService(String)} to retrieve a |
Eugene Susla | 6ed45d8 | 2017-01-22 13:52:51 -0800 | [diff] [blame] | 4290 | * {@link android.companion.CompanionDeviceManager} for managing companion devices |
| 4291 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4292 | * @see #getSystemService(String) |
Eugene Susla | 6ed45d8 | 2017-01-22 13:52:51 -0800 | [diff] [blame] | 4293 | * @see android.companion.CompanionDeviceManager |
| 4294 | */ |
Eugene Susla | d7355cc | 2017-04-20 11:14:45 -0700 | [diff] [blame] | 4295 | public static final String COMPANION_DEVICE_SERVICE = "companiondevice"; |
Eugene Susla | 6ed45d8 | 2017-01-22 13:52:51 -0800 | [diff] [blame] | 4296 | |
| 4297 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4298 | * Use with {@link #getSystemService(String)} to retrieve a |
Erik Gilling | 51e95df | 2013-06-26 11:06:51 -0700 | [diff] [blame] | 4299 | * {@link android.hardware.ConsumerIrManager} for transmitting infrared |
| 4300 | * signals from the device. |
| 4301 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4302 | * @see #getSystemService(String) |
Erik Gilling | 51e95df | 2013-06-26 11:06:51 -0700 | [diff] [blame] | 4303 | * @see android.hardware.ConsumerIrManager |
| 4304 | */ |
| 4305 | public static final String CONSUMER_IR_SERVICE = "consumer_ir"; |
| 4306 | |
| 4307 | /** |
Adrian Roos | 82142c2 | 2014-03-27 14:56:59 +0100 | [diff] [blame] | 4308 | * {@link android.app.trust.TrustManager} for managing trust agents. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4309 | * @see #getSystemService(String) |
Adrian Roos | 82142c2 | 2014-03-27 14:56:59 +0100 | [diff] [blame] | 4310 | * @see android.app.trust.TrustManager |
| 4311 | * @hide |
| 4312 | */ |
| 4313 | public static final String TRUST_SERVICE = "trust"; |
| 4314 | |
| 4315 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4316 | * Use with {@link #getSystemService(String)} to retrieve a |
Jae Seo | d5cc4a2 | 2014-05-30 16:57:43 -0700 | [diff] [blame] | 4317 | * {@link android.media.tv.TvInputManager} for interacting with TV inputs |
| 4318 | * on the device. |
Jae Seo | 3957091 | 2014-02-20 18:23:25 -0800 | [diff] [blame] | 4319 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4320 | * @see #getSystemService(String) |
Jae Seo | d5cc4a2 | 2014-05-30 16:57:43 -0700 | [diff] [blame] | 4321 | * @see android.media.tv.TvInputManager |
Jae Seo | 3957091 | 2014-02-20 18:23:25 -0800 | [diff] [blame] | 4322 | */ |
| 4323 | public static final String TV_INPUT_SERVICE = "tv_input"; |
| 4324 | |
| 4325 | /** |
Jeff Davidson | b51e0a6 | 2014-04-09 12:38:15 -0700 | [diff] [blame] | 4326 | * {@link android.net.NetworkScoreManager} for managing network scoring. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4327 | * @see #getSystemService(String) |
Jeff Davidson | b51e0a6 | 2014-04-09 12:38:15 -0700 | [diff] [blame] | 4328 | * @see android.net.NetworkScoreManager |
| 4329 | * @hide |
| 4330 | */ |
Jeff Davidson | 5ad2079 | 2014-07-21 13:55:42 -0700 | [diff] [blame] | 4331 | @SystemApi |
Jeff Davidson | b51e0a6 | 2014-04-09 12:38:15 -0700 | [diff] [blame] | 4332 | public static final String NETWORK_SCORE_SERVICE = "network_score"; |
| 4333 | |
| 4334 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4335 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Adam Lesinski | aa60767 | 2014-11-24 11:27:50 -0800 | [diff] [blame] | 4336 | * android.app.usage.UsageStatsManager} for querying device usage stats. |
Dianne Hackborn | e22b3b1 | 2014-05-07 18:06:44 -0700 | [diff] [blame] | 4337 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4338 | * @see #getSystemService(String) |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 4339 | * @see android.app.usage.UsageStatsManager |
Dianne Hackborn | e22b3b1 | 2014-05-07 18:06:44 -0700 | [diff] [blame] | 4340 | */ |
| 4341 | public static final String USAGE_STATS_SERVICE = "usagestats"; |
| 4342 | |
| 4343 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4344 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 4345 | * android.app.job.JobScheduler} instance for managing occasional |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 4346 | * background tasks. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4347 | * @see #getSystemService(String) |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 4348 | * @see android.app.job.JobScheduler |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 4349 | */ |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 4350 | public static final String JOB_SCHEDULER_SERVICE = "jobscheduler"; |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 4351 | |
| 4352 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4353 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Andres Morales | 33df937 | 2014-09-26 17:08:59 -0700 | [diff] [blame] | 4354 | * android.service.persistentdata.PersistentDataBlockManager} instance |
| 4355 | * for interacting with a storage device that lives across factory resets. |
| 4356 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4357 | * @see #getSystemService(String) |
Andres Morales | 68d4acd | 2014-07-01 19:40:41 -0700 | [diff] [blame] | 4358 | * @see android.service.persistentdata.PersistentDataBlockManager |
| 4359 | * @hide |
| 4360 | */ |
Andres Morales | 33df937 | 2014-09-26 17:08:59 -0700 | [diff] [blame] | 4361 | @SystemApi |
Andres Morales | 68d4acd | 2014-07-01 19:40:41 -0700 | [diff] [blame] | 4362 | public static final String PERSISTENT_DATA_BLOCK_SERVICE = "persistent_data_block"; |
| 4363 | |
| 4364 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4365 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Andrew Scull | 3b8b46f | 2017-02-13 18:12:15 +0000 | [diff] [blame] | 4366 | * android.service.oemlock.OemLockManager} instance for managing the OEM lock. |
| 4367 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4368 | * @see #getSystemService(String) |
Andrew Scull | 3b8b46f | 2017-02-13 18:12:15 +0000 | [diff] [blame] | 4369 | * @see android.service.oemlock.OemLockManager |
| 4370 | * @hide |
| 4371 | */ |
| 4372 | @SystemApi |
| 4373 | public static final String OEM_LOCK_SERVICE = "oem_lock"; |
| 4374 | |
| 4375 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4376 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 4377 | * android.media.projection.MediaProjectionManager} instance for managing |
| 4378 | * media projection sessions. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4379 | * @see #getSystemService(String) |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 4380 | * @see android.media.projection.MediaProjectionManager |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 4381 | */ |
| 4382 | public static final String MEDIA_PROJECTION_SERVICE = "media_projection"; |
| 4383 | |
| 4384 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4385 | * Use with {@link #getSystemService(String)} to retrieve a |
Mike Lockwood | b673770 | 2015-02-20 08:28:47 -0800 | [diff] [blame] | 4386 | * {@link android.media.midi.MidiManager} for accessing the MIDI service. |
Mike Lockwood | 67f8e8b | 2014-12-01 13:54:59 -0800 | [diff] [blame] | 4387 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4388 | * @see #getSystemService(String) |
Mike Lockwood | 67f8e8b | 2014-12-01 13:54:59 -0800 | [diff] [blame] | 4389 | */ |
| 4390 | public static final String MIDI_SERVICE = "midi"; |
| 4391 | |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 4392 | |
| 4393 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4394 | * Use with {@link #getSystemService(String)} to retrieve a |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 4395 | * {@link android.hardware.radio.RadioManager} for accessing the broadcast radio service. |
| 4396 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4397 | * @see #getSystemService(String) |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 4398 | * @hide |
| 4399 | */ |
Tomasz Wasilczyk | 9110df7 | 2017-06-22 07:57:20 -0700 | [diff] [blame] | 4400 | public static final String RADIO_SERVICE = "broadcastradio"; |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 4401 | |
Paul McLean | a33be21 | 2015-02-20 07:52:45 -0800 | [diff] [blame] | 4402 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4403 | * Use with {@link #getSystemService(String)} to retrieve a |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 4404 | * {@link android.os.HardwarePropertiesManager} for accessing the hardware properties service. |
| 4405 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4406 | * @see #getSystemService(String) |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 4407 | */ |
Polina Bondarenko | 8333c73 | 2016-03-09 18:08:42 +0100 | [diff] [blame] | 4408 | public static final String HARDWARE_PROPERTIES_SERVICE = "hardware_properties"; |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 4409 | |
| 4410 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4411 | * Use with {@link #getSystemService(String)} to retrieve a |
Wei Wang | bad7c20 | 2018-11-01 11:57:39 -0700 | [diff] [blame] | 4412 | * {@link android.os.ThermalService} for accessing the thermal service. |
| 4413 | * |
| 4414 | * @see #getSystemService(String) |
| 4415 | * @hide |
| 4416 | */ |
| 4417 | public static final String THERMAL_SERVICE = "thermalservice"; |
| 4418 | |
| 4419 | /** |
| 4420 | * Use with {@link #getSystemService(String)} to retrieve a |
Makoto Onuki | b5a012f | 2016-06-21 11:13:53 -0700 | [diff] [blame] | 4421 | * {@link android.content.pm.ShortcutManager} for accessing the launcher shortcut service. |
Makoto Onuki | 6f7362d9 | 2016-03-04 13:39:41 -0800 | [diff] [blame] | 4422 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4423 | * @see #getSystemService(String) |
Makoto Onuki | 6f7362d9 | 2016-03-04 13:39:41 -0800 | [diff] [blame] | 4424 | * @see android.content.pm.ShortcutManager |
| 4425 | */ |
| 4426 | public static final String SHORTCUT_SERVICE = "shortcut"; |
| 4427 | |
| 4428 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4429 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 4430 | * android.hardware.location.ContextHubManager} for accessing context hubs. |
| 4431 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4432 | * @see #getSystemService(String) |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 4433 | * @see android.hardware.location.ContextHubManager |
| 4434 | * |
| 4435 | * @hide |
| 4436 | */ |
| 4437 | @SystemApi |
| 4438 | public static final String CONTEXTHUB_SERVICE = "contexthub"; |
| 4439 | |
| 4440 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4441 | * Use with {@link #getSystemService(String)} to retrieve a |
Joe Onorato | 713fec8 | 2016-03-04 10:34:02 -0800 | [diff] [blame] | 4442 | * {@link android.os.health.SystemHealthManager} for accessing system health (battery, power, |
| 4443 | * memory, etc) metrics. |
| 4444 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4445 | * @see #getSystemService(String) |
Joe Onorato | 713fec8 | 2016-03-04 10:34:02 -0800 | [diff] [blame] | 4446 | */ |
| 4447 | public static final String SYSTEM_HEALTH_SERVICE = "systemhealth"; |
| 4448 | |
| 4449 | /** |
Amith Yamasani | d04aaa3 | 2016-06-13 12:09:36 -0700 | [diff] [blame] | 4450 | * Gatekeeper Service. |
| 4451 | * @hide |
| 4452 | */ |
| 4453 | public static final String GATEKEEPER_SERVICE = "android.service.gatekeeper.IGateKeeperService"; |
| 4454 | |
| 4455 | /** |
Svet Ganov | 37e4327 | 2016-09-09 16:01:32 -0700 | [diff] [blame] | 4456 | * Service defining the policy for access to device identifiers. |
| 4457 | * @hide |
| 4458 | */ |
| 4459 | public static final String DEVICE_IDENTIFIERS_SERVICE = "device_identifiers"; |
| 4460 | |
| 4461 | /** |
Joe Onorato | 1754d74 | 2016-11-21 17:51:35 -0800 | [diff] [blame] | 4462 | * Service to report a system health "incident" |
| 4463 | * @hide |
| 4464 | */ |
| 4465 | public static final String INCIDENT_SERVICE = "incident"; |
| 4466 | |
| 4467 | /** |
Joe Onorato | e21ab7e | 2018-12-18 15:00:25 -0800 | [diff] [blame] | 4468 | * Service to assist incidentd and dumpstated in reporting status to the user |
| 4469 | * and in confirming authorization to take an incident report or bugreport |
| 4470 | * @hide |
| 4471 | */ |
| 4472 | public static final String INCIDENT_COMPANION_SERVICE = "incidentcompanion"; |
| 4473 | |
| 4474 | /** |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 4475 | * Service to assist statsd in obtaining general stats. |
| 4476 | * @hide |
| 4477 | */ |
| 4478 | public static final String STATS_COMPANION_SERVICE = "statscompanion"; |
| 4479 | |
| 4480 | /** |
Bookatz | c697797 | 2018-01-16 16:55:05 -0800 | [diff] [blame] | 4481 | * Use with {@link #getSystemService(String)} to retrieve an {@link android.app.StatsManager}. |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 4482 | * @hide |
| 4483 | */ |
| 4484 | @SystemApi |
| 4485 | public static final String STATS_MANAGER = "stats"; |
| 4486 | |
| 4487 | /** |
Nandana Dutt | d11850c | 2018-12-12 17:26:57 +0000 | [diff] [blame] | 4488 | * Service to capture a bugreport. |
| 4489 | * @see #getSystemService(String) |
| 4490 | * @see android.os.BugreportManager |
| 4491 | * @hide |
| 4492 | */ |
| 4493 | // TODO: Expose API when the implementation is more complete. |
| 4494 | // @SystemApi |
| 4495 | public static final String BUGREPORT_SERVICE = "bugreport"; |
| 4496 | |
| 4497 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4498 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
MÃ¥rten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 4499 | * android.content.om.OverlayManager} for managing overlay packages. |
| 4500 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4501 | * @see #getSystemService(String) |
MÃ¥rten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 4502 | * @see android.content.om.OverlayManager |
| 4503 | * @hide |
| 4504 | */ |
| 4505 | public static final String OVERLAY_SERVICE = "overlay"; |
| 4506 | |
| 4507 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4508 | * Use with {@link #getSystemService(String)} to retrieve a |
MÃ¥rten Kongstad | 06a1ac8 | 2018-09-20 13:09:47 +0200 | [diff] [blame] | 4509 | * {android.os.IIdmap2} for managing idmap files (used by overlay |
| 4510 | * packages). |
| 4511 | * |
| 4512 | * @see #getSystemService(String) |
| 4513 | * @hide |
| 4514 | */ |
| 4515 | public static final String IDMAP_SERVICE = "idmap"; |
| 4516 | |
| 4517 | /** |
| 4518 | * Use with {@link #getSystemService(String)} to retrieve a |
Zak Cohen | 56345f4 | 2017-01-26 13:54:28 -0800 | [diff] [blame] | 4519 | * {@link VrManager} for accessing the VR service. |
| 4520 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4521 | * @see #getSystemService(String) |
Zak Cohen | 56345f4 | 2017-01-26 13:54:28 -0800 | [diff] [blame] | 4522 | * @hide |
| 4523 | */ |
| 4524 | @SystemApi |
| 4525 | public static final String VR_SERVICE = "vrmanager"; |
| 4526 | |
| 4527 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4528 | * Use with {@link #getSystemService(String)} to retrieve an |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 4529 | * {@link android.app.timezone.ITimeZoneRulesManager}. |
| 4530 | * @hide |
| 4531 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4532 | * @see #getSystemService(String) |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 4533 | */ |
| 4534 | public static final String TIME_ZONE_RULES_MANAGER_SERVICE = "timezone"; |
| 4535 | |
| 4536 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4537 | * Use with {@link #getSystemService(String)} to retrieve a |
Tony Mak | b0d2262 | 2018-01-18 12:49:49 +0000 | [diff] [blame] | 4538 | * {@link android.content.pm.CrossProfileApps} for cross profile operations. |
Tony Mak | 1b708e6 | 2017-10-12 10:59:11 +0100 | [diff] [blame] | 4539 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4540 | * @see #getSystemService(String) |
Tony Mak | 1b708e6 | 2017-10-12 10:59:11 +0100 | [diff] [blame] | 4541 | */ |
| 4542 | public static final String CROSS_PROFILE_APPS_SERVICE = "crossprofileapps"; |
| 4543 | |
| 4544 | /** |
Ruchi Kandoi | 6149b0f | 2018-01-03 16:14:57 -0800 | [diff] [blame] | 4545 | * Use with {@link #getSystemService} to retrieve a |
| 4546 | * {@link android.se.omapi.ISecureElementService} |
| 4547 | * for accessing the SecureElementService. |
| 4548 | * |
| 4549 | * @hide |
| 4550 | */ |
| 4551 | @SystemApi |
| 4552 | public static final String SECURE_ELEMENT_SERVICE = "secure_element"; |
| 4553 | |
| 4554 | /** |
Neil Fuller | feeee68 | 2018-05-30 14:35:24 +0100 | [diff] [blame] | 4555 | * Use with {@link #getSystemService(String)} to retrieve an |
| 4556 | * {@link android.app.timedetector.ITimeDetectorService}. |
| 4557 | * @hide |
| 4558 | * |
| 4559 | * @see #getSystemService(String) |
| 4560 | */ |
| 4561 | public static final String TIME_DETECTOR_SERVICE = "time_detector"; |
| 4562 | |
| 4563 | /** |
Makoto Onuki | df7e481 | 2018-09-24 14:31:25 -0700 | [diff] [blame] | 4564 | * Binder service name for {@link AppBindingService}. |
| 4565 | * @hide |
| 4566 | */ |
| 4567 | public static final String APP_BINDING_SERVICE = "app_binding"; |
| 4568 | |
| 4569 | /** |
Sahin Caliskan | 9458ebc | 2018-10-31 13:23:29 -0700 | [diff] [blame] | 4570 | * Use with {@link #getSystemService(String)} to retrieve an |
Sahin Caliskan | 84dd306 | 2018-12-03 14:06:39 -0800 | [diff] [blame] | 4571 | * {@link android.telephony.ims.RcsManager}. |
Sahin Caliskan | 9458ebc | 2018-10-31 13:23:29 -0700 | [diff] [blame] | 4572 | * @hide |
| 4573 | */ |
| 4574 | public static final String TELEPHONY_RCS_SERVICE = "ircs"; |
| 4575 | |
Howard Chen | 0a94764 | 2019-01-07 14:10:44 +0800 | [diff] [blame] | 4576 | /** |
| 4577 | * Use with {@link #getSystemService(String)} to retrieve an |
| 4578 | * {@link android.os.DynamicAndroidManager}. |
| 4579 | * @hide |
| 4580 | */ |
| 4581 | @SystemApi |
| 4582 | public static final String DYNAMIC_ANDROID_SERVICE = "dynamic_android"; |
| 4583 | |
Sahin Caliskan | 9458ebc | 2018-10-31 13:23:29 -0700 | [diff] [blame] | 4584 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4585 | * Determine whether the given permission is allowed for a particular |
| 4586 | * process and user ID running in the system. |
| 4587 | * |
| 4588 | * @param permission The name of the permission being checked. |
| 4589 | * @param pid The process ID being checked against. Must be > 0. |
| 4590 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 4591 | * user, which will pass every permission check. |
| 4592 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4593 | * @return {@link PackageManager#PERMISSION_GRANTED} if the given |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4594 | * pid/uid is allowed that permission, or |
| 4595 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4596 | * |
| 4597 | * @see PackageManager#checkPermission(String, String) |
| 4598 | * @see #checkCallingPermission |
| 4599 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4600 | @CheckResult(suggest="#enforcePermission(String,int,int,String)") |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4601 | @PackageManager.PermissionResult |
| 4602 | 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] | 4603 | |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 4604 | /** @hide */ |
| 4605 | @PackageManager.PermissionResult |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 4606 | @UnsupportedAppUsage |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 4607 | public abstract int checkPermission(@NonNull String permission, int pid, int uid, |
| 4608 | IBinder callerToken); |
| 4609 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4610 | /** |
| 4611 | * Determine whether the calling process of an IPC you are handling has been |
| 4612 | * granted a particular permission. This is basically the same as calling |
| 4613 | * {@link #checkPermission(String, int, int)} with the pid and uid returned |
| 4614 | * by {@link android.os.Binder#getCallingPid} and |
| 4615 | * {@link android.os.Binder#getCallingUid}. One important difference |
| 4616 | * is that if you are not currently processing an IPC, this function |
| 4617 | * will always fail. This is done to protect against accidentally |
| 4618 | * leaking permissions; you can use {@link #checkCallingOrSelfPermission} |
| 4619 | * to avoid this protection. |
| 4620 | * |
| 4621 | * @param permission The name of the permission being checked. |
| 4622 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4623 | * @return {@link PackageManager#PERMISSION_GRANTED} if the calling |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4624 | * pid/uid is allowed that permission, or |
| 4625 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4626 | * |
| 4627 | * @see PackageManager#checkPermission(String, String) |
| 4628 | * @see #checkPermission |
| 4629 | * @see #checkCallingOrSelfPermission |
| 4630 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4631 | @CheckResult(suggest="#enforceCallingPermission(String,String)") |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4632 | @PackageManager.PermissionResult |
| 4633 | public abstract int checkCallingPermission(@NonNull String permission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4634 | |
| 4635 | /** |
| 4636 | * Determine whether the calling process of an IPC <em>or you</em> have been |
| 4637 | * granted a particular permission. This is the same as |
| 4638 | * {@link #checkCallingPermission}, except it grants your own permissions |
| 4639 | * if you are not currently processing an IPC. Use with care! |
| 4640 | * |
| 4641 | * @param permission The name of the permission being checked. |
| 4642 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4643 | * @return {@link PackageManager#PERMISSION_GRANTED} if the calling |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4644 | * pid/uid is allowed that permission, or |
| 4645 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4646 | * |
| 4647 | * @see PackageManager#checkPermission(String, String) |
| 4648 | * @see #checkPermission |
| 4649 | * @see #checkCallingPermission |
| 4650 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4651 | @CheckResult(suggest="#enforceCallingOrSelfPermission(String,String)") |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4652 | @PackageManager.PermissionResult |
| 4653 | public abstract int checkCallingOrSelfPermission(@NonNull String permission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4654 | |
| 4655 | /** |
Svetoslav | c6d1c34 | 2015-02-26 14:44:43 -0800 | [diff] [blame] | 4656 | * Determine whether <em>you</em> have been granted a particular permission. |
| 4657 | * |
| 4658 | * @param permission The name of the permission being checked. |
| 4659 | * |
| 4660 | * @return {@link PackageManager#PERMISSION_GRANTED} if you have the |
| 4661 | * permission, or {@link PackageManager#PERMISSION_DENIED} if not. |
| 4662 | * |
| 4663 | * @see PackageManager#checkPermission(String, String) |
| 4664 | * @see #checkCallingPermission(String) |
| 4665 | */ |
| 4666 | @PackageManager.PermissionResult |
| 4667 | public abstract int checkSelfPermission(@NonNull String permission); |
| 4668 | |
| 4669 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4670 | * If the given permission is not allowed for a particular process |
| 4671 | * and user ID running in the system, throw a {@link SecurityException}. |
| 4672 | * |
| 4673 | * @param permission The name of the permission being checked. |
| 4674 | * @param pid The process ID being checked against. Must be > 0. |
| 4675 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 4676 | * user, which will pass every permission check. |
| 4677 | * @param message A message to include in the exception if it is thrown. |
| 4678 | * |
| 4679 | * @see #checkPermission(String, int, int) |
| 4680 | */ |
| 4681 | public abstract void enforcePermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4682 | @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] | 4683 | |
| 4684 | /** |
| 4685 | * If the calling process of an IPC you are handling has not been |
| 4686 | * granted a particular permission, throw a {@link |
| 4687 | * SecurityException}. This is basically the same as calling |
| 4688 | * {@link #enforcePermission(String, int, int, String)} with the |
| 4689 | * pid and uid returned by {@link android.os.Binder#getCallingPid} |
| 4690 | * and {@link android.os.Binder#getCallingUid}. One important |
| 4691 | * difference is that if you are not currently processing an IPC, |
| 4692 | * this function will always throw the SecurityException. This is |
| 4693 | * done to protect against accidentally leaking permissions; you |
| 4694 | * can use {@link #enforceCallingOrSelfPermission} to avoid this |
| 4695 | * protection. |
| 4696 | * |
| 4697 | * @param permission The name of the permission being checked. |
| 4698 | * @param message A message to include in the exception if it is thrown. |
| 4699 | * |
| 4700 | * @see #checkCallingPermission(String) |
| 4701 | */ |
| 4702 | public abstract void enforceCallingPermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4703 | @NonNull String permission, @Nullable String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4704 | |
| 4705 | /** |
| 4706 | * If neither you nor the calling process of an IPC you are |
| 4707 | * handling has been granted a particular permission, throw a |
| 4708 | * {@link SecurityException}. This is the same as {@link |
| 4709 | * #enforceCallingPermission}, except it grants your own |
| 4710 | * permissions if you are not currently processing an IPC. Use |
| 4711 | * with care! |
| 4712 | * |
| 4713 | * @param permission The name of the permission being checked. |
| 4714 | * @param message A message to include in the exception if it is thrown. |
| 4715 | * |
| 4716 | * @see #checkCallingOrSelfPermission(String) |
| 4717 | */ |
| 4718 | public abstract void enforceCallingOrSelfPermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4719 | @NonNull String permission, @Nullable String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4720 | |
| 4721 | /** |
| 4722 | * Grant permission to access a specific Uri to another package, regardless |
| 4723 | * of whether that package has general permission to access the Uri's |
| 4724 | * content provider. This can be used to grant specific, temporary |
| 4725 | * permissions, typically in response to user interaction (such as the |
| 4726 | * user opening an attachment that you would like someone else to |
| 4727 | * display). |
| 4728 | * |
| 4729 | * <p>Normally you should use {@link Intent#FLAG_GRANT_READ_URI_PERMISSION |
| 4730 | * Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 4731 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
| 4732 | * Intent.FLAG_GRANT_WRITE_URI_PERMISSION} with the Intent being used to |
| 4733 | * start an activity instead of this function directly. If you use this |
| 4734 | * function directly, you should be sure to call |
| 4735 | * {@link #revokeUriPermission} when the target should no longer be allowed |
| 4736 | * to access it. |
| 4737 | * |
| 4738 | * <p>To succeed, the content provider owning the Uri must have set the |
| 4739 | * {@link android.R.styleable#AndroidManifestProvider_grantUriPermissions |
| 4740 | * grantUriPermissions} attribute in its manifest or included the |
| 4741 | * {@link android.R.styleable#AndroidManifestGrantUriPermission |
| 4742 | * <grant-uri-permissions>} tag. |
| 4743 | * |
| 4744 | * @param toPackage The package you would like to allow to access the Uri. |
| 4745 | * @param uri The Uri you would like to grant access to. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4746 | * @param modeFlags The desired access modes. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4747 | * |
| 4748 | * @see #revokeUriPermission |
| 4749 | */ |
| 4750 | public abstract void grantUriPermission(String toPackage, Uri uri, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4751 | @Intent.GrantUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4752 | |
| 4753 | /** |
| 4754 | * Remove all permissions to access a particular content provider Uri |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 4755 | * that were previously added with {@link #grantUriPermission} or <em>any other</em> mechanism. |
| 4756 | * 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] | 4757 | * 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] | 4758 | * revoke both "content://foo/target" and "content://foo/target/sub", but not |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4759 | * "content://foo". It will not remove any prefix grants that exist at a |
| 4760 | * higher level. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4761 | * |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 4762 | * <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] | 4763 | * regular permission access to a Uri, but had received access to it through |
| 4764 | * a specific Uri permission grant, you could not revoke that grant with this |
| 4765 | * function and a {@link SecurityException} would be thrown. As of |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 4766 | * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this function will not throw a security |
| 4767 | * 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] | 4768 | * (or none).</p> |
| 4769 | * |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 4770 | * <p>Unlike {@link #revokeUriPermission(String, Uri, int)}, this method impacts all permission |
| 4771 | * grants matching the given Uri, for any package they had been granted to, through any |
| 4772 | * mechanism this had happened (such as indirectly through the clipboard, activity launch, |
| 4773 | * service start, etc). That means this can be potentially dangerous to use, as it can |
| 4774 | * revoke grants that another app could be strongly expecting to stick around.</p> |
| 4775 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4776 | * @param uri The Uri you would like to revoke access to. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4777 | * @param modeFlags The access modes to revoke. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4778 | * |
| 4779 | * @see #grantUriPermission |
| 4780 | */ |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4781 | 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] | 4782 | |
| 4783 | /** |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 4784 | * Remove permissions to access a particular content provider Uri |
| 4785 | * that were previously added with {@link #grantUriPermission} for a specific target |
| 4786 | * package. The given Uri will match all previously granted Uris that are the same or a |
| 4787 | * sub-path of the given Uri. That is, revoking "content://foo/target" will |
| 4788 | * revoke both "content://foo/target" and "content://foo/target/sub", but not |
| 4789 | * "content://foo". It will not remove any prefix grants that exist at a |
| 4790 | * higher level. |
| 4791 | * |
| 4792 | * <p>Unlike {@link #revokeUriPermission(Uri, int)}, this method will <em>only</em> |
| 4793 | * revoke permissions that had been explicitly granted through {@link #grantUriPermission} |
| 4794 | * and only for the package specified. Any matching grants that have happened through |
| 4795 | * other mechanisms (clipboard, activity launching, service starting, etc) will not be |
| 4796 | * removed.</p> |
| 4797 | * |
| 4798 | * @param toPackage The package you had previously granted access to. |
| 4799 | * @param uri The Uri you would like to revoke access to. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4800 | * @param modeFlags The access modes to revoke. |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 4801 | * |
| 4802 | * @see #grantUriPermission |
| 4803 | */ |
| 4804 | public abstract void revokeUriPermission(String toPackage, Uri uri, |
| 4805 | @Intent.AccessUriMode int modeFlags); |
| 4806 | |
| 4807 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4808 | * Determine whether a particular process and user ID has been granted |
| 4809 | * permission to access a specific URI. This only checks for permissions |
| 4810 | * that have been explicitly granted -- if the given process/uid has |
| 4811 | * more general access to the URI's content provider then this check will |
| 4812 | * always fail. |
| 4813 | * |
| 4814 | * @param uri The uri that is being checked. |
| 4815 | * @param pid The process ID being checked against. Must be > 0. |
| 4816 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 4817 | * user, which will pass every permission check. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4818 | * @param modeFlags The access modes to check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4819 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4820 | * @return {@link PackageManager#PERMISSION_GRANTED} if the given |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4821 | * pid/uid is allowed to access that uri, or |
| 4822 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4823 | * |
| 4824 | * @see #checkCallingUriPermission |
| 4825 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4826 | @CheckResult(suggest="#enforceUriPermission(Uri,int,int,String)") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 4827 | @PackageManager.PermissionResult |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4828 | public abstract int checkUriPermission(Uri uri, int pid, int uid, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4829 | @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4830 | |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 4831 | /** @hide */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 4832 | @PackageManager.PermissionResult |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 4833 | public abstract int checkUriPermission(Uri uri, int pid, int uid, |
| 4834 | @Intent.AccessUriMode int modeFlags, IBinder callerToken); |
| 4835 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4836 | /** |
| 4837 | * Determine whether the calling process and user ID has been |
| 4838 | * granted permission to access a specific URI. This is basically |
| 4839 | * the same as calling {@link #checkUriPermission(Uri, int, int, |
| 4840 | * int)} with the pid and uid returned by {@link |
| 4841 | * android.os.Binder#getCallingPid} and {@link |
| 4842 | * android.os.Binder#getCallingUid}. One important difference is |
| 4843 | * that if you are not currently processing an IPC, this function |
| 4844 | * will always fail. |
| 4845 | * |
| 4846 | * @param uri The uri that is being checked. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4847 | * @param modeFlags The access modes to check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4848 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4849 | * @return {@link PackageManager#PERMISSION_GRANTED} if the caller |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4850 | * is allowed to access that uri, or |
| 4851 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4852 | * |
| 4853 | * @see #checkUriPermission(Uri, int, int, int) |
| 4854 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4855 | @CheckResult(suggest="#enforceCallingUriPermission(Uri,int,String)") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 4856 | @PackageManager.PermissionResult |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4857 | 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] | 4858 | |
| 4859 | /** |
| 4860 | * Determine whether the calling process of an IPC <em>or you</em> has been granted |
| 4861 | * permission to access a specific URI. This is the same as |
| 4862 | * {@link #checkCallingUriPermission}, except it grants your own permissions |
| 4863 | * if you are not currently processing an IPC. Use with care! |
| 4864 | * |
| 4865 | * @param uri The uri that is being checked. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4866 | * @param modeFlags The access modes to check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4867 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4868 | * @return {@link PackageManager#PERMISSION_GRANTED} if the caller |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4869 | * is allowed to access that uri, or |
| 4870 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4871 | * |
| 4872 | * @see #checkCallingUriPermission |
| 4873 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4874 | @CheckResult(suggest="#enforceCallingOrSelfUriPermission(Uri,int,String)") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 4875 | @PackageManager.PermissionResult |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4876 | public abstract int checkCallingOrSelfUriPermission(Uri uri, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4877 | @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4878 | |
| 4879 | /** |
| 4880 | * Check both a Uri and normal permission. This allows you to perform |
| 4881 | * both {@link #checkPermission} and {@link #checkUriPermission} in one |
| 4882 | * call. |
| 4883 | * |
| 4884 | * @param uri The Uri whose permission is to be checked, or null to not |
| 4885 | * do this check. |
| 4886 | * @param readPermission The permission that provides overall read access, |
| 4887 | * or null to not do this check. |
| 4888 | * @param writePermission The permission that provides overall write |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4889 | * access, or null to not do this check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4890 | * @param pid The process ID being checked against. Must be > 0. |
| 4891 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 4892 | * user, which will pass every permission check. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4893 | * @param modeFlags The access modes to check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4894 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4895 | * @return {@link PackageManager#PERMISSION_GRANTED} if the caller |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4896 | * is allowed to access that uri or holds one of the given permissions, or |
| 4897 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4898 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4899 | @CheckResult(suggest="#enforceUriPermission(Uri,String,String,int,int,int,String)") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 4900 | @PackageManager.PermissionResult |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4901 | public abstract int checkUriPermission(@Nullable Uri uri, @Nullable String readPermission, |
| 4902 | @Nullable String writePermission, int pid, int uid, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4903 | @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4904 | |
| 4905 | /** |
| 4906 | * If a particular process and user ID has not been granted |
| 4907 | * permission to access a specific URI, throw {@link |
| 4908 | * SecurityException}. This only checks for permissions that have |
| 4909 | * been explicitly granted -- if the given process/uid has more |
| 4910 | * general access to the URI's content provider then this check |
| 4911 | * will always fail. |
| 4912 | * |
| 4913 | * @param uri The uri that is being checked. |
| 4914 | * @param pid The process ID being checked against. Must be > 0. |
| 4915 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 4916 | * user, which will pass every permission check. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4917 | * @param modeFlags The access modes to enforce. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4918 | * @param message A message to include in the exception if it is thrown. |
| 4919 | * |
| 4920 | * @see #checkUriPermission(Uri, int, int, int) |
| 4921 | */ |
| 4922 | public abstract void enforceUriPermission( |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4923 | 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] | 4924 | |
| 4925 | /** |
| 4926 | * If the calling process and user ID has not been granted |
| 4927 | * permission to access a specific URI, throw {@link |
| 4928 | * SecurityException}. This is basically the same as calling |
| 4929 | * {@link #enforceUriPermission(Uri, int, int, int, String)} with |
| 4930 | * the pid and uid returned by {@link |
| 4931 | * android.os.Binder#getCallingPid} and {@link |
| 4932 | * android.os.Binder#getCallingUid}. One important difference is |
| 4933 | * that if you are not currently processing an IPC, this function |
| 4934 | * will always throw a SecurityException. |
| 4935 | * |
| 4936 | * @param uri The uri that is being checked. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4937 | * @param modeFlags The access modes to enforce. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4938 | * @param message A message to include in the exception if it is thrown. |
| 4939 | * |
| 4940 | * @see #checkCallingUriPermission(Uri, int) |
| 4941 | */ |
| 4942 | public abstract void enforceCallingUriPermission( |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4943 | Uri uri, @Intent.AccessUriMode int modeFlags, String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4944 | |
| 4945 | /** |
| 4946 | * If the calling process of an IPC <em>or you</em> has not been |
| 4947 | * granted permission to access a specific URI, throw {@link |
| 4948 | * SecurityException}. This is the same as {@link |
| 4949 | * #enforceCallingUriPermission}, except it grants your own |
| 4950 | * permissions if you are not currently processing an IPC. Use |
| 4951 | * with care! |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4952 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4953 | * @param uri The uri that is being checked. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4954 | * @param modeFlags The access modes to enforce. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4955 | * @param message A message to include in the exception if it is thrown. |
| 4956 | * |
| 4957 | * @see #checkCallingOrSelfUriPermission(Uri, int) |
| 4958 | */ |
| 4959 | public abstract void enforceCallingOrSelfUriPermission( |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4960 | Uri uri, @Intent.AccessUriMode int modeFlags, String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4961 | |
| 4962 | /** |
| 4963 | * Enforce both a Uri and normal permission. This allows you to perform |
| 4964 | * both {@link #enforcePermission} and {@link #enforceUriPermission} in one |
| 4965 | * call. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4966 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4967 | * @param uri The Uri whose permission is to be checked, or null to not |
| 4968 | * do this check. |
| 4969 | * @param readPermission The permission that provides overall read access, |
| 4970 | * or null to not do this check. |
| 4971 | * @param writePermission The permission that provides overall write |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4972 | * access, or null to not do this check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4973 | * @param pid The process ID being checked against. Must be > 0. |
| 4974 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 4975 | * user, which will pass every permission check. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 4976 | * @param modeFlags The access modes to enforce. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4977 | * @param message A message to include in the exception if it is thrown. |
| 4978 | * |
| 4979 | * @see #checkUriPermission(Uri, String, String, int, int, int) |
| 4980 | */ |
| 4981 | public abstract void enforceUriPermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4982 | @Nullable Uri uri, @Nullable String readPermission, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 4983 | @Nullable String writePermission, int pid, int uid, @Intent.AccessUriMode int modeFlags, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4984 | @Nullable String message); |
| 4985 | |
| 4986 | /** @hide */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 4987 | @IntDef(flag = true, prefix = { "CONTEXT_" }, value = { |
| 4988 | CONTEXT_INCLUDE_CODE, |
| 4989 | CONTEXT_IGNORE_SECURITY, |
| 4990 | CONTEXT_RESTRICTED, |
| 4991 | CONTEXT_DEVICE_PROTECTED_STORAGE, |
| 4992 | CONTEXT_CREDENTIAL_PROTECTED_STORAGE, |
| 4993 | CONTEXT_REGISTER_PACKAGE, |
| 4994 | }) |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4995 | @Retention(RetentionPolicy.SOURCE) |
| 4996 | public @interface CreatePackageOptions {} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4997 | |
| 4998 | /** |
| 4999 | * Flag for use with {@link #createPackageContext}: include the application |
| 5000 | * code with the context. This means loading code into the caller's |
| 5001 | * process, so that {@link #getClassLoader()} can be used to instantiate |
| 5002 | * the application's classes. Setting this flags imposes security |
| 5003 | * restrictions on what application context you can access; if the |
| 5004 | * requested application can not be safely loaded into your process, |
| 5005 | * java.lang.SecurityException will be thrown. If this flag is not set, |
| 5006 | * there will be no restrictions on the packages that can be loaded, |
| 5007 | * but {@link #getClassLoader} will always return the default system |
| 5008 | * class loader. |
| 5009 | */ |
| 5010 | public static final int CONTEXT_INCLUDE_CODE = 0x00000001; |
| 5011 | |
| 5012 | /** |
| 5013 | * Flag for use with {@link #createPackageContext}: ignore any security |
| 5014 | * restrictions on the Context being requested, allowing it to always |
| 5015 | * be loaded. For use with {@link #CONTEXT_INCLUDE_CODE} to allow code |
| 5016 | * to be loaded into a process even when it isn't safe to do so. Use |
| 5017 | * with extreme care! |
| 5018 | */ |
| 5019 | public static final int CONTEXT_IGNORE_SECURITY = 0x00000002; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 5020 | |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 5021 | /** |
| 5022 | * Flag for use with {@link #createPackageContext}: a restricted context may |
| 5023 | * disable specific features. For instance, a View associated with a restricted |
| 5024 | * context would ignore particular XML attributes. |
| 5025 | */ |
| 5026 | public static final int CONTEXT_RESTRICTED = 0x00000004; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5027 | |
| 5028 | /** |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5029 | * Flag for use with {@link #createPackageContext}: point all file APIs at |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5030 | * device-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5031 | * |
| 5032 | * @hide |
| 5033 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5034 | public static final int CONTEXT_DEVICE_PROTECTED_STORAGE = 0x00000008; |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5035 | |
| 5036 | /** |
| 5037 | * Flag for use with {@link #createPackageContext}: point all file APIs at |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5038 | * credential-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5039 | * |
| 5040 | * @hide |
| 5041 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5042 | public static final int CONTEXT_CREDENTIAL_PROTECTED_STORAGE = 0x00000010; |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5043 | |
| 5044 | /** |
Dianne Hackborn | fee756f | 2014-07-16 17:31:10 -0700 | [diff] [blame] | 5045 | * @hide Used to indicate we should tell the activity manager about the process |
| 5046 | * loading this code. |
| 5047 | */ |
| 5048 | public static final int CONTEXT_REGISTER_PACKAGE = 0x40000000; |
| 5049 | |
| 5050 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5051 | * Return a new Context object for the given application name. This |
| 5052 | * Context is the same as what the named application gets when it is |
| 5053 | * launched, containing the same resources and class loader. Each call to |
| 5054 | * this method returns a new instance of a Context object; Context objects |
| 5055 | * are not shared, however they share common state (Resources, ClassLoader, |
| 5056 | * etc) so the Context instance itself is fairly lightweight. |
| 5057 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 5058 | * <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] | 5059 | * application with the given package name. |
| 5060 | * |
| 5061 | * <p>Throws {@link java.lang.SecurityException} if the Context requested |
| 5062 | * can not be loaded into the caller's process for security reasons (see |
| 5063 | * {@link #CONTEXT_INCLUDE_CODE} for more information}. |
| 5064 | * |
| 5065 | * @param packageName Name of the application's package. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5066 | * @param flags Option flags. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5067 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5068 | * @return A {@link Context} for the application. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5069 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5070 | * @throws SecurityException |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5071 | * @throws PackageManager.NameNotFoundException if there is no application with |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5072 | * the given package name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5073 | */ |
| 5074 | public abstract Context createPackageContext(String packageName, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5075 | @CreatePackageOptions int flags) throws PackageManager.NameNotFoundException; |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 5076 | |
| 5077 | /** |
Jeff Sharkey | 6d51571 | 2012-09-20 16:06:08 -0700 | [diff] [blame] | 5078 | * Similar to {@link #createPackageContext(String, int)}, but with a |
| 5079 | * different {@link UserHandle}. For example, {@link #getContentResolver()} |
| 5080 | * will open any {@link Uri} as the given user. |
| 5081 | * |
| 5082 | * @hide |
| 5083 | */ |
Patrick Baumann | ef4c407 | 2018-02-01 08:54:05 -0800 | [diff] [blame] | 5084 | @SystemApi |
Jeff Sharkey | ec5f7d1 | 2018-08-08 09:15:04 -0600 | [diff] [blame] | 5085 | @TestApi |
Patrick Baumann | ef4c407 | 2018-02-01 08:54:05 -0800 | [diff] [blame] | 5086 | public Context createPackageContextAsUser( |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5087 | String packageName, @CreatePackageOptions int flags, UserHandle user) |
Patrick Baumann | ef4c407 | 2018-02-01 08:54:05 -0800 | [diff] [blame] | 5088 | throws PackageManager.NameNotFoundException { |
| 5089 | if (Build.IS_ENG) { |
| 5090 | throw new IllegalStateException("createPackageContextAsUser not overridden!"); |
| 5091 | } |
| 5092 | return this; |
| 5093 | } |
Jeff Sharkey | 6d51571 | 2012-09-20 16:06:08 -0700 | [diff] [blame] | 5094 | |
| 5095 | /** |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5096 | * Creates a context given an {@link android.content.pm.ApplicationInfo}. |
| 5097 | * |
| 5098 | * @hide |
| 5099 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 5100 | @UnsupportedAppUsage |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5101 | public abstract Context createApplicationContext(ApplicationInfo application, |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5102 | @CreatePackageOptions int flags) throws PackageManager.NameNotFoundException; |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5103 | |
| 5104 | /** |
Adam Lesinski | 4e86281 | 2016-11-21 16:02:24 -0800 | [diff] [blame] | 5105 | * Return a new Context object for the given split name. The new Context has a ClassLoader and |
| 5106 | * Resources object that can access the split's and all of its dependencies' code/resources. |
| 5107 | * Each call to this method returns a new instance of a Context object; |
| 5108 | * Context objects are not shared, however common state (ClassLoader, other Resources for |
| 5109 | * the same split) may be so the Context itself can be fairly lightweight. |
| 5110 | * |
| 5111 | * @param splitName The name of the split to include, as declared in the split's |
| 5112 | * <code>AndroidManifest.xml</code>. |
| 5113 | * @return A {@link Context} with the given split's code and/or resources loaded. |
| 5114 | */ |
| 5115 | public abstract Context createContextForSplit(String splitName) |
| 5116 | throws PackageManager.NameNotFoundException; |
| 5117 | |
| 5118 | /** |
Jeff Sharkey | ad357d1 | 2018-02-02 13:25:31 -0700 | [diff] [blame] | 5119 | * Get the user associated with this context |
Jim Miller | a75a883 | 2013-02-07 16:53:32 -0800 | [diff] [blame] | 5120 | * @hide |
| 5121 | */ |
Jeff Sharkey | a73b8fd | 2016-01-06 17:02:08 -0700 | [diff] [blame] | 5122 | @TestApi |
Jeff Sharkey | ad357d1 | 2018-02-02 13:25:31 -0700 | [diff] [blame] | 5123 | public UserHandle getUser() { |
| 5124 | return android.os.Process.myUserHandle(); |
| 5125 | } |
| 5126 | |
| 5127 | /** |
| 5128 | * Get the user associated with this context |
| 5129 | * @hide |
| 5130 | */ |
| 5131 | @TestApi |
| 5132 | public @UserIdInt int getUserId() { |
| 5133 | return android.os.UserHandle.myUserId(); |
| 5134 | } |
Jim Miller | a75a883 | 2013-02-07 16:53:32 -0800 | [diff] [blame] | 5135 | |
| 5136 | /** |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 5137 | * Return a new Context object for the current Context but whose resources |
| 5138 | * are adjusted to match the given Configuration. Each call to this method |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 5139 | * returns a new instance of a Context object; Context objects are not |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 5140 | * shared, however common state (ClassLoader, other Resources for the |
| 5141 | * same configuration) may be so the Context itself can be fairly lightweight. |
| 5142 | * |
| 5143 | * @param overrideConfiguration A {@link Configuration} specifying what |
| 5144 | * values to modify in the base Configuration of the original Context's |
| 5145 | * resources. If the base configuration changes (such as due to an |
| 5146 | * orientation change), the resources of this context will also change except |
| 5147 | * for those that have been explicitly overridden with a value here. |
| 5148 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5149 | * @return A {@link Context} with the given configuration override. |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 5150 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5151 | public abstract Context createConfigurationContext( |
| 5152 | @NonNull Configuration overrideConfiguration); |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 5153 | |
| 5154 | /** |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 5155 | * Return a new Context object for the current Context but whose resources |
| 5156 | * are adjusted to match the metrics of the given Display. Each call to this method |
| 5157 | * returns a new instance of a Context object; Context objects are not |
| 5158 | * shared, however common state (ClassLoader, other Resources for the |
| 5159 | * same configuration) may be so the Context itself can be fairly lightweight. |
| 5160 | * |
| 5161 | * The returned display Context provides a {@link WindowManager} |
| 5162 | * (see {@link #getSystemService(String)}) that is configured to show windows |
| 5163 | * on the given display. The WindowManager's {@link WindowManager#getDefaultDisplay} |
| 5164 | * method can be used to retrieve the Display from the returned Context. |
| 5165 | * |
| 5166 | * @param display A {@link Display} object specifying the display |
| 5167 | * for whose metrics the Context's resources should be tailored and upon which |
| 5168 | * new windows should be shown. |
| 5169 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5170 | * @return A {@link Context} for the display. |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 5171 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5172 | public abstract Context createDisplayContext(@NonNull Display display); |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 5173 | |
| 5174 | /** |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5175 | * Return a new Context object for the current Context but whose storage |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5176 | * APIs are backed by device-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5177 | * <p> |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 5178 | * On devices with direct boot, data stored in this location is encrypted |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5179 | * with a key tied to the physical device, and it can be accessed |
| 5180 | * immediately after the device has booted successfully, both |
| 5181 | * <em>before and after</em> the user has authenticated with their |
| 5182 | * credentials (such as a lock pattern or PIN). |
| 5183 | * <p> |
| 5184 | * Because device-protected data is available without user authentication, |
| 5185 | * you should carefully limit the data you store using this Context. For |
| 5186 | * example, storing sensitive authentication tokens or passwords in the |
| 5187 | * device-protected area is strongly discouraged. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5188 | * <p> |
Jeff Sharkey | 3ea44a5 | 2016-01-09 15:19:56 -0700 | [diff] [blame] | 5189 | * If the underlying device does not have the ability to store |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5190 | * device-protected and credential-protected data using different keys, then |
| 5191 | * both storage areas will become available at the same time. They remain as |
| 5192 | * two distinct storage locations on disk, and only the window of |
| 5193 | * availability changes. |
Jeff Sharkey | 3ea44a5 | 2016-01-09 15:19:56 -0700 | [diff] [blame] | 5194 | * <p> |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5195 | * Each call to this method returns a new instance of a Context object; |
| 5196 | * Context objects are not shared, however common state (ClassLoader, other |
| 5197 | * Resources for the same configuration) may be so the Context itself can be |
| 5198 | * fairly lightweight. |
| 5199 | * |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5200 | * @see #isDeviceProtectedStorage() |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5201 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5202 | public abstract Context createDeviceProtectedStorageContext(); |
| 5203 | |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5204 | /** |
| 5205 | * Return a new Context object for the current Context but whose storage |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5206 | * APIs are backed by credential-protected storage. This is the default |
| 5207 | * storage area for apps unless |
| 5208 | * {@link android.R.attr#defaultToDeviceProtectedStorage} was requested. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5209 | * <p> |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 5210 | * On devices with direct boot, data stored in this location is encrypted |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5211 | * with a key tied to user credentials, which can be accessed |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5212 | * <em>only after</em> the user has entered their credentials (such as a |
| 5213 | * lock pattern or PIN). |
| 5214 | * <p> |
Jeff Sharkey | 3ea44a5 | 2016-01-09 15:19:56 -0700 | [diff] [blame] | 5215 | * If the underlying device does not have the ability to store |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5216 | * device-protected and credential-protected data using different keys, then |
| 5217 | * both storage areas will become available at the same time. They remain as |
| 5218 | * two distinct storage locations on disk, and only the window of |
| 5219 | * availability changes. |
Jeff Sharkey | 3ea44a5 | 2016-01-09 15:19:56 -0700 | [diff] [blame] | 5220 | * <p> |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5221 | * Each call to this method returns a new instance of a Context object; |
| 5222 | * Context objects are not shared, however common state (ClassLoader, other |
| 5223 | * Resources for the same configuration) may be so the Context itself can be |
| 5224 | * fairly lightweight. |
| 5225 | * |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5226 | * @see #isCredentialProtectedStorage() |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 5227 | * @hide |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5228 | */ |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 5229 | @SystemApi |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5230 | public abstract Context createCredentialProtectedStorageContext(); |
| 5231 | |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5232 | /** |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 5233 | * Gets the display adjustments holder for this context. This information |
| 5234 | * is provided on a per-application or activity basis and is used to simulate lower density |
| 5235 | * display metrics for legacy applications and restricted screen sizes. |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 5236 | * |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 5237 | * @param displayId The display id for which to get compatibility info. |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 5238 | * @return The compatibility info holder, or null if not required by the application. |
| 5239 | * @hide |
| 5240 | */ |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 5241 | public abstract DisplayAdjustments getDisplayAdjustments(int displayId); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 5242 | |
| 5243 | /** |
Wale Ogunwale | 691af68 | 2019-02-11 03:09:10 -0800 | [diff] [blame^] | 5244 | * @return Returns the {@link Display} object this context is associated with. |
Adam Lesinski | 4ece3d6 | 2016-06-16 18:05:41 -0700 | [diff] [blame] | 5245 | * @hide |
| 5246 | */ |
Wale Ogunwale | 691af68 | 2019-02-11 03:09:10 -0800 | [diff] [blame^] | 5247 | @TestApi |
Adam Lesinski | 4ece3d6 | 2016-06-16 18:05:41 -0700 | [diff] [blame] | 5248 | public abstract Display getDisplay(); |
| 5249 | |
| 5250 | /** |
Yohei Yukawa | 5281b6b | 2018-10-15 07:38:25 +0800 | [diff] [blame] | 5251 | * Gets the display ID. |
| 5252 | * |
| 5253 | * @return display ID associated with this {@link Context}. |
| 5254 | * @hide |
| 5255 | */ |
| 5256 | public abstract int getDisplayId(); |
| 5257 | |
| 5258 | /** |
Andrii Kulian | b047b8b | 2017-02-08 18:38:26 -0800 | [diff] [blame] | 5259 | * @hide |
| 5260 | */ |
| 5261 | public abstract void updateDisplay(int displayId); |
| 5262 | |
| 5263 | /** |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 5264 | * Indicates whether this Context is restricted. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 5265 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5266 | * @return {@code true} if this Context is restricted, {@code false} otherwise. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 5267 | * |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 5268 | * @see #CONTEXT_RESTRICTED |
| 5269 | */ |
| 5270 | public boolean isRestricted() { |
| 5271 | return false; |
| 5272 | } |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5273 | |
| 5274 | /** |
| 5275 | * Indicates if the storage APIs of this Context are backed by |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5276 | * device-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5277 | * |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5278 | * @see #createDeviceProtectedStorageContext() |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5279 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5280 | public abstract boolean isDeviceProtectedStorage(); |
| 5281 | |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5282 | /** |
| 5283 | * Indicates if the storage APIs of this Context are backed by |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5284 | * credential-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5285 | * |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5286 | * @see #createCredentialProtectedStorageContext() |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 5287 | * @hide |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5288 | */ |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 5289 | @SystemApi |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5290 | public abstract boolean isCredentialProtectedStorage(); |
| 5291 | |
Tony Mak | 46aabe5 | 2016-11-14 12:53:06 +0000 | [diff] [blame] | 5292 | /** |
Seigo Nonaka | 6d6cd68 | 2017-06-22 08:22:18 -0700 | [diff] [blame] | 5293 | * Returns true if the context can load unsafe resources, e.g. fonts. |
| 5294 | * @hide |
| 5295 | */ |
| 5296 | public abstract boolean canLoadUnsafeResources(); |
| 5297 | |
| 5298 | /** |
Tony Mak | 46aabe5 | 2016-11-14 12:53:06 +0000 | [diff] [blame] | 5299 | * @hide |
| 5300 | */ |
| 5301 | public IBinder getActivityToken() { |
| 5302 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 5303 | } |
| 5304 | |
| 5305 | /** |
| 5306 | * @hide |
| 5307 | */ |
| 5308 | @Nullable |
| 5309 | public IServiceConnection getServiceDispatcher(ServiceConnection conn, Handler handler, |
| 5310 | int flags) { |
| 5311 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 5312 | } |
| 5313 | |
| 5314 | /** |
| 5315 | * @hide |
| 5316 | */ |
| 5317 | public IApplicationThread getIApplicationThread() { |
| 5318 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 5319 | } |
Tony Mak | bf9928d | 2016-12-22 11:02:45 +0000 | [diff] [blame] | 5320 | |
| 5321 | /** |
| 5322 | * @hide |
| 5323 | */ |
| 5324 | public Handler getMainThreadHandler() { |
| 5325 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 5326 | } |
Adam Lesinski | a82b626 | 2017-03-21 16:56:17 -0700 | [diff] [blame] | 5327 | |
| 5328 | /** |
Felipe Leme | bb567ae | 2017-10-04 09:56:21 -0700 | [diff] [blame] | 5329 | * @hide |
| 5330 | */ |
| 5331 | public AutofillClient getAutofillClient() { |
| 5332 | return null; |
| 5333 | } |
| 5334 | |
| 5335 | /** |
| 5336 | * @hide |
| 5337 | */ |
Svet Ganov | 47b37aa | 2018-02-16 00:11:39 -0800 | [diff] [blame] | 5338 | public void setAutofillClient(@SuppressWarnings("unused") AutofillClient client) { |
Felipe Leme | bb567ae | 2017-10-04 09:56:21 -0700 | [diff] [blame] | 5339 | } |
| 5340 | |
| 5341 | /** |
Svetoslav Ganov | 24c9045 | 2017-12-27 15:17:14 -0800 | [diff] [blame] | 5342 | * @hide |
| 5343 | */ |
Felipe Leme | a4f39cd | 2019-02-19 15:08:59 -0800 | [diff] [blame] | 5344 | public final boolean isAutofillCompatibilityEnabled() { |
| 5345 | final AutofillOptions options = getAutofillOptions(); |
| 5346 | return options != null && options.compatModeEnabled; |
| 5347 | } |
| 5348 | |
| 5349 | /** |
| 5350 | * @hide |
| 5351 | */ |
| 5352 | @Nullable |
| 5353 | public AutofillOptions getAutofillOptions() { |
| 5354 | return null; |
Svetoslav Ganov | 24c9045 | 2017-12-27 15:17:14 -0800 | [diff] [blame] | 5355 | } |
| 5356 | |
| 5357 | /** |
| 5358 | * @hide |
| 5359 | */ |
Svet Ganov | 47b37aa | 2018-02-16 00:11:39 -0800 | [diff] [blame] | 5360 | @TestApi |
Felipe Leme | a4f39cd | 2019-02-19 15:08:59 -0800 | [diff] [blame] | 5361 | public void setAutofillOptions(@SuppressWarnings("unused") @Nullable AutofillOptions options) { |
Svetoslav Ganov | 24c9045 | 2017-12-27 15:17:14 -0800 | [diff] [blame] | 5362 | } |
| 5363 | |
| 5364 | /** |
Felipe Leme | 326f15a | 2019-02-19 09:42:24 -0800 | [diff] [blame] | 5365 | * Gets the Content Capture options for this context, or {@code null} if it's not whitelisted. |
Felipe Leme | ecb08be | 2018-11-27 15:48:47 -0800 | [diff] [blame] | 5366 | * |
| 5367 | * @hide |
| 5368 | */ |
Felipe Leme | 326f15a | 2019-02-19 09:42:24 -0800 | [diff] [blame] | 5369 | @Nullable |
| 5370 | public ContentCaptureOptions getContentCaptureOptions() { |
| 5371 | return null; |
Felipe Leme | ecb08be | 2018-11-27 15:48:47 -0800 | [diff] [blame] | 5372 | } |
| 5373 | |
| 5374 | /** |
| 5375 | * @hide |
| 5376 | */ |
Felipe Leme | 326f15a | 2019-02-19 09:42:24 -0800 | [diff] [blame] | 5377 | @TestApi |
| 5378 | public void setContentCaptureOptions( |
| 5379 | @SuppressWarnings("unused") @Nullable ContentCaptureOptions options) { |
Felipe Leme | ecb08be | 2018-11-27 15:48:47 -0800 | [diff] [blame] | 5380 | } |
| 5381 | |
| 5382 | /** |
Adam Lesinski | a82b626 | 2017-03-21 16:56:17 -0700 | [diff] [blame] | 5383 | * Throws an exception if the Context is using system resources, |
| 5384 | * which are non-runtime-overlay-themable and may show inconsistent UI. |
| 5385 | * @hide |
| 5386 | */ |
| 5387 | public void assertRuntimeOverlayThemable() { |
| 5388 | // Resources.getSystem() is a singleton and the only Resources not managed by |
| 5389 | // ResourcesManager; therefore Resources.getSystem() is not themable. |
| 5390 | if (getResources() == Resources.getSystem()) { |
| 5391 | throw new IllegalArgumentException("Non-UI context used to display UI; " |
| 5392 | + "get a UI context from ActivityThread#getSystemUiContext()"); |
| 5393 | } |
| 5394 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5395 | } |