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; |
Bo Liu | 58a5766 | 2019-03-06 20:21:45 +0000 | [diff] [blame] | 20 | import android.annotation.CallbackExecutor; |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 21 | import android.annotation.CheckResult; |
Tor Norbye | 3e4cda7 | 2015-06-10 08:14:31 -0700 | [diff] [blame] | 22 | import android.annotation.ColorInt; |
| 23 | import android.annotation.ColorRes; |
| 24 | import android.annotation.DrawableRes; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 25 | import android.annotation.IntDef; |
| 26 | import android.annotation.NonNull; |
| 27 | import android.annotation.Nullable; |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 28 | import android.annotation.RequiresPermission; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 29 | import android.annotation.StringDef; |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 30 | import android.annotation.StringRes; |
| 31 | import android.annotation.StyleRes; |
| 32 | import android.annotation.StyleableRes; |
Jinsuk Kim | 66d1eb2 | 2014-06-06 16:12:18 +0900 | [diff] [blame] | 33 | import android.annotation.SystemApi; |
Jeff Sharkey | a73b8fd | 2016-01-06 17:02:08 -0700 | [diff] [blame] | 34 | import android.annotation.TestApi; |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 35 | import android.annotation.UnsupportedAppUsage; |
Jeff Sharkey | 8588bc1 | 2016-01-06 16:47:42 -0700 | [diff] [blame] | 36 | import android.annotation.UserIdInt; |
Selim Cinek | 7fa385a | 2018-01-24 08:35:28 -0800 | [diff] [blame] | 37 | import android.app.ActivityManager; |
Tony Mak | 46aabe5 | 2016-11-14 12:53:06 +0000 | [diff] [blame] | 38 | import android.app.IApplicationThread; |
| 39 | import android.app.IServiceConnection; |
Zak Cohen | 56345f4 | 2017-01-26 13:54:28 -0800 | [diff] [blame] | 40 | import android.app.VrManager; |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 41 | import android.content.pm.ApplicationInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 42 | import android.content.pm.PackageManager; |
| 43 | import android.content.res.AssetManager; |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 44 | import android.content.res.ColorStateList; |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 45 | import android.content.res.Configuration; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 46 | import android.content.res.Resources; |
| 47 | import android.content.res.TypedArray; |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 48 | import android.database.DatabaseErrorHandler; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 49 | import android.database.sqlite.SQLiteDatabase; |
| 50 | import android.database.sqlite.SQLiteDatabase.CursorFactory; |
| 51 | import android.graphics.Bitmap; |
| 52 | import android.graphics.drawable.Drawable; |
| 53 | import android.net.Uri; |
Patrick Baumann | ef4c407 | 2018-02-01 08:54:05 -0800 | [diff] [blame] | 54 | import android.os.Build; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | import android.os.Bundle; |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 56 | import android.os.Environment; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | import android.os.Handler; |
Jeff Sharkey | 8439ac0 | 2017-12-12 17:26:23 -0700 | [diff] [blame] | 58 | import android.os.HandlerExecutor; |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 59 | import android.os.IBinder; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 60 | import android.os.Looper; |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 61 | import android.os.StatFs; |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 62 | import android.os.UserHandle; |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 63 | import android.os.UserManager; |
Jeff Sharkey | 60a82cd | 2017-04-18 18:19:16 -0600 | [diff] [blame] | 64 | import android.os.storage.StorageManager; |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 65 | import android.provider.MediaStore; |
Chen Xu | 1f6cfa5 | 2019-10-13 17:30:32 -0700 | [diff] [blame] | 66 | import android.telephony.TelephonyRegistryManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 67 | import android.util.AttributeSet; |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 68 | import android.view.Display; |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 69 | import android.view.DisplayAdjustments; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 70 | import android.view.View; |
Jon Miranda | 836c0a8 | 2014-08-11 12:32:26 -0700 | [diff] [blame] | 71 | import android.view.ViewDebug; |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 72 | import android.view.WindowManager; |
Felipe Leme | bb567ae | 2017-10-04 09:56:21 -0700 | [diff] [blame] | 73 | import android.view.autofill.AutofillManager.AutofillClient; |
Felipe Leme | cbf7f26 | 2019-04-17 13:57:59 -0700 | [diff] [blame] | 74 | import android.view.contentcapture.ContentCaptureManager.ContentCaptureClient; |
Abodunrinwa Toki | f001fef | 2017-01-04 23:51:42 +0000 | [diff] [blame] | 75 | import android.view.textclassifier.TextClassificationManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 76 | |
atrost | a6a4d60 | 2019-08-21 16:48:56 +0100 | [diff] [blame] | 77 | import com.android.internal.compat.IPlatformCompat; |
atrost | 8748835 | 2019-10-10 19:27:31 +0100 | [diff] [blame] | 78 | import com.android.internal.compat.IPlatformCompatNative; |
atrost | a6a4d60 | 2019-08-21 16:48:56 +0100 | [diff] [blame] | 79 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 80 | import java.io.File; |
| 81 | import java.io.FileInputStream; |
| 82 | import java.io.FileNotFoundException; |
| 83 | import java.io.FileOutputStream; |
| 84 | import java.io.IOException; |
| 85 | import java.io.InputStream; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 86 | import java.lang.annotation.Retention; |
| 87 | import java.lang.annotation.RetentionPolicy; |
Jeff Sharkey | 8439ac0 | 2017-12-12 17:26:23 -0700 | [diff] [blame] | 88 | import java.util.concurrent.Executor; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 89 | |
| 90 | /** |
| 91 | * Interface to global information about an application environment. This is |
| 92 | * an abstract class whose implementation is provided by |
| 93 | * the Android system. It |
| 94 | * allows access to application-specific resources and classes, as well as |
| 95 | * up-calls for application-level operations such as launching activities, |
| 96 | * broadcasting and receiving intents, etc. |
| 97 | */ |
| 98 | public abstract class Context { |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 99 | /** @hide */ |
| 100 | @IntDef(flag = true, prefix = { "MODE_" }, value = { |
| 101 | MODE_PRIVATE, |
| 102 | MODE_WORLD_READABLE, |
| 103 | MODE_WORLD_WRITEABLE, |
| 104 | MODE_APPEND, |
| 105 | }) |
| 106 | @Retention(RetentionPolicy.SOURCE) |
| 107 | public @interface FileMode {} |
| 108 | |
| 109 | /** @hide */ |
| 110 | @IntDef(flag = true, prefix = { "MODE_" }, value = { |
| 111 | MODE_PRIVATE, |
| 112 | MODE_WORLD_READABLE, |
| 113 | MODE_WORLD_WRITEABLE, |
| 114 | MODE_MULTI_PROCESS, |
| 115 | }) |
| 116 | @Retention(RetentionPolicy.SOURCE) |
| 117 | public @interface PreferencesMode {} |
| 118 | |
| 119 | /** @hide */ |
| 120 | @IntDef(flag = true, prefix = { "MODE_" }, value = { |
| 121 | MODE_PRIVATE, |
| 122 | MODE_WORLD_READABLE, |
| 123 | MODE_WORLD_WRITEABLE, |
| 124 | MODE_ENABLE_WRITE_AHEAD_LOGGING, |
| 125 | MODE_NO_LOCALIZED_COLLATORS, |
| 126 | }) |
| 127 | @Retention(RetentionPolicy.SOURCE) |
| 128 | public @interface DatabaseMode {} |
| 129 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 130 | /** |
| 131 | * File creation mode: the default mode, where the created file can only |
| 132 | * be accessed by the calling application (or all applications sharing the |
| 133 | * same user ID). |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 134 | */ |
| 135 | public static final int MODE_PRIVATE = 0x0000; |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 136 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 137 | /** |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 138 | * File creation mode: allow all other applications to have read access to |
| 139 | * the created file. |
| 140 | * <p> |
Dave Friedman | cfe5088 | 2017-07-05 00:40:07 -0700 | [diff] [blame] | 141 | * Starting from {@link android.os.Build.VERSION_CODES#N}, attempting to use this |
| 142 | * mode throws a {@link SecurityException}. |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 143 | * |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 144 | * @deprecated Creating world-readable files is very dangerous, and likely |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 145 | * to cause security holes in applications. It is strongly |
| 146 | * discouraged; instead, applications should use more formal |
| 147 | * mechanism for interactions such as {@link ContentProvider}, |
| 148 | * {@link BroadcastReceiver}, and {@link android.app.Service}. |
| 149 | * There are no guarantees that this access mode will remain on |
| 150 | * a file, such as when it goes through a backup and restore. |
| 151 | * @see android.support.v4.content.FileProvider |
| 152 | * @see Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 153 | */ |
Dianne Hackborn | 556b09e | 2012-09-23 17:46:53 -0700 | [diff] [blame] | 154 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 155 | public static final int MODE_WORLD_READABLE = 0x0001; |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 156 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 157 | /** |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 158 | * File creation mode: allow all other applications to have write access to |
| 159 | * the created file. |
| 160 | * <p> |
Dave Friedman | cfe5088 | 2017-07-05 00:40:07 -0700 | [diff] [blame] | 161 | * 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] | 162 | * mode will throw a {@link SecurityException}. |
| 163 | * |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 164 | * @deprecated Creating world-writable files is very dangerous, and likely |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 165 | * to cause security holes in applications. It is strongly |
| 166 | * discouraged; instead, applications should use more formal |
| 167 | * mechanism for interactions such as {@link ContentProvider}, |
| 168 | * {@link BroadcastReceiver}, and {@link android.app.Service}. |
| 169 | * There are no guarantees that this access mode will remain on |
| 170 | * a file, such as when it goes through a backup and restore. |
| 171 | * @see android.support.v4.content.FileProvider |
| 172 | * @see Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 173 | */ |
Dianne Hackborn | 556b09e | 2012-09-23 17:46:53 -0700 | [diff] [blame] | 174 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 175 | public static final int MODE_WORLD_WRITEABLE = 0x0002; |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 176 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 177 | /** |
| 178 | * File creation mode: for use with {@link #openFileOutput}, if the file |
| 179 | * already exists then write data to the end of the existing file |
| 180 | * instead of erasing it. |
| 181 | * @see #openFileOutput |
| 182 | */ |
| 183 | public static final int MODE_APPEND = 0x8000; |
| 184 | |
| 185 | /** |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 186 | * SharedPreference loading flag: when set, the file on disk will |
| 187 | * be checked for modification even if the shared preferences |
| 188 | * instance is already loaded in this process. This behavior is |
| 189 | * sometimes desired in cases where the application has multiple |
| 190 | * processes, all writing to the same SharedPreferences file. |
| 191 | * Generally there are better forms of communication between |
| 192 | * processes, though. |
| 193 | * |
| 194 | * <p>This was the legacy (but undocumented) behavior in and |
| 195 | * before Gingerbread (Android 2.3) and this flag is implied when |
kopriva | 219f7dc | 2018-10-09 13:42:28 -0700 | [diff] [blame] | 196 | * targeting such releases. For applications targeting SDK |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 197 | * versions <em>greater than</em> Android 2.3, this flag must be |
| 198 | * explicitly set if desired. |
| 199 | * |
| 200 | * @see #getSharedPreferences |
Christopher Tate | d5748b8 | 2015-05-08 18:14:01 -0700 | [diff] [blame] | 201 | * |
| 202 | * @deprecated MODE_MULTI_PROCESS does not work reliably in |
| 203 | * some versions of Android, and furthermore does not provide any |
| 204 | * mechanism for reconciling concurrent modifications across |
| 205 | * processes. Applications should not attempt to use it. Instead, |
| 206 | * they should use an explicit cross-process data management |
| 207 | * approach such as {@link android.content.ContentProvider ContentProvider}. |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 208 | */ |
Christopher Tate | d5748b8 | 2015-05-08 18:14:01 -0700 | [diff] [blame] | 209 | @Deprecated |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 210 | public static final int MODE_MULTI_PROCESS = 0x0004; |
| 211 | |
| 212 | /** |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 213 | * Database open flag: when set, the database is opened with write-ahead |
| 214 | * logging enabled by default. |
| 215 | * |
| 216 | * @see #openOrCreateDatabase(String, int, CursorFactory) |
| 217 | * @see #openOrCreateDatabase(String, int, CursorFactory, DatabaseErrorHandler) |
| 218 | * @see SQLiteDatabase#enableWriteAheadLogging |
| 219 | */ |
| 220 | public static final int MODE_ENABLE_WRITE_AHEAD_LOGGING = 0x0008; |
| 221 | |
Sunny Goyal | a21e6b2 | 2015-12-02 09:51:02 -0800 | [diff] [blame] | 222 | /** |
| 223 | * Database open flag: when set, the database is opened without support for |
| 224 | * localized collators. |
| 225 | * |
| 226 | * @see #openOrCreateDatabase(String, int, CursorFactory) |
| 227 | * @see #openOrCreateDatabase(String, int, CursorFactory, DatabaseErrorHandler) |
| 228 | * @see SQLiteDatabase#NO_LOCALIZED_COLLATORS |
| 229 | */ |
| 230 | public static final int MODE_NO_LOCALIZED_COLLATORS = 0x0010; |
| 231 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 232 | /** @hide */ |
Jeff Sharkey | ce8db99 | 2017-12-13 20:05:05 -0700 | [diff] [blame] | 233 | @IntDef(flag = true, prefix = { "BIND_" }, value = { |
| 234 | BIND_AUTO_CREATE, |
| 235 | BIND_DEBUG_UNBIND, |
| 236 | BIND_NOT_FOREGROUND, |
| 237 | BIND_ABOVE_CLIENT, |
| 238 | BIND_ALLOW_OOM_MANAGEMENT, |
| 239 | BIND_WAIVE_PRIORITY, |
| 240 | BIND_IMPORTANT, |
Amith Yamasani | 5016a78 | 2019-06-17 16:20:24 -0700 | [diff] [blame] | 241 | BIND_ADJUST_WITH_ACTIVITY, |
| 242 | BIND_NOT_PERCEPTIBLE, |
| 243 | BIND_INCLUDE_CAPABILITIES |
Jeff Sharkey | ce8db99 | 2017-12-13 20:05:05 -0700 | [diff] [blame] | 244 | }) |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 245 | @Retention(RetentionPolicy.SOURCE) |
| 246 | public @interface BindServiceFlags {} |
| 247 | |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 248 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 249 | * Flag for {@link #bindService}: automatically create the service as long |
| 250 | * as the binding exists. Note that while this will create the service, |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 251 | * its {@link android.app.Service#onStartCommand} |
| 252 | * method will still only be called due to an |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 253 | * explicit call to {@link #startService}. Even without that, though, |
| 254 | * this still provides you with access to the service object while the |
| 255 | * service is created. |
| 256 | * |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 257 | * <p>Note that prior to {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, |
| 258 | * not supplying this flag would also impact how important the system |
| 259 | * consider's the target service's process to be. When set, the only way |
| 260 | * for it to be raised was by binding from a service in which case it will |
| 261 | * only be important when that activity is in the foreground. Now to |
| 262 | * achieve this behavior you must explicitly supply the new flag |
| 263 | * {@link #BIND_ADJUST_WITH_ACTIVITY}. For compatibility, old applications |
| 264 | * that don't specify {@link #BIND_AUTO_CREATE} will automatically have |
| 265 | * the flags {@link #BIND_WAIVE_PRIORITY} and |
| 266 | * {@link #BIND_ADJUST_WITH_ACTIVITY} set for them in order to achieve |
| 267 | * the same result. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 268 | */ |
| 269 | public static final int BIND_AUTO_CREATE = 0x0001; |
| 270 | |
| 271 | /** |
| 272 | * Flag for {@link #bindService}: include debugging help for mismatched |
| 273 | * calls to unbind. When this flag is set, the callstack of the following |
| 274 | * {@link #unbindService} call is retained, to be printed if a later |
| 275 | * incorrect unbind call is made. Note that doing this requires retaining |
| 276 | * information about the binding that was made for the lifetime of the app, |
| 277 | * resulting in a leak -- this should only be used for debugging. |
| 278 | */ |
| 279 | public static final int BIND_DEBUG_UNBIND = 0x0002; |
| 280 | |
Dianne Hackborn | 09c916b | 2009-12-08 14:50:51 -0800 | [diff] [blame] | 281 | /** |
| 282 | * Flag for {@link #bindService}: don't allow this binding to raise |
| 283 | * the target service's process to the foreground scheduling priority. |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 284 | * It will still be raised to at least the same memory priority |
Dianne Hackborn | 09c916b | 2009-12-08 14:50:51 -0800 | [diff] [blame] | 285 | * as the client (so that its process will not be killable in any |
| 286 | * situation where the client is not killable), but for CPU scheduling |
| 287 | * purposes it may be left in the background. This only has an impact |
| 288 | * in the situation where the binding client is a foreground process |
| 289 | * and the target service is in a background process. |
| 290 | */ |
| 291 | public static final int BIND_NOT_FOREGROUND = 0x0004; |
| 292 | |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 293 | /** |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 294 | * Flag for {@link #bindService}: indicates that the client application |
| 295 | * binding to this service considers the service to be more important than |
| 296 | * 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] | 297 | * 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] | 298 | * this is not guaranteed to be the case. |
| 299 | */ |
| 300 | public static final int BIND_ABOVE_CLIENT = 0x0008; |
| 301 | |
| 302 | /** |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 303 | * Flag for {@link #bindService}: allow the process hosting the bound |
| 304 | * service to go through its normal memory management. It will be |
| 305 | * treated more like a running service, allowing the system to |
| 306 | * (temporarily) expunge the process if low on memory or for some other |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 307 | * whim it may have, and being more aggressive about making it a candidate |
| 308 | * to be killed (and restarted) if running for a long time. |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 309 | */ |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 310 | public static final int BIND_ALLOW_OOM_MANAGEMENT = 0x0010; |
| 311 | |
| 312 | /** |
| 313 | * Flag for {@link #bindService}: don't impact the scheduling or |
| 314 | * memory management priority of the target service's hosting process. |
| 315 | * Allows the service's process to be managed on the background LRU list |
| 316 | * just like a regular application process in the background. |
| 317 | */ |
| 318 | public static final int BIND_WAIVE_PRIORITY = 0x0020; |
| 319 | |
| 320 | /** |
| 321 | * Flag for {@link #bindService}: this service is very important to |
| 322 | * the client, so should be brought to the foreground process level |
| 323 | * when the client is. Normally a process can only be raised to the |
| 324 | * visibility level by a client, even if that client is in the foreground. |
| 325 | */ |
| 326 | public static final int BIND_IMPORTANT = 0x0040; |
| 327 | |
| 328 | /** |
| 329 | * Flag for {@link #bindService}: If binding from an activity, allow the |
| 330 | * target service's process importance to be raised based on whether the |
| 331 | * activity is visible to the user, regardless whether another flag is |
| 332 | * used to reduce the amount that the client process's overall importance |
| 333 | * is used to impact it. |
| 334 | */ |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 335 | public static final int BIND_ADJUST_WITH_ACTIVITY = 0x0080; |
| 336 | |
| 337 | /** |
Amith Yamasani | 5016a78 | 2019-06-17 16:20:24 -0700 | [diff] [blame] | 338 | * Flag for {@link #bindService}: If binding from an app that is visible or user-perceptible, |
| 339 | * lower the target service's importance to below the perceptible level. This allows |
| 340 | * the system to (temporarily) expunge the bound process from memory to make room for more |
| 341 | * important user-perceptible processes. |
| 342 | */ |
| 343 | public static final int BIND_NOT_PERCEPTIBLE = 0x00000100; |
| 344 | |
| 345 | /** |
Amith Yamasani | f178c96 | 2019-03-21 19:40:11 -0700 | [diff] [blame] | 346 | * Flag for {@link #bindService}: If binding from an app that has specific capabilities |
| 347 | * due to its foreground state such as an activity or foreground service, then this flag will |
| 348 | * allow the bound app to get the same capabilities, as long as it has the required permissions |
| 349 | * as well. |
| 350 | */ |
Amith Yamasani | 5016a78 | 2019-06-17 16:20:24 -0700 | [diff] [blame] | 351 | public static final int BIND_INCLUDE_CAPABILITIES = 0x000001000; |
Amith Yamasani | f178c96 | 2019-03-21 19:40:11 -0700 | [diff] [blame] | 352 | |
Amith Yamasani | 0b3ae0e | 2019-05-10 10:29:47 -0700 | [diff] [blame] | 353 | /*********** Public flags above this line ***********/ |
| 354 | /*********** Hidden flags below this line ***********/ |
| 355 | |
| 356 | /** |
Yohei Yukawa | 5973096 | 2019-03-18 10:47:22 -0700 | [diff] [blame] | 357 | * Flag for {@link #bindService}: This flag is intended to be used only by the system to adjust |
| 358 | * the scheduling policy for IMEs (and any other out-of-process user-visible components that |
| 359 | * work closely with the top app) so that UI hosted in such services can have the same |
| 360 | * scheduling policy (e.g. SCHED_FIFO when it is enabled and TOP_APP_PRIORITY_BOOST otherwise) |
| 361 | * as the actual top-app. |
| 362 | * @hide |
| 363 | */ |
| 364 | public static final int BIND_SCHEDULE_LIKE_TOP_APP = 0x00080000; |
| 365 | |
| 366 | /** |
Michal Karpinski | e069b00 | 2019-03-07 16:15:14 +0000 | [diff] [blame] | 367 | * Flag for {@link #bindService}: allow background activity starts from the bound service's |
| 368 | * process. |
| 369 | * This flag is only respected if the caller is holding |
| 370 | * {@link android.Manifest.permission#START_ACTIVITIES_FROM_BACKGROUND}. |
| 371 | * @hide |
| 372 | */ |
| 373 | public static final int BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS = 0x00100000; |
| 374 | |
| 375 | /** |
Dianne Hackborn | c390aa8 | 2019-01-09 16:38:22 -0800 | [diff] [blame] | 376 | * @hide Flag for {@link #bindService}: the service being bound to represents a |
| 377 | * protected system component, so must have association restrictions applied to it. |
| 378 | * That is, a system config must have one or more allow-association tags limiting |
| 379 | * which packages it can interact with. If it does not have any such association |
| 380 | * restrictions, a default empty set will be created. |
| 381 | */ |
| 382 | public static final int BIND_RESTRICT_ASSOCIATIONS = 0x00200000; |
| 383 | |
| 384 | /** |
Svet Ganov | d223db3 | 2017-12-22 09:43:48 -0800 | [diff] [blame] | 385 | * @hide Flag for {@link #bindService}: allows binding to a service provided |
| 386 | * by an instant app. Note that the caller may not have access to the instant |
| 387 | * app providing the service which is a violation of the instant app sandbox. |
| 388 | * This flag is intended ONLY for development/testing and should be used with |
| 389 | * great care. Only the system is allowed to use this flag. |
| 390 | */ |
| 391 | public static final int BIND_ALLOW_INSTANT = 0x00400000; |
| 392 | |
| 393 | /** |
Dianne Hackborn | 83b40f6 | 2017-04-26 13:59:47 -0700 | [diff] [blame] | 394 | * @hide Flag for {@link #bindService}: like {@link #BIND_NOT_FOREGROUND}, but puts it |
| 395 | * up in to the important background state (instead of transient). |
| 396 | */ |
| 397 | public static final int BIND_IMPORTANT_BACKGROUND = 0x00800000; |
| 398 | |
| 399 | /** |
Felipe Leme | a1b79bf | 2016-05-24 13:06:54 -0700 | [diff] [blame] | 400 | * @hide Flag for {@link #bindService}: allows application hosting service to manage whitelists |
| 401 | * such as temporary allowing a {@code PendingIntent} to bypass Power Save mode. |
| 402 | */ |
| 403 | public static final int BIND_ALLOW_WHITELIST_MANAGEMENT = 0x01000000; |
| 404 | |
| 405 | /** |
Dianne Hackborn | d69e4c1 | 2015-04-24 09:54:54 -0700 | [diff] [blame] | 406 | * @hide Flag for {@link #bindService}: Like {@link #BIND_FOREGROUND_SERVICE}, |
| 407 | * but only applies while the device is awake. |
| 408 | */ |
| 409 | public static final int BIND_FOREGROUND_SERVICE_WHILE_AWAKE = 0x02000000; |
| 410 | |
| 411 | /** |
| 412 | * @hide Flag for {@link #bindService}: For only the case where the binding |
| 413 | * is coming from the system, set the process state to FOREGROUND_SERVICE |
| 414 | * instead of the normal maximum of IMPORTANT_FOREGROUND. That is, this is |
| 415 | * saying that the process shouldn't participate in the normal power reduction |
| 416 | * modes (removing network access etc). |
| 417 | */ |
| 418 | public static final int BIND_FOREGROUND_SERVICE = 0x04000000; |
| 419 | |
| 420 | /** |
Dianne Hackborn | f0f94d1 | 2014-03-17 16:04:21 -0700 | [diff] [blame] | 421 | * @hide Flag for {@link #bindService}: Treat the binding as hosting |
| 422 | * an activity, an unbinding as the activity going in the background. |
| 423 | * That is, when unbinding, the process when empty will go on the activity |
| 424 | * LRU list instead of the regular one, keeping it around more aggressively |
| 425 | * than it otherwise would be. This is intended for use with IMEs to try |
| 426 | * to keep IME processes around for faster keyboard switching. |
| 427 | */ |
| 428 | public static final int BIND_TREAT_LIKE_ACTIVITY = 0x08000000; |
| 429 | |
| 430 | /** |
Dianne Hackborn | b12e135 | 2012-09-26 11:39:20 -0700 | [diff] [blame] | 431 | * @hide An idea that is not yet implemented. |
| 432 | * Flag for {@link #bindService}: If binding from an activity, consider |
| 433 | * this service to be visible like the binding activity is. That is, |
| 434 | * it will be treated as something more important to keep around than |
| 435 | * invisible background activities. This will impact the number of |
| 436 | * recent activities the user can switch between without having them |
| 437 | * restart. There is no guarantee this will be respected, as the system |
Amith Yamasani | f235d0b | 2019-03-20 22:49:43 -0700 | [diff] [blame] | 438 | * tries to balance such requests from one app vs. the importance of |
Dianne Hackborn | b12e135 | 2012-09-26 11:39:20 -0700 | [diff] [blame] | 439 | * keeping other apps around. |
| 440 | */ |
Dianne Hackborn | c823051 | 2013-07-13 21:32:12 -0700 | [diff] [blame] | 441 | public static final int BIND_VISIBLE = 0x10000000; |
| 442 | |
| 443 | /** |
| 444 | * @hide |
| 445 | * Flag for {@link #bindService}: Consider this binding to be causing the target |
| 446 | * process to be showing UI, so it will be do a UI_HIDDEN memory trim when it goes |
| 447 | * away. |
| 448 | */ |
| 449 | public static final int BIND_SHOWING_UI = 0x20000000; |
Dianne Hackborn | b12e135 | 2012-09-26 11:39:20 -0700 | [diff] [blame] | 450 | |
| 451 | /** |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 452 | * Flag for {@link #bindService}: Don't consider the bound service to be |
| 453 | * visible, even if the caller is visible. |
| 454 | * @hide |
| 455 | */ |
| 456 | public static final int BIND_NOT_VISIBLE = 0x40000000; |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 457 | |
Alan Viverette | 713a5cd | 2015-12-16 15:46:32 -0500 | [diff] [blame] | 458 | /** |
Robert Sesek | b9a8666 | 2015-12-09 16:22:45 -0500 | [diff] [blame] | 459 | * Flag for {@link #bindService}: The service being bound is an |
| 460 | * {@link android.R.attr#isolatedProcess isolated}, |
| 461 | * {@link android.R.attr#externalService external} service. This binds the service into the |
| 462 | * 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] | 463 | * <p> |
| 464 | * When using this flag, the code for the service being bound will execute under the calling |
| 465 | * application's package name and user ID. Because the service must be an isolated process, |
| 466 | * it will not have direct access to the application's data, though. |
| 467 | * |
| 468 | * The purpose of this flag is to allow applications to provide services that are attributed |
| 469 | * to the app using the service, rather than the application providing the service. |
| 470 | * </p> |
Robert Sesek | b9a8666 | 2015-12-09 16:22:45 -0500 | [diff] [blame] | 471 | */ |
| 472 | public static final int BIND_EXTERNAL_SERVICE = 0x80000000; |
| 473 | |
Dianne Hackborn | a631d56 | 2018-11-20 15:58:15 -0800 | [diff] [blame] | 474 | /** |
| 475 | * These bind flags reduce the strength of the binding such that we shouldn't |
| 476 | * consider it as pulling the process up to the level of the one that is bound to it. |
| 477 | * @hide |
| 478 | */ |
| 479 | public static final int BIND_REDUCTION_FLAGS = |
| 480 | Context.BIND_ALLOW_OOM_MANAGEMENT | Context.BIND_WAIVE_PRIORITY |
Amith Yamasani | 5016a78 | 2019-06-17 16:20:24 -0700 | [diff] [blame] | 481 | | Context.BIND_NOT_PERCEPTIBLE | Context.BIND_NOT_VISIBLE; |
Dianne Hackborn | a631d56 | 2018-11-20 15:58:15 -0800 | [diff] [blame] | 482 | |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 483 | /** @hide */ |
Jeff Sharkey | ce8db99 | 2017-12-13 20:05:05 -0700 | [diff] [blame] | 484 | @IntDef(flag = true, prefix = { "RECEIVER_VISIBLE_" }, value = { |
| 485 | RECEIVER_VISIBLE_TO_INSTANT_APPS |
| 486 | }) |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 487 | @Retention(RetentionPolicy.SOURCE) |
| 488 | public @interface RegisterReceiverFlags {} |
| 489 | |
| 490 | /** |
| 491 | * Flag for {@link #registerReceiver}: The receiver can receive broadcasts from Instant Apps. |
| 492 | */ |
| 493 | public static final int RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x1; |
| 494 | |
Robert Sesek | b9a8666 | 2015-12-09 16:22:45 -0500 | [diff] [blame] | 495 | /** |
Alan Viverette | 713a5cd | 2015-12-16 15:46:32 -0500 | [diff] [blame] | 496 | * Returns an AssetManager instance for the application's package. |
| 497 | * <p> |
| 498 | * <strong>Note:</strong> Implementations of this method should return |
| 499 | * an AssetManager instance that is consistent with the Resources instance |
| 500 | * returned by {@link #getResources()}. For example, they should share the |
| 501 | * same {@link Configuration} object. |
| 502 | * |
| 503 | * @return an AssetManager instance for the application's package |
| 504 | * @see #getResources() |
| 505 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 506 | public abstract AssetManager getAssets(); |
| 507 | |
Alan Viverette | 713a5cd | 2015-12-16 15:46:32 -0500 | [diff] [blame] | 508 | /** |
| 509 | * Returns a Resources instance for the application's package. |
| 510 | * <p> |
| 511 | * <strong>Note:</strong> Implementations of this method should return |
| 512 | * a Resources instance that is consistent with the AssetManager instance |
| 513 | * returned by {@link #getAssets()}. For example, they should share the |
| 514 | * same {@link Configuration} object. |
| 515 | * |
| 516 | * @return a Resources instance for the application's package |
| 517 | * @see #getAssets() |
| 518 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 519 | public abstract Resources getResources(); |
| 520 | |
| 521 | /** Return PackageManager instance to find global package information. */ |
| 522 | public abstract PackageManager getPackageManager(); |
| 523 | |
| 524 | /** Return a ContentResolver instance for your application's package. */ |
| 525 | public abstract ContentResolver getContentResolver(); |
| 526 | |
| 527 | /** |
| 528 | * Return the Looper for the main thread of the current process. This is |
| 529 | * the thread used to dispatch calls to application components (activities, |
| 530 | * services, etc). |
Jeff Brown | f9e989d | 2013-04-04 23:04:03 -0700 | [diff] [blame] | 531 | * <p> |
| 532 | * By definition, this method returns the same result as would be obtained |
| 533 | * by calling {@link Looper#getMainLooper() Looper.getMainLooper()}. |
| 534 | * </p> |
| 535 | * |
| 536 | * @return The main looper. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 537 | */ |
| 538 | public abstract Looper getMainLooper(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 539 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 540 | /** |
Jeff Sharkey | 8439ac0 | 2017-12-12 17:26:23 -0700 | [diff] [blame] | 541 | * Return an {@link Executor} that will run enqueued tasks on the main |
| 542 | * thread associated with this context. This is the thread used to dispatch |
| 543 | * calls to application components (activities, services, etc). |
| 544 | */ |
| 545 | public Executor getMainExecutor() { |
| 546 | // This is pretty inefficient, which is why ContextImpl overrides it |
| 547 | return new HandlerExecutor(new Handler(getMainLooper())); |
| 548 | } |
| 549 | |
| 550 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 551 | * Return the context of the single, global Application object of the |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 552 | * current process. This generally should only be used if you need a |
| 553 | * Context whose lifecycle is separate from the current context, that is |
| 554 | * tied to the lifetime of the process rather than the current component. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 555 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 556 | * <p>Consider for example how this interacts with |
Brad Fitzpatrick | 36af794 | 2010-12-08 11:31:07 -0800 | [diff] [blame] | 557 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter)}: |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 558 | * <ul> |
| 559 | * <li> <p>If used from an Activity context, the receiver is being registered |
| 560 | * within that activity. This means that you are expected to unregister |
| 561 | * before the activity is done being destroyed; in fact if you do not do |
| 562 | * so, the framework will clean up your leaked registration as it removes |
| 563 | * the activity and log an error. Thus, if you use the Activity context |
| 564 | * to register a receiver that is static (global to the process, not |
| 565 | * associated with an Activity instance) then that registration will be |
| 566 | * removed on you at whatever point the activity you used is destroyed. |
| 567 | * <li> <p>If used from the Context returned here, the receiver is being |
| 568 | * registered with the global state associated with your application. Thus |
| 569 | * it will never be unregistered for you. This is necessary if the receiver |
| 570 | * is associated with static data, not a particular component. However |
| 571 | * using the ApplicationContext elsewhere can easily lead to serious leaks |
| 572 | * if you forget to unregister, unbind, etc. |
| 573 | * </ul> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 574 | */ |
| 575 | public abstract Context getApplicationContext(); |
| 576 | |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 577 | /** Non-activity related autofill ids are unique in the app */ |
| 578 | private static int sLastAutofillId = View.NO_ID; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 579 | |
| 580 | /** |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 581 | * Gets the next autofill ID. |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 582 | * |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 583 | * <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] | 584 | * returned will be unique. |
| 585 | * |
| 586 | * @return A ID that is unique in the process |
| 587 | * |
| 588 | * {@hide} |
| 589 | */ |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 590 | public int getNextAutofillId() { |
| 591 | if (sLastAutofillId == View.LAST_APP_AUTOFILL_ID - 1) { |
| 592 | sLastAutofillId = View.NO_ID; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 593 | } |
| 594 | |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 595 | sLastAutofillId++; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 596 | |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 597 | return sLastAutofillId; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 598 | } |
| 599 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 600 | /** |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 601 | * Add a new {@link ComponentCallbacks} to the base application of the |
| 602 | * Context, which will be called at the same times as the ComponentCallbacks |
| 603 | * methods of activities and other components are called. Note that you |
| 604 | * <em>must</em> be sure to use {@link #unregisterComponentCallbacks} when |
| 605 | * appropriate in the future; this will not be removed for you. |
Dianne Hackborn | 905577f | 2011-09-07 18:31:28 -0700 | [diff] [blame] | 606 | * |
| 607 | * @param callback The interface to call. This can be either a |
| 608 | * {@link ComponentCallbacks} or {@link ComponentCallbacks2} interface. |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 609 | */ |
| 610 | public void registerComponentCallbacks(ComponentCallbacks callback) { |
| 611 | getApplicationContext().registerComponentCallbacks(callback); |
| 612 | } |
| 613 | |
| 614 | /** |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 615 | * Remove a {@link ComponentCallbacks} object that was previously registered |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 616 | * with {@link #registerComponentCallbacks(ComponentCallbacks)}. |
| 617 | */ |
| 618 | public void unregisterComponentCallbacks(ComponentCallbacks callback) { |
| 619 | getApplicationContext().unregisterComponentCallbacks(callback); |
| 620 | } |
| 621 | |
| 622 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 623 | * Return a localized, styled CharSequence from the application's package's |
| 624 | * default string table. |
| 625 | * |
| 626 | * @param resId Resource id for the CharSequence text |
| 627 | */ |
Chris Craik | ceb2693 | 2018-02-01 15:51:34 -0800 | [diff] [blame] | 628 | @NonNull |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 629 | public final CharSequence getText(@StringRes int resId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 630 | return getResources().getText(resId); |
| 631 | } |
| 632 | |
| 633 | /** |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 634 | * 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] | 635 | * default string table. |
| 636 | * |
| 637 | * @param resId Resource id for the string |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 638 | * @return The string data associated with the resource, stripped of styled |
| 639 | * text information. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 640 | */ |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 641 | @NonNull |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 642 | public final String getString(@StringRes int resId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 643 | return getResources().getString(resId); |
| 644 | } |
| 645 | |
| 646 | /** |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 647 | * 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] | 648 | * default string table, substituting the format arguments as defined in |
| 649 | * {@link java.util.Formatter} and {@link java.lang.String#format}. |
| 650 | * |
| 651 | * @param resId Resource id for the format string |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 652 | * @param formatArgs The format arguments that will be used for |
| 653 | * substitution. |
| 654 | * @return The string data associated with the resource, formatted and |
| 655 | * stripped of styled text information. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 656 | */ |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 657 | @NonNull |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 658 | public final String getString(@StringRes int resId, Object... formatArgs) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 659 | return getResources().getString(resId, formatArgs); |
| 660 | } |
| 661 | |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 662 | /** |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 663 | * Returns a color associated with a particular resource ID and styled for |
| 664 | * the current theme. |
| 665 | * |
| 666 | * @param id The desired resource identifier, as generated by the aapt |
| 667 | * tool. This integer encodes the package, type, and resource |
| 668 | * entry. The value 0 is an invalid identifier. |
| 669 | * @return A single color value in the form 0xAARRGGBB. |
| 670 | * @throws android.content.res.Resources.NotFoundException if the given ID |
| 671 | * does not exist. |
| 672 | */ |
Tor Norbye | 3e4cda7 | 2015-06-10 08:14:31 -0700 | [diff] [blame] | 673 | @ColorInt |
| 674 | public final int getColor(@ColorRes int id) { |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 675 | return getResources().getColor(id, getTheme()); |
| 676 | } |
| 677 | |
| 678 | /** |
| 679 | * Returns a drawable object associated with a particular resource ID and |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 680 | * styled for the current theme. |
| 681 | * |
| 682 | * @param id The desired resource identifier, as generated by the aapt |
| 683 | * tool. This integer encodes the package, type, and resource |
| 684 | * entry. The value 0 is an invalid identifier. |
Chris Craik | ceb2693 | 2018-02-01 15:51:34 -0800 | [diff] [blame] | 685 | * @return An object that can be used to draw this resource. |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 686 | * @throws android.content.res.Resources.NotFoundException if the given ID |
| 687 | * does not exist. |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 688 | */ |
Chris Craik | 1194b0b | 2018-03-23 13:36:24 -0700 | [diff] [blame] | 689 | @Nullable |
Tor Norbye | 3e4cda7 | 2015-06-10 08:14:31 -0700 | [diff] [blame] | 690 | public final Drawable getDrawable(@DrawableRes int id) { |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 691 | return getResources().getDrawable(id, getTheme()); |
| 692 | } |
| 693 | |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 694 | /** |
| 695 | * Returns a color state list associated with a particular resource ID and |
| 696 | * styled for the current theme. |
| 697 | * |
| 698 | * @param id The desired resource identifier, as generated by the aapt |
| 699 | * tool. This integer encodes the package, type, and resource |
| 700 | * entry. The value 0 is an invalid identifier. |
Chris Craik | ceb2693 | 2018-02-01 15:51:34 -0800 | [diff] [blame] | 701 | * @return A color state list. |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 702 | * @throws android.content.res.Resources.NotFoundException if the given ID |
| 703 | * does not exist. |
| 704 | */ |
Chris Craik | ceb2693 | 2018-02-01 15:51:34 -0800 | [diff] [blame] | 705 | @NonNull |
Tor Norbye | 3e4cda7 | 2015-06-10 08:14:31 -0700 | [diff] [blame] | 706 | public final ColorStateList getColorStateList(@ColorRes int id) { |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 707 | return getResources().getColorStateList(id, getTheme()); |
| 708 | } |
| 709 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 710 | /** |
| 711 | * Set the base theme for this context. Note that this should be called |
| 712 | * before any views are instantiated in the Context (for example before |
| 713 | * calling {@link android.app.Activity#setContentView} or |
| 714 | * {@link android.view.LayoutInflater#inflate}). |
| 715 | * |
| 716 | * @param resid The style resource describing the theme. |
| 717 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 718 | public abstract void setTheme(@StyleRes int resid); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 719 | |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 720 | /** @hide Needed for some internal implementation... not public because |
| 721 | * you can't assume this actually means anything. */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 722 | @UnsupportedAppUsage |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 723 | public int getThemeResId() { |
| 724 | return 0; |
| 725 | } |
| 726 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 727 | /** |
| 728 | * Return the Theme object associated with this Context. |
| 729 | */ |
Jon Miranda | 836c0a8 | 2014-08-11 12:32:26 -0700 | [diff] [blame] | 730 | @ViewDebug.ExportedProperty(deepExport = true) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 731 | public abstract Resources.Theme getTheme(); |
| 732 | |
| 733 | /** |
| 734 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 735 | * {@link android.content.res.Resources.Theme#obtainStyledAttributes(int[])} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 736 | * for more information. |
| 737 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 738 | * @see android.content.res.Resources.Theme#obtainStyledAttributes(int[]) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 739 | */ |
Aurimas Liutikas | 77acf4b | 2018-12-19 17:31:03 -0800 | [diff] [blame] | 740 | @NonNull |
| 741 | public final TypedArray obtainStyledAttributes(@NonNull @StyleableRes int[] attrs) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 742 | return getTheme().obtainStyledAttributes(attrs); |
| 743 | } |
| 744 | |
| 745 | /** |
| 746 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 747 | * {@link android.content.res.Resources.Theme#obtainStyledAttributes(int, int[])} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 748 | * for more information. |
| 749 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 750 | * @see android.content.res.Resources.Theme#obtainStyledAttributes(int, int[]) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 751 | */ |
Aurimas Liutikas | 77acf4b | 2018-12-19 17:31:03 -0800 | [diff] [blame] | 752 | @NonNull |
| 753 | public final TypedArray obtainStyledAttributes(@StyleRes int resid, |
| 754 | @NonNull @StyleableRes int[] attrs) throws Resources.NotFoundException { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 755 | return getTheme().obtainStyledAttributes(resid, attrs); |
| 756 | } |
| 757 | |
| 758 | /** |
| 759 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 760 | * {@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] | 761 | * for more information. |
| 762 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 763 | * @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] | 764 | */ |
Aurimas Liutikas | 77acf4b | 2018-12-19 17:31:03 -0800 | [diff] [blame] | 765 | @NonNull |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 766 | public final TypedArray obtainStyledAttributes( |
Aurimas Liutikas | 77acf4b | 2018-12-19 17:31:03 -0800 | [diff] [blame] | 767 | @Nullable AttributeSet set, @NonNull @StyleableRes int[] attrs) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 768 | return getTheme().obtainStyledAttributes(set, attrs, 0, 0); |
| 769 | } |
| 770 | |
| 771 | /** |
| 772 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 773 | * {@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] | 774 | * for more information. |
| 775 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 776 | * @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] | 777 | */ |
Aurimas Liutikas | 77acf4b | 2018-12-19 17:31:03 -0800 | [diff] [blame] | 778 | @NonNull |
| 779 | public final TypedArray obtainStyledAttributes(@Nullable AttributeSet set, |
| 780 | @NonNull @StyleableRes int[] attrs, @AttrRes int defStyleAttr, |
Tor Norbye | c91531a | 2015-04-01 17:41:55 -0700 | [diff] [blame] | 781 | @StyleRes int defStyleRes) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 782 | return getTheme().obtainStyledAttributes( |
| 783 | set, attrs, defStyleAttr, defStyleRes); |
| 784 | } |
| 785 | |
| 786 | /** |
| 787 | * Return a class loader you can use to retrieve classes in this package. |
| 788 | */ |
| 789 | public abstract ClassLoader getClassLoader(); |
| 790 | |
| 791 | /** Return the name of this application's package. */ |
| 792 | public abstract String getPackageName(); |
| 793 | |
Jaewan Kim | 0980c7f | 2018-11-28 23:55:15 +0900 | [diff] [blame] | 794 | /** |
| 795 | * @hide Return the name of the base context this context is derived from. |
| 796 | * This is the same as {@link #getOpPackageName()} except in |
| 797 | * cases where system components are loaded into other app processes, in which |
| 798 | * case {@link #getOpPackageName()} will be the name of the primary package in |
| 799 | * that process (so that app ops uid verification will work with the name). |
| 800 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 801 | @UnsupportedAppUsage |
Dianne Hackborn | d8e1dbb | 2013-01-17 17:47:37 -0800 | [diff] [blame] | 802 | public abstract String getBasePackageName(); |
| 803 | |
Jaewan Kim | 0980c7f | 2018-11-28 23:55:15 +0900 | [diff] [blame] | 804 | /** |
| 805 | * Return the package name that should be used for {@link android.app.AppOpsManager} calls from |
| 806 | * this context, so that app ops manager's uid verification will work with the name. |
| 807 | * <p> |
| 808 | * This is not generally intended for third party application developers. |
| 809 | */ |
Adrian Roos | ebc927c | 2019-02-28 16:21:18 +0100 | [diff] [blame] | 810 | @NonNull |
Adrian Roos | fe6aeaf | 2019-01-22 16:58:56 +0100 | [diff] [blame] | 811 | public String getOpPackageName() { |
| 812 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 813 | } |
Dianne Hackborn | 95d7853 | 2013-09-11 09:51:14 -0700 | [diff] [blame] | 814 | |
Philip P. Moltmann | 59076d8 | 2019-08-19 15:00:40 -0700 | [diff] [blame] | 815 | /** |
| 816 | * <p>Features are used in complex apps to logically separate parts of the app. E.g. a |
| 817 | * blogging app might also have a instant messaging app built in. |
| 818 | * |
| 819 | * @return the feature id this context is for or {@code null} if this is the default |
| 820 | * feature. |
| 821 | */ |
| 822 | public @Nullable String getFeatureId() { |
| 823 | return null; |
| 824 | } |
| 825 | |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 826 | /** Return the full application info for this context's package. */ |
| 827 | public abstract ApplicationInfo getApplicationInfo(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 828 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 829 | /** |
Kenny Root | 3214839 | 2010-01-21 15:40:47 -0800 | [diff] [blame] | 830 | * Return the full path to this context's primary Android package. |
| 831 | * The Android package is a ZIP file which contains the application's |
| 832 | * primary resources. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 833 | * |
| 834 | * <p>Note: this is not generally useful for applications, since they should |
| 835 | * not be directly accessing the file system. |
| 836 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 837 | * @return String Path to the resources. |
| 838 | */ |
| 839 | public abstract String getPackageResourcePath(); |
| 840 | |
| 841 | /** |
Kenny Root | 3214839 | 2010-01-21 15:40:47 -0800 | [diff] [blame] | 842 | * Return the full path to this context's primary Android package. |
| 843 | * The Android package is a ZIP file which contains application's |
| 844 | * primary code and assets. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 845 | * |
| 846 | * <p>Note: this is not generally useful for applications, since they should |
| 847 | * not be directly accessing the file system. |
| 848 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 849 | * @return String Path to the code and assets. |
| 850 | */ |
| 851 | public abstract String getPackageCodePath(); |
| 852 | |
| 853 | /** |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 854 | * @hide |
| 855 | * @deprecated use {@link #getSharedPreferencesPath(String)} |
Joe Onorato | 23ecae3 | 2009-06-10 17:07:15 -0700 | [diff] [blame] | 856 | */ |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 857 | @Deprecated |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 858 | @UnsupportedAppUsage |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 859 | public File getSharedPrefsFile(String name) { |
| 860 | return getSharedPreferencesPath(name); |
| 861 | } |
Joe Onorato | 23ecae3 | 2009-06-10 17:07:15 -0700 | [diff] [blame] | 862 | |
| 863 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 864 | * Retrieve and hold the contents of the preferences file 'name', returning |
| 865 | * a SharedPreferences through which you can retrieve and modify its |
| 866 | * values. Only one instance of the SharedPreferences object is returned |
| 867 | * to any callers for the same name, meaning they will see each other's |
| 868 | * edits as soon as they are made. |
| 869 | * |
Nate Fischer | 5272c37 | 2019-08-27 16:37:00 -0700 | [diff] [blame] | 870 | * <p>This method is thread-safe. |
Jonathan Dormody | 1bca5db | 2017-11-16 11:25:20 -0700 | [diff] [blame] | 871 | * |
Nate Fischer | 5272c37 | 2019-08-27 16:37:00 -0700 | [diff] [blame] | 872 | * <p>If the preferences directory does not already exist, it will be created when this method |
| 873 | * is called. |
| 874 | * |
| 875 | * <p>If a preferences file by this name does not exist, it will be created when you retrieve an |
| 876 | * editor ({@link SharedPreferences#edit()}) and then commit changes ({@link |
| 877 | * SharedPreferences.Editor#commit()} or {@link SharedPreferences.Editor#apply()}). |
| 878 | * |
| 879 | * @param name Desired preferences file. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 880 | * @param mode Operating mode. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 881 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 882 | * @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] | 883 | * to retrieve and modify the preference values. |
| 884 | * |
| 885 | * @see #MODE_PRIVATE |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 886 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 887 | public abstract SharedPreferences getSharedPreferences(String name, @PreferencesMode int mode); |
Jeff Sharkey | 8fc29cf | 2015-11-30 17:51:00 -0700 | [diff] [blame] | 888 | |
| 889 | /** |
| 890 | * Retrieve and hold the contents of the preferences file, returning |
| 891 | * a SharedPreferences through which you can retrieve and modify its |
| 892 | * values. Only one instance of the SharedPreferences object is returned |
| 893 | * to any callers for the same name, meaning they will see each other's |
| 894 | * edits as soon as they are made. |
| 895 | * |
| 896 | * @param file Desired preferences file. If a preferences file by this name |
| 897 | * does not exist, it will be created when you retrieve an |
| 898 | * editor (SharedPreferences.edit()) and then commit changes (Editor.commit()). |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 899 | * @param mode Operating mode. |
Jeff Sharkey | 8fc29cf | 2015-11-30 17:51:00 -0700 | [diff] [blame] | 900 | * |
| 901 | * @return The single {@link SharedPreferences} instance that can be used |
| 902 | * to retrieve and modify the preference values. |
| 903 | * |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 904 | * @see #getSharedPreferencesPath(String) |
Jeff Sharkey | 8fc29cf | 2015-11-30 17:51:00 -0700 | [diff] [blame] | 905 | * @see #MODE_PRIVATE |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 906 | * @removed |
Jeff Sharkey | 8fc29cf | 2015-11-30 17:51:00 -0700 | [diff] [blame] | 907 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 908 | public abstract SharedPreferences getSharedPreferences(File file, @PreferencesMode int mode); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 909 | |
| 910 | /** |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 911 | * Move an existing shared preferences file from the given source storage |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 912 | * context to this context. This is typically used to migrate data between |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 913 | * storage locations after an upgrade, such as moving to device protected |
| 914 | * storage. |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 915 | * |
| 916 | * @param sourceContext The source context which contains the existing |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 917 | * shared preferences to move. |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 918 | * @param name The name of the shared preferences file. |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 919 | * @return {@code true} if the move was successful or if the shared |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 920 | * preferences didn't exist in the source context, otherwise |
| 921 | * {@code false}. |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 922 | * @see #createDeviceProtectedStorageContext() |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 923 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 924 | public abstract boolean moveSharedPreferencesFrom(Context sourceContext, String name); |
| 925 | |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 926 | /** |
| 927 | * Delete an existing shared preferences file. |
| 928 | * |
| 929 | * @param name The name (unique in the application package) of the shared |
| 930 | * preferences file. |
| 931 | * @return {@code true} if the shared preferences file was successfully |
| 932 | * deleted; else {@code false}. |
| 933 | * @see #getSharedPreferences(String, int) |
| 934 | */ |
| 935 | public abstract boolean deleteSharedPreferences(String name); |
| 936 | |
Christopher Tate | fe2368c | 2017-05-17 15:42:35 -0700 | [diff] [blame] | 937 | /** @hide */ |
| 938 | public abstract void reloadSharedPreferences(); |
| 939 | |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 940 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 941 | * Open a private file associated with this Context's application package |
| 942 | * for reading. |
| 943 | * |
| 944 | * @param name The name of the file to open; can not contain path |
| 945 | * separators. |
| 946 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 947 | * @return The resulting {@link FileInputStream}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 948 | * |
| 949 | * @see #openFileOutput |
| 950 | * @see #fileList |
| 951 | * @see #deleteFile |
| 952 | * @see java.io.FileInputStream#FileInputStream(String) |
| 953 | */ |
| 954 | public abstract FileInputStream openFileInput(String name) |
| 955 | throws FileNotFoundException; |
| 956 | |
| 957 | /** |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 958 | * Open a private file associated with this Context's application package |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 959 | * for writing. Creates the file if it doesn't already exist. |
| 960 | * <p> |
| 961 | * No additional permissions are required for the calling app to read or |
| 962 | * write the returned file. |
Ricardo Cervera | 90a5f98 | 2014-04-04 10:26:05 -0700 | [diff] [blame] | 963 | * |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 964 | * @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] | 965 | * separators. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 966 | * @param mode Operating mode. |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 967 | * @return The resulting {@link FileOutputStream}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 968 | * @see #MODE_APPEND |
| 969 | * @see #MODE_PRIVATE |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 970 | * @see #openFileInput |
| 971 | * @see #fileList |
| 972 | * @see #deleteFile |
| 973 | * @see java.io.FileOutputStream#FileOutputStream(String) |
| 974 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 975 | public abstract FileOutputStream openFileOutput(String name, @FileMode int mode) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 976 | throws FileNotFoundException; |
| 977 | |
| 978 | /** |
| 979 | * Delete the given private file associated with this Context's |
| 980 | * application package. |
| 981 | * |
| 982 | * @param name The name of the file to delete; can not contain path |
| 983 | * separators. |
| 984 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 985 | * @return {@code true} if the file was successfully deleted; else |
| 986 | * {@code false}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 987 | * |
| 988 | * @see #openFileInput |
| 989 | * @see #openFileOutput |
| 990 | * @see #fileList |
| 991 | * @see java.io.File#delete() |
| 992 | */ |
| 993 | public abstract boolean deleteFile(String name); |
| 994 | |
| 995 | /** |
| 996 | * Returns the absolute path on the filesystem where a file created with |
| 997 | * {@link #openFileOutput} is stored. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 998 | * <p> |
| 999 | * The returned path may change over time if the calling app is moved to an |
| 1000 | * 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] | 1001 | * |
| 1002 | * @param name The name of the file for which you would like to get |
| 1003 | * its path. |
| 1004 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1005 | * @return An absolute path to the given file. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1006 | * |
| 1007 | * @see #openFileOutput |
| 1008 | * @see #getFilesDir |
| 1009 | * @see #getDir |
| 1010 | */ |
| 1011 | public abstract File getFileStreamPath(String name); |
| 1012 | |
| 1013 | /** |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 1014 | * Returns the absolute path on the filesystem where a file created with |
| 1015 | * {@link #getSharedPreferences(String, int)} is stored. |
| 1016 | * <p> |
| 1017 | * The returned path may change over time if the calling app is moved to an |
| 1018 | * adopted storage device, so only relative paths should be persisted. |
| 1019 | * |
| 1020 | * @param name The name of the shared preferences for which you would like |
| 1021 | * to get a path. |
| 1022 | * @return An absolute path to the given file. |
| 1023 | * @see #getSharedPreferences(String, int) |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 1024 | * @removed |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 1025 | */ |
| 1026 | public abstract File getSharedPreferencesPath(String name); |
| 1027 | |
| 1028 | /** |
Jeff Sharkey | 2c1ba9a | 2016-02-17 15:29:38 -0700 | [diff] [blame] | 1029 | * Returns the absolute path to the directory on the filesystem where all |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 1030 | * private files belonging to this app are stored. Apps should not use this |
| 1031 | * path directly; they should instead use {@link #getFilesDir()}, |
| 1032 | * {@link #getCacheDir()}, {@link #getDir(String, int)}, or other storage |
| 1033 | * APIs on this class. |
Jeff Sharkey | 2c1ba9a | 2016-02-17 15:29:38 -0700 | [diff] [blame] | 1034 | * <p> |
| 1035 | * The returned path may change over time if the calling app is moved to an |
| 1036 | * adopted storage device, so only relative paths should be persisted. |
| 1037 | * <p> |
| 1038 | * No additional permissions are required for the calling app to read or |
| 1039 | * write files under the returned path. |
| 1040 | * |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 1041 | * @see ApplicationInfo#dataDir |
Jeff Sharkey | 2c1ba9a | 2016-02-17 15:29:38 -0700 | [diff] [blame] | 1042 | */ |
| 1043 | public abstract File getDataDir(); |
| 1044 | |
| 1045 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1046 | * Returns the absolute path to the directory on the filesystem where files |
| 1047 | * created with {@link #openFileOutput} are stored. |
| 1048 | * <p> |
| 1049 | * The returned path may change over time if the calling app is moved to an |
| 1050 | * adopted storage device, so only relative paths should be persisted. |
| 1051 | * <p> |
| 1052 | * No additional permissions are required for the calling app to read or |
| 1053 | * write files under the returned path. |
Ricardo Cervera | 90a5f98 | 2014-04-04 10:26:05 -0700 | [diff] [blame] | 1054 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1055 | * @return The path of the directory holding application files. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1056 | * @see #openFileOutput |
| 1057 | * @see #getFileStreamPath |
| 1058 | * @see #getDir |
| 1059 | */ |
| 1060 | public abstract File getFilesDir(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1061 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1062 | /** |
Christopher Tate | a7835b6 | 2014-07-11 17:25:57 -0700 | [diff] [blame] | 1063 | * Returns the absolute path to the directory on the filesystem similar to |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1064 | * {@link #getFilesDir()}. The difference is that files placed under this |
| 1065 | * directory will be excluded from automatic backup to remote storage. See |
Christopher Tate | a7835b6 | 2014-07-11 17:25:57 -0700 | [diff] [blame] | 1066 | * {@link android.app.backup.BackupAgent BackupAgent} for a full discussion |
| 1067 | * of the automatic backup mechanism in Android. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1068 | * <p> |
| 1069 | * The returned path may change over time if the calling app is moved to an |
| 1070 | * adopted storage device, so only relative paths should be persisted. |
| 1071 | * <p> |
| 1072 | * No additional permissions are required for the calling app to read or |
| 1073 | * write files under the returned path. |
Christopher Tate | a7835b6 | 2014-07-11 17:25:57 -0700 | [diff] [blame] | 1074 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1075 | * @return The path of the directory holding application files that will not |
| 1076 | * be automatically backed up to remote storage. |
Christopher Tate | a7835b6 | 2014-07-11 17:25:57 -0700 | [diff] [blame] | 1077 | * @see #openFileOutput |
| 1078 | * @see #getFileStreamPath |
| 1079 | * @see #getDir |
| 1080 | * @see android.app.backup.BackupAgent |
| 1081 | */ |
| 1082 | public abstract File getNoBackupFilesDir(); |
| 1083 | |
| 1084 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1085 | * Returns the absolute path to the directory on the primary shared/external |
| 1086 | * storage device where the application can place persistent files it owns. |
| 1087 | * These files are internal to the applications, and not typically visible |
| 1088 | * to the user as media. |
| 1089 | * <p> |
| 1090 | * This is like {@link #getFilesDir()} in that these files will be deleted |
| 1091 | * when the application is uninstalled, however there are some important |
| 1092 | * differences: |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1093 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1094 | * <li>Shared storage may not always be available, since removable media can |
| 1095 | * be ejected by the user. Media state can be checked using |
| 1096 | * {@link Environment#getExternalStorageState(File)}. |
| 1097 | * <li>There is no security enforced with these files. For example, any |
| 1098 | * application holding |
| 1099 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1100 | * these files. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1101 | * </ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1102 | * <p> |
| 1103 | * If a shared storage device is emulated (as determined by |
| 1104 | * {@link Environment#isExternalStorageEmulated(File)}), it's contents are |
| 1105 | * backed by a private user data partition, which means there is little |
| 1106 | * benefit to storing data here instead of the private directories returned |
| 1107 | * by {@link #getFilesDir()}, etc. |
| 1108 | * <p> |
| 1109 | * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1110 | * 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] | 1111 | * accessible to the calling app. This only applies to paths generated for |
| 1112 | * package name of the calling application. To access paths belonging to |
| 1113 | * other packages, |
| 1114 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} and/or |
| 1115 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} are required. |
| 1116 | * <p> |
| 1117 | * On devices with multiple users (as described by {@link UserManager}), |
| 1118 | * each user has their own isolated shared storage. Applications only have |
| 1119 | * access to the shared storage for the user they're running as. |
| 1120 | * <p> |
| 1121 | * The returned path may change over time if different shared storage media |
| 1122 | * is inserted, so only relative paths should be persisted. |
| 1123 | * <p> |
| 1124 | * Here is an example of typical code to manipulate a file in an |
| 1125 | * application's shared storage: |
| 1126 | * </p> |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1127 | * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java |
| 1128 | * private_file} |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1129 | * <p> |
| 1130 | * If you supply a non-null <var>type</var> to this function, the returned |
| 1131 | * file will be a path to a sub-directory of the given type. Though these |
| 1132 | * files are not automatically scanned by the media scanner, you can |
| 1133 | * explicitly add them to the media database with |
| 1134 | * {@link android.media.MediaScannerConnection#scanFile(Context, String[], String[], android.media.MediaScannerConnection.OnScanCompletedListener) |
| 1135 | * MediaScannerConnection.scanFile}. Note that this is not the same as |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1136 | * {@link android.os.Environment#getExternalStoragePublicDirectory |
| 1137 | * Environment.getExternalStoragePublicDirectory()}, which provides |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1138 | * directories of media shared by all applications. The directories returned |
| 1139 | * here are owned by the application, and their contents will be removed |
| 1140 | * when the application is uninstalled. Unlike |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1141 | * {@link android.os.Environment#getExternalStoragePublicDirectory |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1142 | * Environment.getExternalStoragePublicDirectory()}, the directory returned |
| 1143 | * here will be automatically created for you. |
| 1144 | * <p> |
| 1145 | * Here is an example of typical code to manipulate a picture in an |
| 1146 | * application's shared storage and add it to the media database: |
| 1147 | * </p> |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1148 | * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java |
| 1149 | * private_picture} |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 1150 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1151 | * @param type The type of files directory to return. May be {@code null} |
| 1152 | * for the root of the files directory or one of the following |
| 1153 | * constants for a subdirectory: |
| 1154 | * {@link android.os.Environment#DIRECTORY_MUSIC}, |
| 1155 | * {@link android.os.Environment#DIRECTORY_PODCASTS}, |
| 1156 | * {@link android.os.Environment#DIRECTORY_RINGTONES}, |
| 1157 | * {@link android.os.Environment#DIRECTORY_ALARMS}, |
| 1158 | * {@link android.os.Environment#DIRECTORY_NOTIFICATIONS}, |
| 1159 | * {@link android.os.Environment#DIRECTORY_PICTURES}, or |
| 1160 | * {@link android.os.Environment#DIRECTORY_MOVIES}. |
| 1161 | * @return the absolute path to application-specific directory. May return |
| 1162 | * {@code null} if shared storage is not currently available. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1163 | * @see #getFilesDir |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1164 | * @see #getExternalFilesDirs(String) |
| 1165 | * @see Environment#getExternalStorageState(File) |
| 1166 | * @see Environment#isExternalStorageEmulated(File) |
| 1167 | * @see Environment#isExternalStorageRemovable(File) |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1168 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1169 | @Nullable |
| 1170 | public abstract File getExternalFilesDir(@Nullable String type); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1171 | |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1172 | /** |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1173 | * Returns absolute paths to application-specific directories on all |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1174 | * shared/external storage devices where the application can place |
| 1175 | * persistent files it owns. These files are internal to the application, |
| 1176 | * and not typically visible to the user as media. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1177 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1178 | * This is like {@link #getFilesDir()} in that these files will be deleted |
| 1179 | * when the application is uninstalled, however there are some important |
| 1180 | * differences: |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1181 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1182 | * <li>Shared storage may not always be available, since removable media can |
| 1183 | * be ejected by the user. Media state can be checked using |
| 1184 | * {@link Environment#getExternalStorageState(File)}. |
| 1185 | * <li>There is no security enforced with these files. For example, any |
| 1186 | * application holding |
| 1187 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 1188 | * these files. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1189 | * </ul> |
| 1190 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1191 | * If a shared storage device is emulated (as determined by |
| 1192 | * {@link Environment#isExternalStorageEmulated(File)}), it's contents are |
| 1193 | * backed by a private user data partition, which means there is little |
| 1194 | * benefit to storing data here instead of the private directories returned |
| 1195 | * by {@link #getFilesDir()}, etc. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1196 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1197 | * Shared storage devices returned here are considered a stable part of the |
| 1198 | * device, including physical media slots under a protective cover. The |
| 1199 | * returned paths do not include transient devices, such as USB flash drives |
| 1200 | * connected to handheld devices. |
| 1201 | * <p> |
| 1202 | * 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] | 1203 | * example, an app may choose to store large files on the device with the |
| 1204 | * most available space, as measured by {@link StatFs}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1205 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1206 | * No additional permissions are required for the calling app to read or |
| 1207 | * write files under the returned path. Write access outside of these paths |
| 1208 | * on secondary external storage devices is not available. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1209 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1210 | * The returned path may change over time if different shared storage media |
| 1211 | * is inserted, so only relative paths should be persisted. |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 1212 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1213 | * @param type The type of files directory to return. May be {@code null} |
| 1214 | * for the root of the files directory or one of the following |
| 1215 | * constants for a subdirectory: |
| 1216 | * {@link android.os.Environment#DIRECTORY_MUSIC}, |
| 1217 | * {@link android.os.Environment#DIRECTORY_PODCASTS}, |
| 1218 | * {@link android.os.Environment#DIRECTORY_RINGTONES}, |
| 1219 | * {@link android.os.Environment#DIRECTORY_ALARMS}, |
| 1220 | * {@link android.os.Environment#DIRECTORY_NOTIFICATIONS}, |
| 1221 | * {@link android.os.Environment#DIRECTORY_PICTURES}, or |
| 1222 | * {@link android.os.Environment#DIRECTORY_MOVIES}. |
| 1223 | * @return the absolute paths to application-specific directories. Some |
| 1224 | * individual paths may be {@code null} if that shared storage is |
| 1225 | * not currently available. The first path returned is the same as |
| 1226 | * {@link #getExternalFilesDir(String)}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1227 | * @see #getExternalFilesDir(String) |
Jeff Sharkey | 4ca728c | 2014-01-10 16:27:19 -0800 | [diff] [blame] | 1228 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1229 | * @see Environment#isExternalStorageEmulated(File) |
| 1230 | * @see Environment#isExternalStorageRemovable(File) |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1231 | */ |
| 1232 | public abstract File[] getExternalFilesDirs(String type); |
| 1233 | |
| 1234 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1235 | * Return the primary shared/external storage directory where this |
| 1236 | * application's OBB files (if there are any) can be found. Note if the |
| 1237 | * application does not have any OBB files, this directory may not exist. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1238 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1239 | * This is like {@link #getFilesDir()} in that these files will be deleted |
| 1240 | * when the application is uninstalled, however there are some important |
| 1241 | * differences: |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1242 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1243 | * <li>Shared storage may not always be available, since removable media can |
| 1244 | * be ejected by the user. Media state can be checked using |
| 1245 | * {@link Environment#getExternalStorageState(File)}. |
| 1246 | * <li>There is no security enforced with these files. For example, any |
| 1247 | * application holding |
| 1248 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1249 | * these files. |
| 1250 | * </ul> |
| 1251 | * <p> |
| 1252 | * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions |
Dave Friedman | cfe5088 | 2017-07-05 00:40:07 -0700 | [diff] [blame] | 1253 | * are required to read or write to the path that this method returns. |
| 1254 | * However, starting from {@link android.os.Build.VERSION_CODES#M}, |
| 1255 | * to read the OBB expansion files, you must declare the |
| 1256 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} permission in the app manifest and ask for |
| 1257 | * permission at runtime as follows: |
| 1258 | * </p> |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1259 | * <p> |
Dave Friedman | cfe5088 | 2017-07-05 00:40:07 -0700 | [diff] [blame] | 1260 | * {@code <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" |
| 1261 | * android:maxSdkVersion="23" />} |
| 1262 | * </p> |
| 1263 | * <p> |
| 1264 | * Starting from {@link android.os.Build.VERSION_CODES#N}, |
| 1265 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} |
| 1266 | * permission is not required, so don’t ask for this |
| 1267 | * permission at runtime. To handle both cases, your app must first try to read the OBB file, |
| 1268 | * and if it fails, you must request |
| 1269 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} permission at runtime. |
| 1270 | * </p> |
| 1271 | * |
| 1272 | * <p> |
| 1273 | * The following code snippet shows how to do this: |
| 1274 | * </p> |
| 1275 | * |
| 1276 | * <pre> |
| 1277 | * File obb = new File(obb_filename); |
| 1278 | * boolean open_failed = false; |
| 1279 | * |
| 1280 | * try { |
| 1281 | * BufferedReader br = new BufferedReader(new FileReader(obb)); |
| 1282 | * open_failed = false; |
| 1283 | * ReadObbFile(br); |
| 1284 | * } catch (IOException e) { |
| 1285 | * open_failed = true; |
| 1286 | * } |
| 1287 | * |
| 1288 | * if (open_failed) { |
| 1289 | * // request READ_EXTERNAL_STORAGE permission before reading OBB file |
| 1290 | * ReadObbFileWithPermission(); |
| 1291 | * } |
| 1292 | * </pre> |
| 1293 | * |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1294 | * On devices with multiple users (as described by {@link UserManager}), |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 1295 | * multiple users may share the same OBB storage location. Applications |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1296 | * should ensure that multiple instances running under different users don't |
| 1297 | * interfere with each other. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1298 | * |
| 1299 | * @return the absolute path to application-specific directory. May return |
| 1300 | * {@code null} if shared storage is not currently available. |
| 1301 | * @see #getObbDirs() |
| 1302 | * @see Environment#getExternalStorageState(File) |
| 1303 | * @see Environment#isExternalStorageEmulated(File) |
| 1304 | * @see Environment#isExternalStorageRemovable(File) |
Dianne Hackborn | 805fd7e | 2011-01-16 18:30:29 -0800 | [diff] [blame] | 1305 | */ |
| 1306 | public abstract File getObbDir(); |
| 1307 | |
| 1308 | /** |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1309 | * Returns absolute paths to application-specific directories on all |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1310 | * shared/external storage devices where the application's OBB files (if |
| 1311 | * there are any) can be found. Note if the application does not have any |
| 1312 | * OBB files, these directories may not exist. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1313 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1314 | * This is like {@link #getFilesDir()} in that these files will be deleted |
| 1315 | * when the application is uninstalled, however there are some important |
| 1316 | * differences: |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1317 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1318 | * <li>Shared storage may not always be available, since removable media can |
| 1319 | * be ejected by the user. Media state can be checked using |
| 1320 | * {@link Environment#getExternalStorageState(File)}. |
| 1321 | * <li>There is no security enforced with these files. For example, any |
| 1322 | * application holding |
| 1323 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 1324 | * these files. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1325 | * </ul> |
| 1326 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1327 | * Shared storage devices returned here are considered a stable part of the |
| 1328 | * device, including physical media slots under a protective cover. The |
| 1329 | * returned paths do not include transient devices, such as USB flash drives |
| 1330 | * connected to handheld devices. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1331 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1332 | * 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] | 1333 | * example, an app may choose to store large files on the device with the |
| 1334 | * most available space, as measured by {@link StatFs}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1335 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1336 | * No additional permissions are required for the calling app to read or |
| 1337 | * write files under the returned path. Write access outside of these paths |
| 1338 | * on secondary external storage devices is not available. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1339 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1340 | * @return the absolute paths to application-specific directories. Some |
| 1341 | * individual paths may be {@code null} if that shared storage is |
| 1342 | * not currently available. The first path returned is the same as |
| 1343 | * {@link #getObbDir()} |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1344 | * @see #getObbDir() |
Jeff Sharkey | 4ca728c | 2014-01-10 16:27:19 -0800 | [diff] [blame] | 1345 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1346 | * @see Environment#isExternalStorageEmulated(File) |
| 1347 | * @see Environment#isExternalStorageRemovable(File) |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1348 | */ |
| 1349 | public abstract File[] getObbDirs(); |
| 1350 | |
| 1351 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1352 | * Returns the absolute path to the application specific cache directory on |
Jeff Sharkey | 60a82cd | 2017-04-18 18:19:16 -0600 | [diff] [blame] | 1353 | * the filesystem. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1354 | * <p> |
Jeff Sharkey | 60a82cd | 2017-04-18 18:19:16 -0600 | [diff] [blame] | 1355 | * The system will automatically delete files in this directory as disk |
| 1356 | * space is needed elsewhere on the device. The system will always delete |
| 1357 | * older files first, as reported by {@link File#lastModified()}. If |
| 1358 | * desired, you can exert more control over how files are deleted using |
| 1359 | * {@link StorageManager#setCacheBehaviorGroup(File, boolean)} and |
| 1360 | * {@link StorageManager#setCacheBehaviorTombstone(File, boolean)}. |
| 1361 | * <p> |
| 1362 | * Apps are strongly encouraged to keep their usage of cache space below the |
| 1363 | * quota returned by |
| 1364 | * {@link StorageManager#getCacheQuotaBytes(java.util.UUID)}. If your app |
| 1365 | * goes above this quota, your cached files will be some of the first to be |
| 1366 | * deleted when additional disk space is needed. Conversely, if your app |
| 1367 | * stays under this quota, your cached files will be some of the last to be |
| 1368 | * deleted when additional disk space is needed. |
| 1369 | * <p> |
| 1370 | * Note that your cache quota will change over time depending on how |
| 1371 | * frequently the user interacts with your app, and depending on how much |
| 1372 | * system-wide disk space is used. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1373 | * <p> |
| 1374 | * The returned path may change over time if the calling app is moved to an |
| 1375 | * adopted storage device, so only relative paths should be persisted. |
| 1376 | * <p> |
| 1377 | * Apps require no extra permissions to read or write to the returned path, |
| 1378 | * since this path lives in their private storage. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1379 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1380 | * @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] | 1381 | * @see #openFileOutput |
| 1382 | * @see #getFileStreamPath |
| 1383 | * @see #getDir |
Kevin Hufnagle | e9681e1 | 2016-09-23 16:44:03 -0700 | [diff] [blame] | 1384 | * @see #getExternalCacheDir |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1385 | */ |
| 1386 | public abstract File getCacheDir(); |
| 1387 | |
| 1388 | /** |
Jeff Sharkey | 4ed745d | 2014-07-15 20:39:15 -0700 | [diff] [blame] | 1389 | * Returns the absolute path to the application specific cache directory on |
Jeff Sharkey | 60a82cd | 2017-04-18 18:19:16 -0600 | [diff] [blame] | 1390 | * the filesystem designed for storing cached code. |
| 1391 | * <p> |
| 1392 | * The system will delete any files stored in this location both when your |
| 1393 | * specific application is upgraded, and when the entire platform is |
| 1394 | * upgraded. |
Jeff Sharkey | 4ed745d | 2014-07-15 20:39:15 -0700 | [diff] [blame] | 1395 | * <p> |
| 1396 | * This location is optimal for storing compiled or optimized code generated |
| 1397 | * by your application at runtime. |
| 1398 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1399 | * The returned path may change over time if the calling app is moved to an |
| 1400 | * adopted storage device, so only relative paths should be persisted. |
| 1401 | * <p> |
Jeff Sharkey | 4ed745d | 2014-07-15 20:39:15 -0700 | [diff] [blame] | 1402 | * Apps require no extra permissions to read or write to the returned path, |
| 1403 | * since this path lives in their private storage. |
| 1404 | * |
| 1405 | * @return The path of the directory holding application code cache files. |
| 1406 | */ |
| 1407 | public abstract File getCodeCacheDir(); |
| 1408 | |
| 1409 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1410 | * Returns absolute path to application-specific directory on the primary |
| 1411 | * shared/external storage device where the application can place cache |
| 1412 | * files it owns. These files are internal to the application, and not |
| 1413 | * typically visible to the user as media. |
| 1414 | * <p> |
| 1415 | * This is like {@link #getCacheDir()} in that these files will be deleted |
| 1416 | * when the application is uninstalled, however there are some important |
| 1417 | * differences: |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1418 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1419 | * <li>The platform does not always monitor the space available in shared |
| 1420 | * storage, and thus may not automatically delete these files. Apps should |
| 1421 | * always manage the maximum space used in this location. Currently the only |
| 1422 | * time files here will be deleted by the platform is when running on |
| 1423 | * {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} or later and |
| 1424 | * {@link Environment#isExternalStorageEmulated(File)} returns true. |
| 1425 | * <li>Shared storage may not always be available, since removable media can |
| 1426 | * be ejected by the user. Media state can be checked using |
| 1427 | * {@link Environment#getExternalStorageState(File)}. |
| 1428 | * <li>There is no security enforced with these files. For example, any |
| 1429 | * application holding |
| 1430 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1431 | * these files. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1432 | * </ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1433 | * <p> |
| 1434 | * If a shared storage device is emulated (as determined by |
Kevin Hufnagle | e9681e1 | 2016-09-23 16:44:03 -0700 | [diff] [blame] | 1435 | * {@link Environment#isExternalStorageEmulated(File)}), its contents are |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1436 | * backed by a private user data partition, which means there is little |
| 1437 | * benefit to storing data here instead of the private directory returned by |
| 1438 | * {@link #getCacheDir()}. |
| 1439 | * <p> |
| 1440 | * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1441 | * 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] | 1442 | * accessible to the calling app. This only applies to paths generated for |
| 1443 | * package name of the calling application. To access paths belonging to |
| 1444 | * other packages, |
| 1445 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} and/or |
| 1446 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} are required. |
| 1447 | * <p> |
| 1448 | * On devices with multiple users (as described by {@link UserManager}), |
| 1449 | * each user has their own isolated shared storage. Applications only have |
| 1450 | * access to the shared storage for the user they're running as. |
| 1451 | * <p> |
| 1452 | * The returned path may change over time if different shared storage media |
| 1453 | * is inserted, so only relative paths should be persisted. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1454 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1455 | * @return the absolute path to application-specific directory. May return |
| 1456 | * {@code null} if shared storage is not currently available. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1457 | * @see #getCacheDir |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1458 | * @see #getExternalCacheDirs() |
| 1459 | * @see Environment#getExternalStorageState(File) |
| 1460 | * @see Environment#isExternalStorageEmulated(File) |
| 1461 | * @see Environment#isExternalStorageRemovable(File) |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1462 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1463 | @Nullable |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1464 | public abstract File getExternalCacheDir(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1465 | |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1466 | /** |
Fyodor Kupolov | 6122129 | 2016-09-02 15:21:03 -0700 | [diff] [blame] | 1467 | * Returns absolute path to application-specific directory in the preloaded cache. |
| 1468 | * <p>Files stored in the cache directory can be deleted when the device runs low on storage. |
| 1469 | * There is no guarantee when these files will be deleted. |
| 1470 | * @hide |
| 1471 | */ |
| 1472 | @Nullable |
| 1473 | @SystemApi |
| 1474 | public abstract File getPreloadsFileCache(); |
| 1475 | |
| 1476 | /** |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1477 | * Returns absolute paths to application-specific directories on all |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1478 | * shared/external storage devices where the application can place cache |
| 1479 | * files it owns. These files are internal to the application, and not |
| 1480 | * typically visible to the user as media. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1481 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1482 | * This is like {@link #getCacheDir()} in that these files will be deleted |
| 1483 | * when the application is uninstalled, however there are some important |
| 1484 | * differences: |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1485 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1486 | * <li>The platform does not always monitor the space available in shared |
| 1487 | * storage, and thus may not automatically delete these files. Apps should |
| 1488 | * always manage the maximum space used in this location. Currently the only |
| 1489 | * time files here will be deleted by the platform is when running on |
| 1490 | * {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} or later and |
| 1491 | * {@link Environment#isExternalStorageEmulated(File)} returns true. |
| 1492 | * <li>Shared storage may not always be available, since removable media can |
| 1493 | * be ejected by the user. Media state can be checked using |
| 1494 | * {@link Environment#getExternalStorageState(File)}. |
| 1495 | * <li>There is no security enforced with these files. For example, any |
| 1496 | * application holding |
| 1497 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 1498 | * these files. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1499 | * </ul> |
| 1500 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1501 | * If a shared storage device is emulated (as determined by |
| 1502 | * {@link Environment#isExternalStorageEmulated(File)}), it's contents are |
| 1503 | * backed by a private user data partition, which means there is little |
| 1504 | * benefit to storing data here instead of the private directory returned by |
| 1505 | * {@link #getCacheDir()}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1506 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1507 | * Shared storage devices returned here are considered a stable part of the |
| 1508 | * device, including physical media slots under a protective cover. The |
| 1509 | * returned paths do not include transient devices, such as USB flash drives |
| 1510 | * connected to handheld devices. |
| 1511 | * <p> |
| 1512 | * 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] | 1513 | * example, an app may choose to store large files on the device with the |
| 1514 | * most available space, as measured by {@link StatFs}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1515 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1516 | * No additional permissions are required for the calling app to read or |
| 1517 | * write files under the returned path. Write access outside of these paths |
| 1518 | * on secondary external storage devices is not available. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1519 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1520 | * The returned paths may change over time if different shared storage media |
| 1521 | * is inserted, so only relative paths should be persisted. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1522 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1523 | * @return the absolute paths to application-specific directories. Some |
| 1524 | * individual paths may be {@code null} if that shared storage is |
| 1525 | * not currently available. The first path returned is the same as |
| 1526 | * {@link #getExternalCacheDir()}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1527 | * @see #getExternalCacheDir() |
Jeff Sharkey | 4ca728c | 2014-01-10 16:27:19 -0800 | [diff] [blame] | 1528 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1529 | * @see Environment#isExternalStorageEmulated(File) |
| 1530 | * @see Environment#isExternalStorageRemovable(File) |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1531 | */ |
| 1532 | public abstract File[] getExternalCacheDirs(); |
| 1533 | |
| 1534 | /** |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1535 | * Returns absolute paths to application-specific directories on all |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1536 | * shared/external storage devices where the application can place media |
| 1537 | * files. These files are scanned and made available to other apps through |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1538 | * {@link MediaStore}. |
| 1539 | * <p> |
| 1540 | * This is like {@link #getExternalFilesDirs} in that these files will be |
| 1541 | * deleted when the application is uninstalled, however there are some |
| 1542 | * important differences: |
| 1543 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1544 | * <li>Shared storage may not always be available, since removable media can |
| 1545 | * be ejected by the user. Media state can be checked using |
| 1546 | * {@link Environment#getExternalStorageState(File)}. |
| 1547 | * <li>There is no security enforced with these files. For example, any |
| 1548 | * application holding |
| 1549 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 1550 | * these files. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1551 | * </ul> |
| 1552 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1553 | * Shared storage devices returned here are considered a stable part of the |
| 1554 | * device, including physical media slots under a protective cover. The |
| 1555 | * returned paths do not include transient devices, such as USB flash drives |
| 1556 | * connected to handheld devices. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1557 | * <p> |
| 1558 | * An application may store data on any or all of the returned devices. For |
| 1559 | * example, an app may choose to store large files on the device with the |
| 1560 | * most available space, as measured by {@link StatFs}. |
| 1561 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1562 | * No additional permissions are required for the calling app to read or |
| 1563 | * write files under the returned path. Write access outside of these paths |
| 1564 | * on secondary external storage devices is not available. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1565 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1566 | * The returned paths may change over time if different shared storage media |
| 1567 | * is inserted, so only relative paths should be persisted. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1568 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1569 | * @return the absolute paths to application-specific directories. Some |
| 1570 | * individual paths may be {@code null} if that shared storage is |
| 1571 | * not currently available. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1572 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1573 | * @see Environment#isExternalStorageEmulated(File) |
| 1574 | * @see Environment#isExternalStorageRemovable(File) |
Jeff Sharkey | 588c15e | 2019-10-10 17:29:58 -0600 | [diff] [blame] | 1575 | * @deprecated These directories still exist and are scanned, but developers |
| 1576 | * are encouraged to migrate to inserting content into a |
| 1577 | * {@link MediaStore} collection directly, as any app can |
| 1578 | * contribute new media to {@link MediaStore} with no |
| 1579 | * permissions required, starting in |
| 1580 | * {@link android.os.Build.VERSION_CODES#Q}. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1581 | */ |
Jeff Sharkey | 588c15e | 2019-10-10 17:29:58 -0600 | [diff] [blame] | 1582 | @Deprecated |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1583 | public abstract File[] getExternalMediaDirs(); |
| 1584 | |
| 1585 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1586 | * Returns an array of strings naming the private files associated with |
| 1587 | * this Context's application package. |
| 1588 | * |
| 1589 | * @return Array of strings naming the private files. |
| 1590 | * |
| 1591 | * @see #openFileInput |
| 1592 | * @see #openFileOutput |
| 1593 | * @see #deleteFile |
| 1594 | */ |
| 1595 | public abstract String[] fileList(); |
| 1596 | |
| 1597 | /** |
| 1598 | * Retrieve, creating if needed, a new directory in which the application |
| 1599 | * can place its own custom data files. You can use the returned File |
| 1600 | * object to create and access files in this directory. Note that files |
| 1601 | * created through a File object will only be accessible by your own |
| 1602 | * application; you can only set the mode of the entire directory, not |
| 1603 | * of individual files. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1604 | * <p> |
| 1605 | * The returned path may change over time if the calling app is moved to an |
| 1606 | * adopted storage device, so only relative paths should be persisted. |
| 1607 | * <p> |
| 1608 | * Apps require no extra permissions to read or write to the returned path, |
| 1609 | * since this path lives in their private storage. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1610 | * |
Nick Kralevich | 92091fa | 2012-12-12 16:24:31 -0800 | [diff] [blame] | 1611 | * @param name Name of the directory to retrieve. This is a directory |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1612 | * that is created as part of your application data. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1613 | * @param mode Operating mode. |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1614 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1615 | * @return A {@link File} object for the requested directory. The directory |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1616 | * 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] | 1617 | * |
| 1618 | * @see #openFileOutput(String, int) |
| 1619 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1620 | public abstract File getDir(String name, @FileMode int mode); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1621 | |
| 1622 | /** |
| 1623 | * Open a new private SQLiteDatabase associated with this Context's |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1624 | * 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] | 1625 | * |
| 1626 | * @param name The name (unique in the application package) of the database. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1627 | * @param mode Operating mode. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1628 | * @param factory An optional factory class that is called to instantiate a |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1629 | * cursor when query is called. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1630 | * @return The contents of a newly created database with the given name. |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1631 | * @throws android.database.sqlite.SQLiteException if the database file |
| 1632 | * could not be opened. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1633 | * @see #MODE_PRIVATE |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 1634 | * @see #MODE_ENABLE_WRITE_AHEAD_LOGGING |
Sunny Goyal | a21e6b2 | 2015-12-02 09:51:02 -0800 | [diff] [blame] | 1635 | * @see #MODE_NO_LOCALIZED_COLLATORS |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1636 | * @see #deleteDatabase |
| 1637 | */ |
| 1638 | public abstract SQLiteDatabase openOrCreateDatabase(String name, |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1639 | @DatabaseMode int mode, CursorFactory factory); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1640 | |
| 1641 | /** |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1642 | * Open a new private SQLiteDatabase associated with this Context's |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1643 | * application package. Creates the database file if it doesn't exist. |
| 1644 | * <p> |
| 1645 | * Accepts input param: a concrete instance of {@link DatabaseErrorHandler} |
| 1646 | * to be used to handle corruption when sqlite reports database corruption. |
| 1647 | * </p> |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1648 | * |
| 1649 | * @param name The name (unique in the application package) of the database. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1650 | * @param mode Operating mode. |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1651 | * @param factory An optional factory class that is called to instantiate a |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1652 | * cursor when query is called. |
| 1653 | * @param errorHandler the {@link DatabaseErrorHandler} to be used when |
| 1654 | * sqlite reports database corruption. if null, |
| 1655 | * {@link android.database.DefaultDatabaseErrorHandler} is |
| 1656 | * assumed. |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1657 | * @return The contents of a newly created database with the given name. |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1658 | * @throws android.database.sqlite.SQLiteException if the database file |
| 1659 | * could not be opened. |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1660 | * @see #MODE_PRIVATE |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 1661 | * @see #MODE_ENABLE_WRITE_AHEAD_LOGGING |
Sunny Goyal | a21e6b2 | 2015-12-02 09:51:02 -0800 | [diff] [blame] | 1662 | * @see #MODE_NO_LOCALIZED_COLLATORS |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1663 | * @see #deleteDatabase |
| 1664 | */ |
| 1665 | public abstract SQLiteDatabase openOrCreateDatabase(String name, |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1666 | @DatabaseMode int mode, CursorFactory factory, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1667 | @Nullable DatabaseErrorHandler errorHandler); |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1668 | |
| 1669 | /** |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 1670 | * Move an existing database file from the given source storage context to |
| 1671 | * this context. This is typically used to migrate data between storage |
| 1672 | * locations after an upgrade, such as migrating to device protected |
| 1673 | * storage. |
Jeff Sharkey | d21cad1 | 2016-05-20 11:30:07 -0600 | [diff] [blame] | 1674 | * <p> |
| 1675 | * The database must be closed before being moved. |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 1676 | * |
| 1677 | * @param sourceContext The source context which contains the existing |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 1678 | * database to move. |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 1679 | * @param name The name of the database file. |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 1680 | * @return {@code true} if the move was successful or if the database didn't |
| 1681 | * exist in the source context, otherwise {@code false}. |
| 1682 | * @see #createDeviceProtectedStorageContext() |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 1683 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 1684 | public abstract boolean moveDatabaseFrom(Context sourceContext, String name); |
| 1685 | |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 1686 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1687 | * Delete an existing private SQLiteDatabase associated with this Context's |
| 1688 | * application package. |
| 1689 | * |
| 1690 | * @param name The name (unique in the application package) of the |
| 1691 | * database. |
| 1692 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1693 | * @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] | 1694 | * |
| 1695 | * @see #openOrCreateDatabase |
| 1696 | */ |
| 1697 | public abstract boolean deleteDatabase(String name); |
| 1698 | |
| 1699 | /** |
| 1700 | * Returns the absolute path on the filesystem where a database created with |
| 1701 | * {@link #openOrCreateDatabase} is stored. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1702 | * <p> |
| 1703 | * The returned path may change over time if the calling app is moved to an |
| 1704 | * 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] | 1705 | * |
| 1706 | * @param name The name of the database for which you would like to get |
| 1707 | * its path. |
| 1708 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1709 | * @return An absolute path to the given database. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1710 | * |
| 1711 | * @see #openOrCreateDatabase |
| 1712 | */ |
| 1713 | public abstract File getDatabasePath(String name); |
| 1714 | |
| 1715 | /** |
| 1716 | * Returns an array of strings naming the private databases associated with |
| 1717 | * this Context's application package. |
| 1718 | * |
| 1719 | * @return Array of strings naming the private databases. |
| 1720 | * |
| 1721 | * @see #openOrCreateDatabase |
| 1722 | * @see #deleteDatabase |
| 1723 | */ |
| 1724 | public abstract String[] databaseList(); |
| 1725 | |
| 1726 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1727 | * @deprecated Use {@link android.app.WallpaperManager#getDrawable |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1728 | * WallpaperManager.get()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1729 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1730 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1731 | public abstract Drawable getWallpaper(); |
| 1732 | |
| 1733 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1734 | * @deprecated Use {@link android.app.WallpaperManager#peekDrawable |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1735 | * WallpaperManager.peek()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1736 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1737 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1738 | public abstract Drawable peekWallpaper(); |
| 1739 | |
| 1740 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1741 | * @deprecated Use {@link android.app.WallpaperManager#getDesiredMinimumWidth() |
| 1742 | * WallpaperManager.getDesiredMinimumWidth()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1743 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1744 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1745 | public abstract int getWallpaperDesiredMinimumWidth(); |
| 1746 | |
| 1747 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1748 | * @deprecated Use {@link android.app.WallpaperManager#getDesiredMinimumHeight() |
| 1749 | * WallpaperManager.getDesiredMinimumHeight()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1750 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1751 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1752 | public abstract int getWallpaperDesiredMinimumHeight(); |
| 1753 | |
| 1754 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1755 | * @deprecated Use {@link android.app.WallpaperManager#setBitmap(Bitmap) |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1756 | * WallpaperManager.set()} instead. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 1757 | * <p>This method requires the caller to hold the permission |
| 1758 | * {@link android.Manifest.permission#SET_WALLPAPER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1759 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1760 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1761 | public abstract void setWallpaper(Bitmap bitmap) throws IOException; |
| 1762 | |
| 1763 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1764 | * @deprecated Use {@link android.app.WallpaperManager#setStream(InputStream) |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1765 | * WallpaperManager.set()} instead. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 1766 | * <p>This method requires the caller to hold the permission |
| 1767 | * {@link android.Manifest.permission#SET_WALLPAPER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1768 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1769 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1770 | public abstract void setWallpaper(InputStream data) throws IOException; |
| 1771 | |
| 1772 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1773 | * @deprecated Use {@link android.app.WallpaperManager#clear |
| 1774 | * WallpaperManager.clear()} instead. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 1775 | * <p>This method requires the caller to hold the permission |
| 1776 | * {@link android.Manifest.permission#SET_WALLPAPER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1777 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1778 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1779 | public abstract void clearWallpaper() throws IOException; |
| 1780 | |
| 1781 | /** |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1782 | * Same as {@link #startActivity(Intent, Bundle)} with no options |
| 1783 | * specified. |
| 1784 | * |
| 1785 | * @param intent The description of the activity to start. |
| 1786 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1787 | * @throws ActivityNotFoundException |
Svet Ganov | 1ed0e55 | 2015-06-11 01:15:43 -0700 | [diff] [blame] | 1788 | *` |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1789 | * @see #startActivity(Intent, Bundle) |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1790 | * @see PackageManager#resolveActivity |
| 1791 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1792 | public abstract void startActivity(@RequiresPermission Intent intent); |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1793 | |
| 1794 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1795 | * Version of {@link #startActivity(Intent)} that allows you to specify the |
| 1796 | * 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] | 1797 | * that are not pre-installed on the system image. |
Amith Yamasani | 8264408 | 2012-08-03 13:09:11 -0700 | [diff] [blame] | 1798 | * @param intent The description of the activity to start. |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 1799 | * @param user The UserHandle of the user to start this activity for. |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1800 | * @throws ActivityNotFoundException |
Amith Yamasani | 8264408 | 2012-08-03 13:09:11 -0700 | [diff] [blame] | 1801 | * @hide |
| 1802 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 1803 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) |
Philip P. Moltmann | 4e615e6 | 2018-08-28 14:57:49 -0700 | [diff] [blame] | 1804 | @SystemApi |
Adrian Roos | ebc927c | 2019-02-28 16:21:18 +0100 | [diff] [blame] | 1805 | public void startActivityAsUser(@RequiresPermission @NonNull Intent intent, |
| 1806 | @NonNull UserHandle user) { |
Amith Yamasani | 8264408 | 2012-08-03 13:09:11 -0700 | [diff] [blame] | 1807 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 1808 | } |
| 1809 | |
| 1810 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1811 | * Launch a new activity. You will not receive any information about when |
| 1812 | * the activity exits. |
| 1813 | * |
| 1814 | * <p>Note that if this method is being called from outside of an |
| 1815 | * {@link android.app.Activity} Context, then the Intent must include |
| 1816 | * the {@link Intent#FLAG_ACTIVITY_NEW_TASK} launch flag. This is because, |
| 1817 | * without being started from an existing Activity, there is no existing |
| 1818 | * task in which to place the new activity and thus it needs to be placed |
| 1819 | * in its own separate task. |
| 1820 | * |
| 1821 | * <p>This method throws {@link ActivityNotFoundException} |
| 1822 | * if there was no Activity found to run the given Intent. |
| 1823 | * |
| 1824 | * @param intent The description of the activity to start. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1825 | * @param options Additional options for how the Activity should be started. |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 1826 | * May be null if there are no options. See {@link android.app.ActivityOptions} |
| 1827 | * for how to build the Bundle supplied here; there are no supported definitions |
| 1828 | * for building it manually. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1829 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1830 | * @throws ActivityNotFoundException |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1831 | * |
Scott Main | 60dd520 | 2012-06-23 00:01:22 -0700 | [diff] [blame] | 1832 | * @see #startActivity(Intent) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1833 | * @see PackageManager#resolveActivity |
| 1834 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1835 | public abstract void startActivity(@RequiresPermission Intent intent, |
| 1836 | @Nullable Bundle options); |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1837 | |
| 1838 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1839 | * Version of {@link #startActivity(Intent, Bundle)} that allows you to specify the |
| 1840 | * 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] | 1841 | * that are not pre-installed on the system image. |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 1842 | * @param intent The description of the activity to start. |
| 1843 | * @param options Additional options for how the Activity should be started. |
| 1844 | * May be null if there are no options. See {@link android.app.ActivityOptions} |
| 1845 | * for how to build the Bundle supplied here; there are no supported definitions |
| 1846 | * for building it manually. |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 1847 | * @param userId The UserHandle of the user to start this activity for. |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1848 | * @throws ActivityNotFoundException |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 1849 | * @hide |
| 1850 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 1851 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 1852 | @UnsupportedAppUsage |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1853 | public void startActivityAsUser(@RequiresPermission Intent intent, @Nullable Bundle options, |
| 1854 | UserHandle userId) { |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 1855 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 1856 | } |
| 1857 | |
| 1858 | /** |
Clara Bayarri | d5bf3ed | 2015-03-27 17:32:45 +0000 | [diff] [blame] | 1859 | * Version of {@link #startActivity(Intent, Bundle)} that returns a result to the caller. This |
| 1860 | * is only supported for Views and Fragments. |
| 1861 | * @param who The identifier for the calling element that will receive the result. |
| 1862 | * @param intent The intent to start. |
| 1863 | * @param requestCode The code that will be returned with onActivityResult() identifying this |
| 1864 | * request. |
| 1865 | * @param options Additional options for how the Activity should be started. |
| 1866 | * May be null if there are no options. See {@link android.app.ActivityOptions} |
| 1867 | * for how to build the Bundle supplied here; there are no supported definitions |
| 1868 | * for building it manually. |
| 1869 | * @hide |
| 1870 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 1871 | @UnsupportedAppUsage |
Clara Bayarri | d5bf3ed | 2015-03-27 17:32:45 +0000 | [diff] [blame] | 1872 | public void startActivityForResult( |
| 1873 | @NonNull String who, Intent intent, int requestCode, @Nullable Bundle options) { |
| 1874 | throw new RuntimeException("This method is only implemented for Activity-based Contexts. " |
| 1875 | + "Check canStartActivityForResult() before calling."); |
| 1876 | } |
| 1877 | |
| 1878 | /** |
| 1879 | * Identifies whether this Context instance will be able to process calls to |
| 1880 | * {@link #startActivityForResult(String, Intent, int, Bundle)}. |
| 1881 | * @hide |
| 1882 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 1883 | @UnsupportedAppUsage |
Clara Bayarri | d5bf3ed | 2015-03-27 17:32:45 +0000 | [diff] [blame] | 1884 | public boolean canStartActivityForResult() { |
| 1885 | return false; |
| 1886 | } |
| 1887 | |
| 1888 | /** |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1889 | * Same as {@link #startActivities(Intent[], Bundle)} with no options |
| 1890 | * specified. |
| 1891 | * |
| 1892 | * @param intents An array of Intents to be started. |
| 1893 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1894 | * @throws ActivityNotFoundException |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1895 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1896 | * @see #startActivities(Intent[], Bundle) |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1897 | * @see PackageManager#resolveActivity |
| 1898 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1899 | public abstract void startActivities(@RequiresPermission Intent[] intents); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1900 | |
| 1901 | /** |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1902 | * Launch multiple new activities. This is generally the same as calling |
| 1903 | * {@link #startActivity(Intent)} for the first Intent in the array, |
| 1904 | * that activity during its creation calling {@link #startActivity(Intent)} |
| 1905 | * for the second entry, etc. Note that unlike that approach, generally |
| 1906 | * none of the activities except the last in the array will be created |
| 1907 | * at this point, but rather will be created when the user first visits |
| 1908 | * them (due to pressing back from the activity on top). |
| 1909 | * |
| 1910 | * <p>This method throws {@link ActivityNotFoundException} |
| 1911 | * if there was no Activity found for <em>any</em> given Intent. In this |
| 1912 | * case the state of the activity stack is undefined (some Intents in the |
| 1913 | * list may be on it, some not), so you probably want to avoid such situations. |
| 1914 | * |
| 1915 | * @param intents An array of Intents to be started. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1916 | * @param options Additional options for how the Activity should be started. |
Elliot Waite | 54de774 | 2017-01-11 15:30:35 -0800 | [diff] [blame] | 1917 | * See {@link android.content.Context#startActivity(Intent, Bundle)} |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 1918 | * Context.startActivity(Intent, Bundle)} for more details. |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1919 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1920 | * @throws ActivityNotFoundException |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1921 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1922 | * @see #startActivities(Intent[]) |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1923 | * @see PackageManager#resolveActivity |
| 1924 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1925 | public abstract void startActivities(@RequiresPermission Intent[] intents, Bundle options); |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1926 | |
| 1927 | /** |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1928 | * @hide |
| 1929 | * Launch multiple new activities. This is generally the same as calling |
| 1930 | * {@link #startActivity(Intent)} for the first Intent in the array, |
| 1931 | * that activity during its creation calling {@link #startActivity(Intent)} |
| 1932 | * for the second entry, etc. Note that unlike that approach, generally |
| 1933 | * none of the activities except the last in the array will be created |
| 1934 | * at this point, but rather will be created when the user first visits |
| 1935 | * them (due to pressing back from the activity on top). |
| 1936 | * |
| 1937 | * <p>This method throws {@link ActivityNotFoundException} |
| 1938 | * if there was no Activity found for <em>any</em> given Intent. In this |
| 1939 | * case the state of the activity stack is undefined (some Intents in the |
| 1940 | * list may be on it, some not), so you probably want to avoid such situations. |
| 1941 | * |
| 1942 | * @param intents An array of Intents to be started. |
| 1943 | * @param options Additional options for how the Activity should be started. |
| 1944 | * @param userHandle The user for whom to launch the activities |
Elliot Waite | 54de774 | 2017-01-11 15:30:35 -0800 | [diff] [blame] | 1945 | * See {@link android.content.Context#startActivity(Intent, Bundle)} |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1946 | * Context.startActivity(Intent, Bundle)} for more details. |
| 1947 | * |
Selim Cinek | 7fa385a | 2018-01-24 08:35:28 -0800 | [diff] [blame] | 1948 | * @return The corresponding flag {@link ActivityManager#START_CANCELED}, |
| 1949 | * {@link ActivityManager#START_SUCCESS} etc. indicating whether the launch was |
| 1950 | * successful. |
| 1951 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1952 | * @throws ActivityNotFoundException |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1953 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1954 | * @see #startActivities(Intent[]) |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1955 | * @see PackageManager#resolveActivity |
| 1956 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 1957 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) |
Selim Cinek | 7fa385a | 2018-01-24 08:35:28 -0800 | [diff] [blame] | 1958 | public int startActivitiesAsUser(Intent[] intents, Bundle options, UserHandle userHandle) { |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1959 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 1960 | } |
| 1961 | |
| 1962 | /** |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1963 | * Same as {@link #startIntentSender(IntentSender, Intent, int, int, int, Bundle)} |
| 1964 | * with no options specified. |
| 1965 | * |
| 1966 | * @param intent The IntentSender to launch. |
| 1967 | * @param fillInIntent If non-null, this will be provided as the |
| 1968 | * intent parameter to {@link IntentSender#sendIntent}. |
| 1969 | * @param flagsMask Intent flags in the original IntentSender that you |
| 1970 | * would like to change. |
| 1971 | * @param flagsValues Desired values for any bits set in |
| 1972 | * <var>flagsMask</var> |
| 1973 | * @param extraFlags Always set to 0. |
| 1974 | * |
| 1975 | * @see #startActivity(Intent) |
| 1976 | * @see #startIntentSender(IntentSender, Intent, int, int, int, Bundle) |
| 1977 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1978 | public abstract void startIntentSender(IntentSender intent, @Nullable Intent fillInIntent, |
| 1979 | @Intent.MutableFlags int flagsMask, @Intent.MutableFlags int flagsValues, |
| 1980 | int extraFlags) throws IntentSender.SendIntentException; |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1981 | |
| 1982 | /** |
| 1983 | * Like {@link #startActivity(Intent, Bundle)}, but taking a IntentSender |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1984 | * 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] | 1985 | * as if you had called the regular {@link #startActivity(Intent)} |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1986 | * here; otherwise, its associated action will be executed (such as |
| 1987 | * sending a broadcast) as if you had called |
| 1988 | * {@link IntentSender#sendIntent IntentSender.sendIntent} on it. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1989 | * |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 1990 | * @param intent The IntentSender to launch. |
| 1991 | * @param fillInIntent If non-null, this will be provided as the |
| 1992 | * intent parameter to {@link IntentSender#sendIntent}. |
| 1993 | * @param flagsMask Intent flags in the original IntentSender that you |
| 1994 | * would like to change. |
| 1995 | * @param flagsValues Desired values for any bits set in |
| 1996 | * <var>flagsMask</var> |
| 1997 | * @param extraFlags Always set to 0. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1998 | * @param options Additional options for how the Activity should be started. |
Elliot Waite | 54de774 | 2017-01-11 15:30:35 -0800 | [diff] [blame] | 1999 | * See {@link android.content.Context#startActivity(Intent, Bundle)} |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 2000 | * Context.startActivity(Intent, Bundle)} for more details. If options |
| 2001 | * have also been supplied by the IntentSender, options given here will |
| 2002 | * override any that conflict with those given by the IntentSender. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 2003 | * |
| 2004 | * @see #startActivity(Intent, Bundle) |
| 2005 | * @see #startIntentSender(IntentSender, Intent, int, int, int) |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 2006 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 2007 | public abstract void startIntentSender(IntentSender intent, @Nullable Intent fillInIntent, |
| 2008 | @Intent.MutableFlags int flagsMask, @Intent.MutableFlags int flagsValues, |
| 2009 | int extraFlags, @Nullable Bundle options) throws IntentSender.SendIntentException; |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 2010 | |
| 2011 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2012 | * Broadcast the given intent to all interested BroadcastReceivers. This |
| 2013 | * call is asynchronous; it returns immediately, and you will continue |
| 2014 | * executing while the receivers are run. No results are propagated from |
| 2015 | * receivers and receivers can not abort the broadcast. If you want |
| 2016 | * to allow receivers to propagate results or abort the broadcast, you must |
| 2017 | * send an ordered broadcast using |
| 2018 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2019 | * |
| 2020 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2021 | * |
| 2022 | * @param intent The Intent to broadcast; all receivers matching this |
| 2023 | * Intent will receive the broadcast. |
| 2024 | * |
| 2025 | * @see android.content.BroadcastReceiver |
| 2026 | * @see #registerReceiver |
| 2027 | * @see #sendBroadcast(Intent, String) |
| 2028 | * @see #sendOrderedBroadcast(Intent, String) |
| 2029 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2030 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2031 | public abstract void sendBroadcast(@RequiresPermission Intent intent); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2032 | |
| 2033 | /** |
| 2034 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
| 2035 | * an optional required permission to be enforced. This |
| 2036 | * call is asynchronous; it returns immediately, and you will continue |
| 2037 | * executing while the receivers are run. No results are propagated from |
| 2038 | * receivers and receivers can not abort the broadcast. If you want |
| 2039 | * to allow receivers to propagate results or abort the broadcast, you must |
| 2040 | * send an ordered broadcast using |
| 2041 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2042 | * |
| 2043 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2044 | * |
| 2045 | * @param intent The Intent to broadcast; all receivers matching this |
| 2046 | * Intent will receive the broadcast. |
Brad Fitzpatrick | 26b71be | 2010-12-07 14:52:58 -0800 | [diff] [blame] | 2047 | * @param receiverPermission (optional) String naming a permission that |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2048 | * a receiver must hold in order to receive your broadcast. |
| 2049 | * If null, no permission is required. |
| 2050 | * |
| 2051 | * @see android.content.BroadcastReceiver |
| 2052 | * @see #registerReceiver |
| 2053 | * @see #sendBroadcast(Intent) |
| 2054 | * @see #sendOrderedBroadcast(Intent, String) |
| 2055 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2056 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2057 | public abstract void sendBroadcast(@RequiresPermission Intent intent, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2058 | @Nullable String receiverPermission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2059 | |
Fyodor Kupolov | d4fd8c7 | 2015-07-13 19:19:25 -0700 | [diff] [blame] | 2060 | |
| 2061 | /** |
| 2062 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
| 2063 | * an array of required permissions to be enforced. This call is asynchronous; it returns |
| 2064 | * immediately, and you will continue executing while the receivers are run. No results are |
| 2065 | * propagated from receivers and receivers can not abort the broadcast. If you want to allow |
| 2066 | * receivers to propagate results or abort the broadcast, you must send an ordered broadcast |
| 2067 | * using {@link #sendOrderedBroadcast(Intent, String)}. |
| 2068 | * |
| 2069 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2070 | * |
| 2071 | * @param intent The Intent to broadcast; all receivers matching this |
| 2072 | * Intent will receive the broadcast. |
| 2073 | * @param receiverPermissions Array of names of permissions that a receiver must hold |
| 2074 | * in order to receive your broadcast. |
Roshan Pius | 3fe42f0 | 2019-11-12 09:56:48 -0800 | [diff] [blame] | 2075 | * If empty, no permissions are required. |
Fyodor Kupolov | d4fd8c7 | 2015-07-13 19:19:25 -0700 | [diff] [blame] | 2076 | * |
| 2077 | * @see android.content.BroadcastReceiver |
| 2078 | * @see #registerReceiver |
| 2079 | * @see #sendBroadcast(Intent) |
| 2080 | * @see #sendOrderedBroadcast(Intent, String) |
| 2081 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2082 | * @hide |
| 2083 | */ |
Roshan Pius | 3fe42f0 | 2019-11-12 09:56:48 -0800 | [diff] [blame] | 2084 | public void sendBroadcastMultiplePermissions(@NonNull Intent intent, |
| 2085 | @NonNull String[] receiverPermissions) { |
| 2086 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 2087 | } |
Fyodor Kupolov | d4fd8c7 | 2015-07-13 19:19:25 -0700 | [diff] [blame] | 2088 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2089 | /** |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 2090 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
Tyler Gunn | f955e56 | 2018-04-26 14:43:31 -0700 | [diff] [blame] | 2091 | * an array of required permissions to be enforced. This call is asynchronous; it returns |
| 2092 | * immediately, and you will continue executing while the receivers are run. No results are |
| 2093 | * propagated from receivers and receivers can not abort the broadcast. If you want to allow |
| 2094 | * receivers to propagate results or abort the broadcast, you must send an ordered broadcast |
| 2095 | * using {@link #sendOrderedBroadcast(Intent, String)}. |
| 2096 | * |
| 2097 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2098 | * |
| 2099 | * @param intent The Intent to broadcast; all receivers matching this |
| 2100 | * Intent will receive the broadcast. |
Roshan Pius | a2baf58e | 2019-11-20 14:40:30 -0800 | [diff] [blame] | 2101 | * @param receiverPermissions Array of names of permissions that a receiver must hold |
| 2102 | * in order to receive your broadcast. |
| 2103 | * If empty, no permissions are required. |
| 2104 | * |
| 2105 | * @see android.content.BroadcastReceiver |
| 2106 | * @see #registerReceiver |
| 2107 | * @see #sendBroadcast(Intent) |
| 2108 | * @see #sendOrderedBroadcast(Intent, String) |
| 2109 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2110 | */ |
| 2111 | public void sendBroadcastWithMultiplePermissions(@NonNull Intent intent, |
| 2112 | @NonNull String[] receiverPermissions) { |
| 2113 | sendBroadcastMultiplePermissions(intent, receiverPermissions); |
| 2114 | } |
| 2115 | |
| 2116 | /** |
| 2117 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
| 2118 | * an array of required permissions to be enforced. This call is asynchronous; it returns |
| 2119 | * immediately, and you will continue executing while the receivers are run. No results are |
| 2120 | * propagated from receivers and receivers can not abort the broadcast. If you want to allow |
| 2121 | * receivers to propagate results or abort the broadcast, you must send an ordered broadcast |
| 2122 | * using {@link #sendOrderedBroadcast(Intent, String)}. |
| 2123 | * |
| 2124 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2125 | * |
| 2126 | * @param intent The Intent to broadcast; all receivers matching this |
| 2127 | * Intent will receive the broadcast. |
Tyler Gunn | f955e56 | 2018-04-26 14:43:31 -0700 | [diff] [blame] | 2128 | * @param user The user to send the broadcast to. |
| 2129 | * @param receiverPermissions Array of names of permissions that a receiver must hold |
| 2130 | * in order to receive your broadcast. |
| 2131 | * If null or empty, no permissions are required. |
| 2132 | * |
| 2133 | * @see android.content.BroadcastReceiver |
| 2134 | * @see #registerReceiver |
| 2135 | * @see #sendBroadcast(Intent) |
| 2136 | * @see #sendOrderedBroadcast(Intent, String) |
| 2137 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2138 | * @hide |
| 2139 | */ |
| 2140 | public abstract void sendBroadcastAsUserMultiplePermissions(Intent intent, UserHandle user, |
| 2141 | String[] receiverPermissions); |
| 2142 | |
| 2143 | /** |
| 2144 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 2145 | * an optional required permission to be enforced. This |
| 2146 | * call is asynchronous; it returns immediately, and you will continue |
| 2147 | * executing while the receivers are run. No results are propagated from |
| 2148 | * receivers and receivers can not abort the broadcast. If you want |
| 2149 | * to allow receivers to propagate results or abort the broadcast, you must |
| 2150 | * send an ordered broadcast using |
| 2151 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2152 | * |
| 2153 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2154 | * |
| 2155 | * @param intent The Intent to broadcast; all receivers matching this |
| 2156 | * Intent will receive the broadcast. |
| 2157 | * @param receiverPermission (optional) String naming a permission that |
| 2158 | * a receiver must hold in order to receive your broadcast. |
| 2159 | * If null, no permission is required. |
| 2160 | * @param options (optional) Additional sending options, generated from a |
| 2161 | * {@link android.app.BroadcastOptions}. |
| 2162 | * |
| 2163 | * @see android.content.BroadcastReceiver |
| 2164 | * @see #registerReceiver |
| 2165 | * @see #sendBroadcast(Intent) |
| 2166 | * @see #sendOrderedBroadcast(Intent, String) |
| 2167 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2168 | * @hide |
| 2169 | */ |
| 2170 | @SystemApi |
| 2171 | public abstract void sendBroadcast(Intent intent, |
| 2172 | @Nullable String receiverPermission, |
| 2173 | @Nullable Bundle options); |
| 2174 | |
| 2175 | /** |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2176 | * Like {@link #sendBroadcast(Intent, String)}, but also allows specification |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2177 | * of an associated app op as per {@link android.app.AppOpsManager}. |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2178 | * @hide |
| 2179 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 2180 | @UnsupportedAppUsage |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2181 | public abstract void sendBroadcast(Intent intent, |
| 2182 | String receiverPermission, int appOp); |
| 2183 | |
| 2184 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2185 | * Broadcast the given intent to all interested BroadcastReceivers, delivering |
| 2186 | * them one at a time to allow more preferred receivers to consume the |
| 2187 | * broadcast before it is delivered to less preferred receivers. This |
| 2188 | * call is asynchronous; it returns immediately, and you will continue |
| 2189 | * executing while the receivers are run. |
| 2190 | * |
| 2191 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2192 | * |
| 2193 | * @param intent The Intent to broadcast; all receivers matching this |
| 2194 | * Intent will receive the broadcast. |
| 2195 | * @param receiverPermission (optional) String naming a permissions that |
| 2196 | * a receiver must hold in order to receive your broadcast. |
| 2197 | * If null, no permission is required. |
| 2198 | * |
| 2199 | * @see android.content.BroadcastReceiver |
| 2200 | * @see #registerReceiver |
| 2201 | * @see #sendBroadcast(Intent) |
| 2202 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2203 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2204 | public abstract void sendOrderedBroadcast(@RequiresPermission Intent intent, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2205 | @Nullable String receiverPermission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2206 | |
| 2207 | /** |
| 2208 | * Version of {@link #sendBroadcast(Intent)} that allows you to |
| 2209 | * receive data back from the broadcast. This is accomplished by |
| 2210 | * supplying your own BroadcastReceiver when calling, which will be |
| 2211 | * treated as a final receiver at the end of the broadcast -- its |
| 2212 | * {@link BroadcastReceiver#onReceive} method will be called with |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2213 | * 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] | 2214 | * be serialized in the same way as calling |
| 2215 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2216 | * |
| 2217 | * <p>Like {@link #sendBroadcast(Intent)}, this method is |
| 2218 | * asynchronous; it will return before |
| 2219 | * resultReceiver.onReceive() is called. |
| 2220 | * |
| 2221 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2222 | * |
| 2223 | * @param intent The Intent to broadcast; all receivers matching this |
| 2224 | * Intent will receive the broadcast. |
| 2225 | * @param receiverPermission String naming a permissions that |
| 2226 | * a receiver must hold in order to receive your broadcast. |
| 2227 | * If null, no permission is required. |
| 2228 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2229 | * receiver of the broadcast. |
| 2230 | * @param scheduler A custom Handler with which to schedule the |
| 2231 | * resultReceiver callback; if null it will be |
| 2232 | * scheduled in the Context's main thread. |
| 2233 | * @param initialCode An initial value for the result code. Often |
| 2234 | * Activity.RESULT_OK. |
| 2235 | * @param initialData An initial value for the result data. Often |
| 2236 | * null. |
| 2237 | * @param initialExtras An initial value for the result extras. Often |
| 2238 | * null. |
| 2239 | * |
| 2240 | * @see #sendBroadcast(Intent) |
| 2241 | * @see #sendBroadcast(Intent, String) |
| 2242 | * @see #sendOrderedBroadcast(Intent, String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2243 | * @see android.content.BroadcastReceiver |
| 2244 | * @see #registerReceiver |
| 2245 | * @see android.app.Activity#RESULT_OK |
| 2246 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2247 | public abstract void sendOrderedBroadcast(@RequiresPermission @NonNull Intent intent, |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 2248 | @Nullable String receiverPermission, @Nullable BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2249 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2250 | @Nullable Bundle initialExtras); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2251 | |
| 2252 | /** |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 2253 | * Version of {@link #sendBroadcast(Intent)} that allows you to |
| 2254 | * receive data back from the broadcast. This is accomplished by |
| 2255 | * supplying your own BroadcastReceiver when calling, which will be |
| 2256 | * treated as a final receiver at the end of the broadcast -- its |
| 2257 | * {@link BroadcastReceiver#onReceive} method will be called with |
| 2258 | * the result values collected from the other receivers. The broadcast will |
| 2259 | * be serialized in the same way as calling |
| 2260 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2261 | * |
| 2262 | * <p>Like {@link #sendBroadcast(Intent)}, this method is |
| 2263 | * asynchronous; it will return before |
| 2264 | * resultReceiver.onReceive() is called. |
| 2265 | * |
| 2266 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2267 | * |
| 2268 | * |
| 2269 | * @param intent The Intent to broadcast; all receivers matching this |
| 2270 | * Intent will receive the broadcast. |
| 2271 | * @param receiverPermission String naming a permissions that |
| 2272 | * a receiver must hold in order to receive your broadcast. |
| 2273 | * If null, no permission is required. |
| 2274 | * @param options (optional) Additional sending options, generated from a |
| 2275 | * {@link android.app.BroadcastOptions}. |
| 2276 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2277 | * receiver of the broadcast. |
| 2278 | * @param scheduler A custom Handler with which to schedule the |
| 2279 | * resultReceiver callback; if null it will be |
| 2280 | * scheduled in the Context's main thread. |
| 2281 | * @param initialCode An initial value for the result code. Often |
| 2282 | * Activity.RESULT_OK. |
| 2283 | * @param initialData An initial value for the result data. Often |
| 2284 | * null. |
| 2285 | * @param initialExtras An initial value for the result extras. Often |
| 2286 | * null. |
| 2287 | * @see #sendBroadcast(Intent) |
| 2288 | * @see #sendBroadcast(Intent, String) |
| 2289 | * @see #sendOrderedBroadcast(Intent, String) |
| 2290 | * @see android.content.BroadcastReceiver |
| 2291 | * @see #registerReceiver |
| 2292 | * @see android.app.Activity#RESULT_OK |
| 2293 | * @hide |
| 2294 | */ |
| 2295 | @SystemApi |
| 2296 | public abstract void sendOrderedBroadcast(@NonNull Intent intent, |
| 2297 | @Nullable String receiverPermission, @Nullable Bundle options, |
| 2298 | @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, |
| 2299 | int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras); |
| 2300 | |
| 2301 | /** |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2302 | * Like {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, android.os.Handler, |
| 2303 | * int, String, android.os.Bundle)}, but also allows specification |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2304 | * of an associated app op as per {@link android.app.AppOpsManager}. |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2305 | * @hide |
| 2306 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 2307 | @UnsupportedAppUsage |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2308 | public abstract void sendOrderedBroadcast(Intent intent, |
| 2309 | String receiverPermission, int appOp, BroadcastReceiver resultReceiver, |
| 2310 | Handler scheduler, int initialCode, String initialData, |
| 2311 | Bundle initialExtras); |
| 2312 | |
| 2313 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2314 | * Version of {@link #sendBroadcast(Intent)} that allows you to specify the |
| 2315 | * 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] | 2316 | * that are not pre-installed on the system image. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2317 | * @param intent The intent to broadcast |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 2318 | * @param user UserHandle to send the intent to. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2319 | * @see #sendBroadcast(Intent) |
| 2320 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2321 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2322 | public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent, |
| 2323 | UserHandle user); |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2324 | |
| 2325 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2326 | * Version of {@link #sendBroadcast(Intent, String)} that allows you to specify the |
| 2327 | * 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] | 2328 | * that are not pre-installed on the system image. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2329 | * |
| 2330 | * @param intent The Intent to broadcast; all receivers matching this |
| 2331 | * Intent will receive the broadcast. |
| 2332 | * @param user UserHandle to send the intent to. |
| 2333 | * @param receiverPermission (optional) String naming a permission that |
| 2334 | * a receiver must hold in order to receive your broadcast. |
| 2335 | * If null, no permission is required. |
| 2336 | * |
| 2337 | * @see #sendBroadcast(Intent, String) |
| 2338 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2339 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2340 | public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent, |
| 2341 | UserHandle user, @Nullable String receiverPermission); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2342 | |
Chad Brubaker | 52c8edc | 2016-07-25 14:30:26 -0700 | [diff] [blame] | 2343 | /** |
| 2344 | * Version of {@link #sendBroadcast(Intent, String, Bundle)} that allows you to specify the |
| 2345 | * 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] | 2346 | * that are not pre-installed on the system image. |
Chad Brubaker | 52c8edc | 2016-07-25 14:30:26 -0700 | [diff] [blame] | 2347 | * |
| 2348 | * @param intent The Intent to broadcast; all receivers matching this |
| 2349 | * Intent will receive the broadcast. |
| 2350 | * @param user UserHandle to send the intent to. |
| 2351 | * @param receiverPermission (optional) String naming a permission that |
| 2352 | * a receiver must hold in order to receive your broadcast. |
| 2353 | * If null, no permission is required. |
| 2354 | * @param options (optional) Additional sending options, generated from a |
| 2355 | * {@link android.app.BroadcastOptions}. |
| 2356 | * |
| 2357 | * @see #sendBroadcast(Intent, String, Bundle) |
| 2358 | * @hide |
| 2359 | */ |
| 2360 | @SystemApi |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2361 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Chad Brubaker | 52c8edc | 2016-07-25 14:30:26 -0700 | [diff] [blame] | 2362 | public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent, |
| 2363 | UserHandle user, @Nullable String receiverPermission, @Nullable Bundle options); |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 2364 | |
| 2365 | /** |
| 2366 | * Version of {@link #sendBroadcast(Intent, String)} that allows you to specify the |
| 2367 | * 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] | 2368 | * that are not pre-installed on the system image. |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 2369 | * |
| 2370 | * @param intent The Intent to broadcast; all receivers matching this |
| 2371 | * Intent will receive the broadcast. |
| 2372 | * @param user UserHandle to send the intent to. |
| 2373 | * @param receiverPermission (optional) String naming a permission that |
| 2374 | * a receiver must hold in order to receive your broadcast. |
| 2375 | * If null, no permission is required. |
| 2376 | * @param appOp The app op associated with the broadcast. |
| 2377 | * |
| 2378 | * @see #sendBroadcast(Intent, String) |
| 2379 | * |
| 2380 | * @hide |
| 2381 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2382 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 2383 | @UnsupportedAppUsage |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2384 | public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent, |
| 2385 | UserHandle user, @Nullable String receiverPermission, int appOp); |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 2386 | |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2387 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2388 | * Version of |
| 2389 | * {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)} |
| 2390 | * that allows you to specify the |
| 2391 | * 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] | 2392 | * that are not pre-installed on the system image. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2393 | * |
| 2394 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2395 | * |
| 2396 | * @param intent The Intent to broadcast; all receivers matching this |
| 2397 | * Intent will receive the broadcast. |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 2398 | * @param user UserHandle to send the intent to. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2399 | * @param receiverPermission String naming a permissions that |
| 2400 | * a receiver must hold in order to receive your broadcast. |
| 2401 | * If null, no permission is required. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2402 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2403 | * receiver of the broadcast. |
| 2404 | * @param scheduler A custom Handler with which to schedule the |
| 2405 | * resultReceiver callback; if null it will be |
| 2406 | * scheduled in the Context's main thread. |
| 2407 | * @param initialCode An initial value for the result code. Often |
| 2408 | * Activity.RESULT_OK. |
| 2409 | * @param initialData An initial value for the result data. Often |
| 2410 | * null. |
| 2411 | * @param initialExtras An initial value for the result extras. Often |
| 2412 | * null. |
| 2413 | * |
| 2414 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2415 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2416 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2417 | public abstract void sendOrderedBroadcastAsUser(@RequiresPermission Intent intent, |
| 2418 | UserHandle user, @Nullable String receiverPermission, BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2419 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2420 | @Nullable Bundle initialExtras); |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2421 | |
| 2422 | /** |
Amith Yamasani | 3cf7572 | 2014-05-16 12:37:29 -0700 | [diff] [blame] | 2423 | * Similar to above but takes an appOp as well, to enforce restrictions. |
| 2424 | * @see #sendOrderedBroadcastAsUser(Intent, UserHandle, String, |
| 2425 | * BroadcastReceiver, Handler, int, String, Bundle) |
| 2426 | * @hide |
| 2427 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2428 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 2429 | @UnsupportedAppUsage |
Amith Yamasani | 3cf7572 | 2014-05-16 12:37:29 -0700 | [diff] [blame] | 2430 | public abstract void sendOrderedBroadcastAsUser(Intent intent, UserHandle user, |
| 2431 | @Nullable String receiverPermission, int appOp, BroadcastReceiver resultReceiver, |
| 2432 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2433 | @Nullable Bundle initialExtras); |
| 2434 | |
| 2435 | /** |
Dianne Hackborn | fd854ee | 2015-07-13 18:00:37 -0700 | [diff] [blame] | 2436 | * Similar to above but takes an appOp as well, to enforce restrictions, and an options Bundle. |
| 2437 | * @see #sendOrderedBroadcastAsUser(Intent, UserHandle, String, |
| 2438 | * BroadcastReceiver, Handler, int, String, Bundle) |
| 2439 | * @hide |
| 2440 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2441 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 2442 | @UnsupportedAppUsage |
Dianne Hackborn | fd854ee | 2015-07-13 18:00:37 -0700 | [diff] [blame] | 2443 | public abstract void sendOrderedBroadcastAsUser(Intent intent, UserHandle user, |
| 2444 | @Nullable String receiverPermission, int appOp, @Nullable Bundle options, |
| 2445 | BroadcastReceiver resultReceiver, @Nullable Handler scheduler, int initialCode, |
| 2446 | @Nullable String initialData, @Nullable Bundle initialExtras); |
| 2447 | |
| 2448 | /** |
Jordan Liu | 5473553 | 2019-10-29 10:33:55 -0700 | [diff] [blame] | 2449 | * Version of |
| 2450 | * {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, |
| 2451 | * Bundle)} that allows you to specify the App Op to enforce restrictions on which receivers |
| 2452 | * the broadcast will be sent to. |
| 2453 | * |
| 2454 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2455 | * |
| 2456 | * @param intent The Intent to broadcast; all receivers matching this |
| 2457 | * Intent will receive the broadcast. |
| 2458 | * @param receiverPermission String naming a permissions that |
| 2459 | * a receiver must hold in order to receive your broadcast. |
| 2460 | * If null, no permission is required. |
| 2461 | * @param receiverAppOp The app op associated with the broadcast. If null, no appOp is |
| 2462 | * required. If both receiverAppOp and receiverPermission are non-null, |
| 2463 | * a receiver must have both of them to |
| 2464 | * receive the broadcast |
| 2465 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2466 | * receiver of the broadcast. |
| 2467 | * @param scheduler A custom Handler with which to schedule the |
| 2468 | * resultReceiver callback; if null it will be |
| 2469 | * scheduled in the Context's main thread. |
| 2470 | * @param initialCode An initial value for the result code. Often |
| 2471 | * Activity.RESULT_OK. |
| 2472 | * @param initialData An initial value for the result data. Often |
| 2473 | * null. |
| 2474 | * @param initialExtras An initial value for the result extras. Often |
| 2475 | * null. |
| 2476 | * |
| 2477 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2478 | */ |
Jordan Liu | 31a4da6 | 2019-11-19 11:36:34 -0800 | [diff] [blame] | 2479 | public void sendOrderedBroadcast(@NonNull Intent intent, @Nullable String receiverPermission, |
| 2480 | @Nullable String receiverAppOp, @Nullable BroadcastReceiver resultReceiver, |
| 2481 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2482 | @Nullable Bundle initialExtras) { |
Jordan Liu | 5473553 | 2019-10-29 10:33:55 -0700 | [diff] [blame] | 2483 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 2484 | } |
| 2485 | |
| 2486 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2487 | * <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] | 2488 | * Intent you are sending stays around after the broadcast is complete, |
| 2489 | * so that others can quickly retrieve that data through the return |
| 2490 | * value of {@link #registerReceiver(BroadcastReceiver, IntentFilter)}. In |
| 2491 | * all other ways, this behaves the same as |
| 2492 | * {@link #sendBroadcast(Intent)}. |
| 2493 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2494 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2495 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2496 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2497 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2498 | * desired. |
| 2499 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2500 | * @param intent The Intent to broadcast; all receivers matching this |
| 2501 | * Intent will receive the broadcast, and the Intent will be held to |
| 2502 | * be re-broadcast to future receivers. |
| 2503 | * |
| 2504 | * @see #sendBroadcast(Intent) |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2505 | * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2506 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2507 | @Deprecated |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 2508 | @RequiresPermission(android.Manifest.permission.BROADCAST_STICKY) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2509 | public abstract void sendStickyBroadcast(@RequiresPermission Intent intent); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2510 | |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2511 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2512 | * <p>Version of {@link #sendStickyBroadcast} that allows you to |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2513 | * receive data back from the broadcast. This is accomplished by |
| 2514 | * supplying your own BroadcastReceiver when calling, which will be |
| 2515 | * treated as a final receiver at the end of the broadcast -- its |
| 2516 | * {@link BroadcastReceiver#onReceive} method will be called with |
| 2517 | * the result values collected from the other receivers. The broadcast will |
| 2518 | * be serialized in the same way as calling |
| 2519 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2520 | * |
| 2521 | * <p>Like {@link #sendBroadcast(Intent)}, this method is |
| 2522 | * asynchronous; it will return before |
| 2523 | * resultReceiver.onReceive() is called. Note that the sticky data |
| 2524 | * stored is only the data you initially supply to the broadcast, not |
| 2525 | * the result of any changes made by the receivers. |
| 2526 | * |
| 2527 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2528 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2529 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2530 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2531 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2532 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2533 | * desired. |
| 2534 | * |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2535 | * @param intent The Intent to broadcast; all receivers matching this |
| 2536 | * Intent will receive the broadcast. |
| 2537 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2538 | * receiver of the broadcast. |
| 2539 | * @param scheduler A custom Handler with which to schedule the |
| 2540 | * resultReceiver callback; if null it will be |
| 2541 | * scheduled in the Context's main thread. |
| 2542 | * @param initialCode An initial value for the result code. Often |
| 2543 | * Activity.RESULT_OK. |
| 2544 | * @param initialData An initial value for the result data. Often |
| 2545 | * null. |
| 2546 | * @param initialExtras An initial value for the result extras. Often |
| 2547 | * null. |
| 2548 | * |
| 2549 | * @see #sendBroadcast(Intent) |
| 2550 | * @see #sendBroadcast(Intent, String) |
| 2551 | * @see #sendOrderedBroadcast(Intent, String) |
| 2552 | * @see #sendStickyBroadcast(Intent) |
| 2553 | * @see android.content.BroadcastReceiver |
| 2554 | * @see #registerReceiver |
| 2555 | * @see android.app.Activity#RESULT_OK |
| 2556 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2557 | @Deprecated |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 2558 | @RequiresPermission(android.Manifest.permission.BROADCAST_STICKY) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2559 | public abstract void sendStickyOrderedBroadcast(@RequiresPermission Intent intent, |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2560 | BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2561 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2562 | @Nullable Bundle initialExtras); |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2563 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2564 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2565 | * <p>Remove the data previously sent with {@link #sendStickyBroadcast}, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2566 | * so that it is as if the sticky broadcast had never happened. |
| 2567 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2568 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2569 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2570 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2571 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2572 | * desired. |
| 2573 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2574 | * @param intent The Intent that was previously broadcast. |
| 2575 | * |
| 2576 | * @see #sendStickyBroadcast |
| 2577 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2578 | @Deprecated |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 2579 | @RequiresPermission(android.Manifest.permission.BROADCAST_STICKY) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2580 | public abstract void removeStickyBroadcast(@RequiresPermission Intent intent); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2581 | |
| 2582 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2583 | * <p>Version of {@link #sendStickyBroadcast(Intent)} that allows you to specify the |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2584 | * 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] | 2585 | * that are not pre-installed on the system image. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2586 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2587 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2588 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2589 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2590 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2591 | * desired. |
| 2592 | * |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2593 | * @param intent The Intent to broadcast; all receivers matching this |
| 2594 | * Intent will receive the broadcast, and the Intent will be held to |
| 2595 | * be re-broadcast to future receivers. |
| 2596 | * @param user UserHandle to send the intent to. |
| 2597 | * |
| 2598 | * @see #sendBroadcast(Intent) |
| 2599 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2600 | @Deprecated |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2601 | @RequiresPermission(allOf = { |
| 2602 | android.Manifest.permission.INTERACT_ACROSS_USERS, |
| 2603 | android.Manifest.permission.BROADCAST_STICKY |
| 2604 | }) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2605 | public abstract void sendStickyBroadcastAsUser(@RequiresPermission Intent intent, |
| 2606 | UserHandle user); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2607 | |
| 2608 | /** |
Dianne Hackborn | e0e413e | 2015-12-09 17:22:26 -0800 | [diff] [blame] | 2609 | * @hide |
| 2610 | * This is just here for sending CONNECTIVITY_ACTION. |
| 2611 | */ |
| 2612 | @Deprecated |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2613 | @RequiresPermission(allOf = { |
| 2614 | android.Manifest.permission.INTERACT_ACROSS_USERS, |
| 2615 | android.Manifest.permission.BROADCAST_STICKY |
| 2616 | }) |
Dianne Hackborn | e0e413e | 2015-12-09 17:22:26 -0800 | [diff] [blame] | 2617 | public abstract void sendStickyBroadcastAsUser(@RequiresPermission Intent intent, |
| 2618 | UserHandle user, Bundle options); |
| 2619 | |
| 2620 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2621 | * <p>Version of |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2622 | * {@link #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)} |
| 2623 | * that allows you to specify the |
| 2624 | * 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] | 2625 | * that are not pre-installed on the system image. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2626 | * |
| 2627 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2628 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2629 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2630 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2631 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2632 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2633 | * desired. |
| 2634 | * |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2635 | * @param intent The Intent to broadcast; all receivers matching this |
| 2636 | * Intent will receive the broadcast. |
| 2637 | * @param user UserHandle to send the intent to. |
| 2638 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2639 | * receiver of the broadcast. |
| 2640 | * @param scheduler A custom Handler with which to schedule the |
| 2641 | * resultReceiver callback; if null it will be |
| 2642 | * scheduled in the Context's main thread. |
| 2643 | * @param initialCode An initial value for the result code. Often |
| 2644 | * Activity.RESULT_OK. |
| 2645 | * @param initialData An initial value for the result data. Often |
| 2646 | * null. |
| 2647 | * @param initialExtras An initial value for the result extras. Often |
| 2648 | * null. |
| 2649 | * |
| 2650 | * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle) |
| 2651 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2652 | @Deprecated |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2653 | @RequiresPermission(allOf = { |
| 2654 | android.Manifest.permission.INTERACT_ACROSS_USERS, |
| 2655 | android.Manifest.permission.BROADCAST_STICKY |
| 2656 | }) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2657 | public abstract void sendStickyOrderedBroadcastAsUser(@RequiresPermission Intent intent, |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2658 | UserHandle user, BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2659 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2660 | @Nullable Bundle initialExtras); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2661 | |
| 2662 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2663 | * <p>Version of {@link #removeStickyBroadcast(Intent)} that allows you to specify the |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2664 | * 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] | 2665 | * that are not pre-installed on the system image. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2666 | * |
| 2667 | * <p>You must hold the {@link android.Manifest.permission#BROADCAST_STICKY} |
| 2668 | * permission in order to use this API. If you do not hold that |
| 2669 | * permission, {@link SecurityException} will be thrown. |
| 2670 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2671 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2672 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2673 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2674 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2675 | * desired. |
| 2676 | * |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2677 | * @param intent The Intent that was previously broadcast. |
| 2678 | * @param user UserHandle to remove the sticky broadcast from. |
| 2679 | * |
| 2680 | * @see #sendStickyBroadcastAsUser |
| 2681 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2682 | @Deprecated |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2683 | @RequiresPermission(allOf = { |
| 2684 | android.Manifest.permission.INTERACT_ACROSS_USERS, |
| 2685 | android.Manifest.permission.BROADCAST_STICKY |
| 2686 | }) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2687 | public abstract void removeStickyBroadcastAsUser(@RequiresPermission Intent intent, |
| 2688 | UserHandle user); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2689 | |
| 2690 | /** |
Chris Tate | a34df8a2 | 2009-04-02 23:15:58 -0700 | [diff] [blame] | 2691 | * 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] | 2692 | * <var>receiver</var> will be called with any broadcast Intent that |
| 2693 | * matches <var>filter</var>, in the main application thread. |
| 2694 | * |
| 2695 | * <p>The system may broadcast Intents that are "sticky" -- these stay |
Kweku Adams | 86f39a4 | 2016-11-16 12:50:38 -0800 | [diff] [blame] | 2696 | * 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] | 2697 | * registrations. If your IntentFilter matches one of these sticky |
| 2698 | * Intents, that Intent will be returned by this function |
| 2699 | * <strong>and</strong> sent to your <var>receiver</var> as if it had just |
| 2700 | * been broadcast. |
| 2701 | * |
| 2702 | * <p>There may be multiple sticky Intents that match <var>filter</var>, |
| 2703 | * in which case each of these will be sent to <var>receiver</var>. In |
| 2704 | * this case, only one of these can be returned directly by the function; |
| 2705 | * which of these that is returned is arbitrarily decided by the system. |
| 2706 | * |
| 2707 | * <p>If you know the Intent your are registering for is sticky, you can |
| 2708 | * supply null for your <var>receiver</var>. In this case, no receiver is |
| 2709 | * registered -- the function simply returns the sticky Intent that |
| 2710 | * matches <var>filter</var>. In the case of multiple matches, the same |
| 2711 | * rules as described above apply. |
| 2712 | * |
| 2713 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2714 | * |
Dianne Hackborn | 6c418d5 | 2011-06-29 14:05:33 -0700 | [diff] [blame] | 2715 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 2716 | * registered with this method will correctly respect the |
| 2717 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 2718 | * Prior to that, it would be ignored and delivered to all matching registered |
| 2719 | * receivers. Be careful if using this for security.</p> |
| 2720 | * |
Chris Tate | a34df8a2 | 2009-04-02 23:15:58 -0700 | [diff] [blame] | 2721 | * <p class="note">Note: this method <em>cannot be called from a |
| 2722 | * {@link BroadcastReceiver} component;</em> that is, from a BroadcastReceiver |
| 2723 | * that is declared in an application's manifest. It is okay, however, to call |
| 2724 | * this method from another BroadcastReceiver that has itself been registered |
| 2725 | * at run time with {@link #registerReceiver}, since the lifetime of such a |
| 2726 | * 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] | 2727 | * |
| 2728 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2729 | * @param filter Selects the Intent broadcasts to be received. |
| 2730 | * |
| 2731 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2732 | * or null if there are none. |
| 2733 | * |
| 2734 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
| 2735 | * @see #sendBroadcast |
| 2736 | * @see #unregisterReceiver |
| 2737 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2738 | @Nullable |
| 2739 | public abstract Intent registerReceiver(@Nullable BroadcastReceiver receiver, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2740 | IntentFilter filter); |
| 2741 | |
| 2742 | /** |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2743 | * Register to receive intent broadcasts, with the receiver optionally being |
| 2744 | * exposed to Instant Apps. See |
| 2745 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter)} for more |
| 2746 | * information. By default Instant Apps cannot interact with receivers in other |
| 2747 | * applications, this allows you to expose a receiver that Instant Apps can |
| 2748 | * interact with. |
| 2749 | * |
| 2750 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2751 | * |
| 2752 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 2753 | * registered with this method will correctly respect the |
| 2754 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 2755 | * Prior to that, it would be ignored and delivered to all matching registered |
| 2756 | * receivers. Be careful if using this for security.</p> |
| 2757 | * |
| 2758 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2759 | * @param filter Selects the Intent broadcasts to be received. |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2760 | * @param flags Additional options for the receiver. May be 0 or |
| 2761 | * {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2762 | * |
| 2763 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2764 | * or null if there are none. |
| 2765 | * |
| 2766 | * @see #registerReceiver(BroadcastReceiver, IntentFilter) |
| 2767 | * @see #sendBroadcast |
| 2768 | * @see #unregisterReceiver |
| 2769 | */ |
| 2770 | @Nullable |
| 2771 | public abstract Intent registerReceiver(@Nullable BroadcastReceiver receiver, |
| 2772 | IntentFilter filter, |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2773 | @RegisterReceiverFlags int flags); |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2774 | |
| 2775 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2776 | * Register to receive intent broadcasts, to run in the context of |
| 2777 | * <var>scheduler</var>. See |
| 2778 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter)} for more |
| 2779 | * information. This allows you to enforce permissions on who can |
| 2780 | * broadcast intents to your receiver, or have the receiver run in |
| 2781 | * a different thread than the main application thread. |
| 2782 | * |
| 2783 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2784 | * |
Dianne Hackborn | 6c418d5 | 2011-06-29 14:05:33 -0700 | [diff] [blame] | 2785 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 2786 | * registered with this method will correctly respect the |
| 2787 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 2788 | * Prior to that, it would be ignored and delivered to all matching registered |
| 2789 | * receivers. Be careful if using this for security.</p> |
| 2790 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2791 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2792 | * @param filter Selects the Intent broadcasts to be received. |
| 2793 | * @param broadcastPermission String naming a permissions that a |
| 2794 | * broadcaster must hold in order to send an Intent to you. If null, |
| 2795 | * no permission is required. |
| 2796 | * @param scheduler Handler identifying the thread that will receive |
| 2797 | * the Intent. If null, the main thread of the process will be used. |
| 2798 | * |
| 2799 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2800 | * or null if there are none. |
| 2801 | * |
| 2802 | * @see #registerReceiver(BroadcastReceiver, IntentFilter) |
| 2803 | * @see #sendBroadcast |
| 2804 | * @see #unregisterReceiver |
| 2805 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2806 | @Nullable |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2807 | public abstract Intent registerReceiver(BroadcastReceiver receiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2808 | IntentFilter filter, @Nullable String broadcastPermission, |
| 2809 | @Nullable Handler scheduler); |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2810 | |
| 2811 | /** |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2812 | * Register to receive intent broadcasts, to run in the context of |
| 2813 | * <var>scheduler</var>. See |
| 2814 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter, int)} and |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2815 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler)} |
| 2816 | * for more information. |
| 2817 | * |
| 2818 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2819 | * |
| 2820 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 2821 | * registered with this method will correctly respect the |
| 2822 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 2823 | * Prior to that, it would be ignored and delivered to all matching registered |
| 2824 | * receivers. Be careful if using this for security.</p> |
| 2825 | * |
| 2826 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2827 | * @param filter Selects the Intent broadcasts to be received. |
| 2828 | * @param broadcastPermission String naming a permissions that a |
| 2829 | * broadcaster must hold in order to send an Intent to you. If null, |
| 2830 | * no permission is required. |
| 2831 | * @param scheduler Handler identifying the thread that will receive |
| 2832 | * 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] | 2833 | * @param flags Additional options for the receiver. May be 0 or |
| 2834 | * {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2835 | * |
| 2836 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2837 | * or null if there are none. |
| 2838 | * |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2839 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, int) |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2840 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
| 2841 | * @see #sendBroadcast |
| 2842 | * @see #unregisterReceiver |
| 2843 | */ |
| 2844 | @Nullable |
| 2845 | public abstract Intent registerReceiver(BroadcastReceiver receiver, |
| 2846 | IntentFilter filter, @Nullable String broadcastPermission, |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2847 | @Nullable Handler scheduler, @RegisterReceiverFlags int flags); |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2848 | |
| 2849 | /** |
Meng Wang | 3f9e036 | 2019-11-05 10:43:45 -0800 | [diff] [blame] | 2850 | * Same as {@link #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler)} |
| 2851 | * but this receiver will receive broadcasts that are sent to all users. The receiver can |
| 2852 | * use {@link BroadcastReceiver#getSendingUser} to determine on which user the broadcast |
| 2853 | * was sent. |
| 2854 | * |
| 2855 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2856 | * @param filter Selects the Intent broadcasts to be received. |
| 2857 | * @param broadcastPermission String naming a permissions that a |
| 2858 | * broadcaster must hold in order to send an Intent to you. If {@code null}, |
| 2859 | * no permission is required. |
| 2860 | * @param scheduler Handler identifying the thread that will receive |
| 2861 | * the Intent. If {@code null}, the main thread of the process will be used. |
| 2862 | * |
| 2863 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2864 | * or {@code null} if there are none. |
| 2865 | * |
| 2866 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
| 2867 | * @see #sendBroadcast |
| 2868 | * @see #unregisterReceiver |
| 2869 | * @hide |
| 2870 | */ |
| 2871 | @Nullable |
| 2872 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) |
| 2873 | @SystemApi |
| 2874 | public Intent registerReceiverForAllUsers(@Nullable BroadcastReceiver receiver, |
| 2875 | @NonNull IntentFilter filter, @Nullable String broadcastPermission, |
| 2876 | @Nullable Handler scheduler) { |
| 2877 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 2878 | } |
| 2879 | |
| 2880 | /** |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2881 | * @hide |
| 2882 | * Same as {@link #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
| 2883 | * but for a specific user. This receiver will receiver broadcasts that |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2884 | * are sent to the requested user. |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2885 | * |
| 2886 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2887 | * @param user UserHandle to send the intent to. |
| 2888 | * @param filter Selects the Intent broadcasts to be received. |
| 2889 | * @param broadcastPermission String naming a permissions that a |
| 2890 | * broadcaster must hold in order to send an Intent to you. If null, |
| 2891 | * no permission is required. |
| 2892 | * @param scheduler Handler identifying the thread that will receive |
| 2893 | * the Intent. If null, the main thread of the process will be used. |
| 2894 | * |
| 2895 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2896 | * or null if there are none. |
| 2897 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 2898 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2899 | * @see #sendBroadcast |
| 2900 | * @see #unregisterReceiver |
| 2901 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2902 | @Nullable |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2903 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 2904 | @UnsupportedAppUsage |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2905 | public abstract Intent registerReceiverAsUser(BroadcastReceiver receiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2906 | UserHandle user, IntentFilter filter, @Nullable String broadcastPermission, |
| 2907 | @Nullable Handler scheduler); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2908 | |
| 2909 | /** |
| 2910 | * Unregister a previously registered BroadcastReceiver. <em>All</em> |
| 2911 | * filters that have been registered for this BroadcastReceiver will be |
| 2912 | * removed. |
| 2913 | * |
| 2914 | * @param receiver The BroadcastReceiver to unregister. |
| 2915 | * |
| 2916 | * @see #registerReceiver |
| 2917 | */ |
| 2918 | public abstract void unregisterReceiver(BroadcastReceiver receiver); |
| 2919 | |
| 2920 | /** |
| 2921 | * Request that a given application service be started. The Intent |
Hans Boehm | fb9f6ac | 2016-05-05 13:09:28 -0700 | [diff] [blame] | 2922 | * should either contain the complete class name of a specific service |
| 2923 | * implementation to start, or a specific package name to target. If the |
| 2924 | * Intent is less specified, it logs a warning about this. In this case any of the |
| 2925 | * multiple matching services may be used. If this service |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2926 | * is not already running, it will be instantiated and started (creating a |
| 2927 | * process for it if needed); if it is running then it remains running. |
| 2928 | * |
| 2929 | * <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] | 2930 | * 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] | 2931 | * with the <var>intent</var> given here. This provides a convenient way |
| 2932 | * to submit jobs to a service without having to bind and call on to its |
| 2933 | * interface. |
| 2934 | * |
| 2935 | * <p>Using startService() overrides the default service lifetime that is |
| 2936 | * managed by {@link #bindService}: it requires the service to remain |
| 2937 | * running until {@link #stopService} is called, regardless of whether |
| 2938 | * any clients are connected to it. Note that calls to startService() |
Hans Boehm | fb9f6ac | 2016-05-05 13:09:28 -0700 | [diff] [blame] | 2939 | * 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] | 2940 | * a single call to {@link #stopService} will stop it. |
| 2941 | * |
| 2942 | * <p>The system attempts to keep running services around as much as |
| 2943 | * possible. The only time they should be stopped is if the current |
| 2944 | * foreground application is using so many resources that the service needs |
| 2945 | * to be killed. If any errors happen in the service's process, it will |
| 2946 | * automatically be restarted. |
| 2947 | * |
| 2948 | * <p>This function will throw {@link SecurityException} if you do not |
| 2949 | * have permission to start the given service. |
| 2950 | * |
Chris Craik | 1e35352 | 2016-04-18 10:20:50 -0700 | [diff] [blame] | 2951 | * <p class="note"><strong>Note:</strong> Each call to startService() |
| 2952 | * results in significant work done by the system to manage service |
| 2953 | * lifecycle surrounding the processing of the intent, which can take |
| 2954 | * multiple milliseconds of CPU time. Due to this cost, startService() |
| 2955 | * should not be used for frequent intent delivery to a service, and only |
| 2956 | * for scheduling significant work. Use {@link #bindService bound services} |
| 2957 | * for high frequency calls. |
| 2958 | * </p> |
| 2959 | * |
Mark Lu | 94ebbe0 | 2016-12-13 16:29:51 -0800 | [diff] [blame] | 2960 | * @param service Identifies the service to be started. The Intent must be |
| 2961 | * fully explicit (supplying a component name). Additional values |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2962 | * may be included in the Intent extras to supply arguments along with |
| 2963 | * this specific start call. |
| 2964 | * |
| 2965 | * @return If the service is being started or is already running, the |
| 2966 | * {@link ComponentName} of the actual service that was started is |
| 2967 | * returned; else if the service does not exist null is returned. |
| 2968 | * |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2969 | * @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] | 2970 | * or the service can not be found. |
| 2971 | * @throws IllegalStateException If the application is in a state where the service |
| 2972 | * 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] | 2973 | * |
| 2974 | * @see #stopService |
| 2975 | * @see #bindService |
| 2976 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2977 | @Nullable |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2978 | public abstract ComponentName startService(Intent service); |
| 2979 | |
| 2980 | /** |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 2981 | * Similar to {@link #startService(Intent)}, but with an implicit promise that the |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 2982 | * Service will call {@link android.app.Service#startForeground(int, android.app.Notification) |
| 2983 | * 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] | 2984 | * an amount of time comparable to the ANR interval to do this, otherwise the system |
| 2985 | * will automatically stop the service and declare the app ANR. |
| 2986 | * |
| 2987 | * <p>Unlike the ordinary {@link #startService(Intent)}, this method can be used |
| 2988 | * at any time, regardless of whether the app hosting the service is in a foreground |
| 2989 | * state. |
| 2990 | * |
| 2991 | * @param service Identifies the service to be started. The Intent must be |
| 2992 | * fully explicit (supplying a component name). Additional values |
| 2993 | * may be included in the Intent extras to supply arguments along with |
| 2994 | * this specific start call. |
| 2995 | * |
| 2996 | * @return If the service is being started or is already running, the |
| 2997 | * {@link ComponentName} of the actual service that was started is |
| 2998 | * returned; else if the service does not exist null is returned. |
| 2999 | * |
| 3000 | * @throws SecurityException If the caller does not have permission to access the service |
| 3001 | * or the service can not be found. |
| 3002 | * |
| 3003 | * @see #stopService |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 3004 | * @see android.app.Service#startForeground(int, android.app.Notification) |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 3005 | */ |
| 3006 | @Nullable |
| 3007 | public abstract ComponentName startForegroundService(Intent service); |
| 3008 | |
| 3009 | /** |
| 3010 | * @hide like {@link #startForegroundService(Intent)} but for a specific user. |
| 3011 | */ |
| 3012 | @Nullable |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 3013 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 3014 | public abstract ComponentName startForegroundServiceAsUser(Intent service, UserHandle user); |
| 3015 | |
| 3016 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3017 | * Request that a given application service be stopped. If the service is |
| 3018 | * not running, nothing happens. Otherwise it is stopped. Note that calls |
| 3019 | * to startService() are not counted -- this stops the service no matter |
| 3020 | * how many times it was started. |
| 3021 | * |
| 3022 | * <p>Note that if a stopped service still has {@link ServiceConnection} |
| 3023 | * objects bound to it with the {@link #BIND_AUTO_CREATE} set, it will |
| 3024 | * not be destroyed until all of these bindings are removed. See |
| 3025 | * the {@link android.app.Service} documentation for more details on a |
| 3026 | * service's lifecycle. |
| 3027 | * |
| 3028 | * <p>This function will throw {@link SecurityException} if you do not |
| 3029 | * have permission to stop the given service. |
| 3030 | * |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 3031 | * @param service Description of the service to be stopped. The Intent must be either |
| 3032 | * fully explicit (supplying a component name) or specify a specific package |
kopriva | 219f7dc | 2018-10-09 13:42:28 -0700 | [diff] [blame] | 3033 | * name it is targeted to. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3034 | * |
| 3035 | * @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] | 3036 | * 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] | 3037 | * |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 3038 | * @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] | 3039 | * or the service can not be found. |
| 3040 | * @throws IllegalStateException If the application is in a state where the service |
| 3041 | * 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] | 3042 | * |
| 3043 | * @see #startService |
| 3044 | */ |
| 3045 | public abstract boolean stopService(Intent service); |
| 3046 | |
| 3047 | /** |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 3048 | * @hide like {@link #startService(Intent)} but for a specific user. |
| 3049 | */ |
Christopher Tate | 42a386b | 2016-11-07 12:21:21 -0800 | [diff] [blame] | 3050 | @Nullable |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 3051 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 3052 | @UnsupportedAppUsage |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 3053 | public abstract ComponentName startServiceAsUser(Intent service, UserHandle user); |
| 3054 | |
| 3055 | /** |
| 3056 | * @hide like {@link #stopService(Intent)} but for a specific user. |
| 3057 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 3058 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 3059 | public abstract boolean stopServiceAsUser(Intent service, UserHandle user); |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 3060 | |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 3061 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3062 | * Connect to an application service, creating it if needed. This defines |
| 3063 | * a dependency between your application and the service. The given |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 3064 | * <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] | 3065 | * told if it dies and restarts. The service will be considered required |
| 3066 | * by the system only for as long as the calling context exists. For |
| 3067 | * example, if this Context is an Activity that is stopped, the service will |
| 3068 | * not be required to continue running until the Activity is resumed. |
| 3069 | * |
Christopher Tate | 5d73b6d | 2017-10-06 16:15:34 -0700 | [diff] [blame] | 3070 | * <p>If the service does not support binding, it may return {@code null} from |
| 3071 | * its {@link android.app.Service#onBind(Intent) onBind()} method. If it does, then |
| 3072 | * the ServiceConnection's |
| 3073 | * {@link ServiceConnection#onNullBinding(ComponentName) onNullBinding()} method |
| 3074 | * will be invoked instead of |
| 3075 | * {@link ServiceConnection#onServiceConnected(ComponentName, IBinder) onServiceConnected()}. |
| 3076 | * |
| 3077 | * <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] | 3078 | * have permission to bind to the given service. |
| 3079 | * |
Christopher Tate | 5d73b6d | 2017-10-06 16:15:34 -0700 | [diff] [blame] | 3080 | * <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] | 3081 | * {@link BroadcastReceiver} component</em>. A pattern you can use to |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 3082 | * 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] | 3083 | * {@link #startService} with the arguments containing the command to be |
| 3084 | * sent, with the service calling its |
| 3085 | * {@link android.app.Service#stopSelf(int)} method when done executing |
| 3086 | * that command. See the API demo App/Service/Service Start Arguments |
| 3087 | * Controller for an illustration of this. It is okay, however, to use |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 3088 | * 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] | 3089 | * {@link #registerReceiver}, since the lifetime of this BroadcastReceiver |
| 3090 | * is tied to another object (the one that registered it).</p> |
| 3091 | * |
Mark Lu | 94ebbe0 | 2016-12-13 16:29:51 -0800 | [diff] [blame] | 3092 | * @param service Identifies the service to connect to. The Intent must |
| 3093 | * specify an explicit component name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3094 | * @param conn Receives information as the service is started and stopped. |
Christopher Tate | 79b3317 | 2012-06-18 14:54:21 -0700 | [diff] [blame] | 3095 | * This must be a valid ServiceConnection object; it must not be null. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3096 | * @param flags Operation options for the binding. May be 0, |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 3097 | * {@link #BIND_AUTO_CREATE}, {@link #BIND_DEBUG_UNBIND}, |
| 3098 | * {@link #BIND_NOT_FOREGROUND}, {@link #BIND_ABOVE_CLIENT}, |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3099 | * {@link #BIND_ALLOW_OOM_MANAGEMENT}, {@link #BIND_WAIVE_PRIORITY}. |
| 3100 | * {@link #BIND_IMPORTANT}, or |
| 3101 | * {@link #BIND_ADJUST_WITH_ACTIVITY}. |
Kevin Hufnagle | 34acbc9b | 2017-06-29 15:58:48 -0700 | [diff] [blame] | 3102 | * @return {@code true} if the system is in the process of bringing up a |
| 3103 | * service that your client has permission to bind to; {@code false} |
| 3104 | * if the system couldn't find the service or if your client doesn't |
| 3105 | * have permission to bind to it. If this value is {@code true}, you |
| 3106 | * should later call {@link #unbindService} to release the |
| 3107 | * connection. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3108 | * |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 3109 | * @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] | 3110 | * or the service can not be found. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3111 | * |
| 3112 | * @see #unbindService |
| 3113 | * @see #startService |
| 3114 | * @see #BIND_AUTO_CREATE |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3115 | * @see #BIND_DEBUG_UNBIND |
| 3116 | * @see #BIND_NOT_FOREGROUND |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3117 | * @see #BIND_ABOVE_CLIENT |
| 3118 | * @see #BIND_ALLOW_OOM_MANAGEMENT |
| 3119 | * @see #BIND_WAIVE_PRIORITY |
| 3120 | * @see #BIND_IMPORTANT |
| 3121 | * @see #BIND_ADJUST_WITH_ACTIVITY |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3122 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 3123 | public abstract boolean bindService(@RequiresPermission Intent service, |
| 3124 | @NonNull ServiceConnection conn, @BindServiceFlags int flags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3125 | |
| 3126 | /** |
Bo Liu | 58a5766 | 2019-03-06 20:21:45 +0000 | [diff] [blame] | 3127 | * Same as {@link #bindService(Intent, ServiceConnection, int)} with executor to control |
| 3128 | * ServiceConnection callbacks. |
| 3129 | * @param executor Callbacks on ServiceConnection will be called on executor. Must use same |
| 3130 | * instance for the same instance of ServiceConnection. |
| 3131 | */ |
| 3132 | public boolean bindService(@RequiresPermission @NonNull Intent service, |
| 3133 | @BindServiceFlags int flags, @NonNull @CallbackExecutor Executor executor, |
| 3134 | @NonNull ServiceConnection conn) { |
| 3135 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 3136 | } |
| 3137 | |
| 3138 | /** |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3139 | * Variation of {@link #bindService} that, in the specific case of isolated |
| 3140 | * services, allows the caller to generate multiple instances of a service |
Dianne Hackborn | cc67f96 | 2019-04-29 16:32:44 -0700 | [diff] [blame] | 3141 | * from a single component declaration. In other words, you can use this to bind |
| 3142 | * to a service that has specified {@link android.R.attr#isolatedProcess} and, in |
| 3143 | * addition to the existing behavior of running in an isolated process, you can |
| 3144 | * also through the arguments here have the system bring up multiple concurrent |
| 3145 | * processes hosting their own instances of that service. The <var>instanceName</var> |
| 3146 | * you provide here identifies the different instances, and you can use |
| 3147 | * {@link #updateServiceGroup(ServiceConnection, int, int)} to tell the system how it |
| 3148 | * should manage each of these instances. |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3149 | * |
| 3150 | * @param service Identifies the service to connect to. The Intent must |
| 3151 | * specify an explicit component name. |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3152 | * @param flags Operation options for the binding as per {@link #bindService}. |
| 3153 | * @param instanceName Unique identifier for the service instance. Each unique |
Robert Sesek | e3a5bc6 | 2019-04-22 17:43:03 -0400 | [diff] [blame] | 3154 | * name here will result in a different service instance being created. Identifiers |
| 3155 | * must only contain ASCII letters, digits, underscores, and periods. |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3156 | * @return Returns success of binding as per {@link #bindService}. |
Bo Liu | 58a5766 | 2019-03-06 20:21:45 +0000 | [diff] [blame] | 3157 | * @param executor Callbacks on ServiceConnection will be called on executor. |
| 3158 | * Must use same instance for the same instance of ServiceConnection. |
| 3159 | * @param conn Receives information as the service is started and stopped. |
| 3160 | * This must be a valid ServiceConnection object; it must not be null. |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3161 | * |
| 3162 | * @throws SecurityException If the caller does not have permission to access the service |
Robert Sesek | e3a5bc6 | 2019-04-22 17:43:03 -0400 | [diff] [blame] | 3163 | * @throws IllegalArgumentException If the instanceName is invalid. |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3164 | * |
| 3165 | * @see #bindService |
Dianne Hackborn | cc67f96 | 2019-04-29 16:32:44 -0700 | [diff] [blame] | 3166 | * @see #updateServiceGroup |
| 3167 | * @see android.R.attr#isolatedProcess |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3168 | */ |
Adrian Roos | ebc927c | 2019-02-28 16:21:18 +0100 | [diff] [blame] | 3169 | public boolean bindIsolatedService(@RequiresPermission @NonNull Intent service, |
Bo Liu | 58a5766 | 2019-03-06 20:21:45 +0000 | [diff] [blame] | 3170 | @BindServiceFlags int flags, @NonNull String instanceName, |
| 3171 | @NonNull @CallbackExecutor Executor executor, @NonNull ServiceConnection conn) { |
Adrian Roos | fe6aeaf | 2019-01-22 16:58:56 +0100 | [diff] [blame] | 3172 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 3173 | } |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3174 | |
| 3175 | /** |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 3176 | * Same as {@link #bindService(Intent, ServiceConnection, int)}, but with an explicit userHandle |
Amith Yamasani | 37ce3a8 | 2012-02-06 12:04:42 -0800 | [diff] [blame] | 3177 | * argument for use by system server and other multi-user aware code. |
| 3178 | * @hide |
| 3179 | */ |
Amith Yamasani | c85029f | 2014-09-11 16:47:17 -0700 | [diff] [blame] | 3180 | @SystemApi |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3181 | @SuppressWarnings("unused") |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 3182 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 3183 | public boolean bindServiceAsUser(@RequiresPermission Intent service, ServiceConnection conn, |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3184 | int flags, UserHandle user) { |
Amith Yamasani | 37ce3a8 | 2012-02-06 12:04:42 -0800 | [diff] [blame] | 3185 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 3186 | } |
| 3187 | |
| 3188 | /** |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3189 | * Same as {@link #bindServiceAsUser(Intent, ServiceConnection, int, UserHandle)}, but with an |
Adrian Roos | 691546e | 2016-02-09 10:13:41 -0800 | [diff] [blame] | 3190 | * explicit non-null Handler to run the ServiceConnection callbacks on. |
| 3191 | * |
| 3192 | * @hide |
| 3193 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 3194 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Mathew Inwood | 7bcc174 | 2019-07-04 11:39:42 +0100 | [diff] [blame] | 3195 | @UnsupportedAppUsage(trackingBug = 136728678) |
Adrian Roos | 691546e | 2016-02-09 10:13:41 -0800 | [diff] [blame] | 3196 | public boolean bindServiceAsUser(Intent service, ServiceConnection conn, int flags, |
| 3197 | Handler handler, UserHandle user) { |
| 3198 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 3199 | } |
| 3200 | |
| 3201 | /** |
Dianne Hackborn | a631d56 | 2018-11-20 15:58:15 -0800 | [diff] [blame] | 3202 | * For a service previously bound with {@link #bindService} or a related method, change |
| 3203 | * how the system manages that service's process in relation to other processes. This |
| 3204 | * doesn't modify the original bind flags that were passed in when binding, but adjusts |
| 3205 | * how the process will be managed in some cases based on those flags. Currently only |
| 3206 | * works on isolated processes (will be ignored for non-isolated processes). |
| 3207 | * |
Dianne Hackborn | 2f55e5a | 2018-11-30 16:31:31 -0800 | [diff] [blame] | 3208 | * <p>Note that this call does not take immediate effect, but will be applied the next |
| 3209 | * time the impacted process is adjusted for some other reason. Typically you would |
| 3210 | * call this before then calling a new {@link #bindIsolatedService} on the service |
| 3211 | * of interest, with that binding causing the process to be shuffled accordingly.</p> |
| 3212 | * |
Dianne Hackborn | a631d56 | 2018-11-20 15:58:15 -0800 | [diff] [blame] | 3213 | * @param conn The connection interface previously supplied to bindService(). This |
| 3214 | * parameter must not be null. |
| 3215 | * @param group A group to put this connection's process in. Upon calling here, this |
| 3216 | * will override any previous group that was set for that process. The group |
| 3217 | * tells the system about processes that are logically grouped together, so |
| 3218 | * should be managed as one unit of importance (such as when being considered |
| 3219 | * a recently used app). All processes in the same app with the same group |
| 3220 | * are considered to be related. Supplying 0 reverts to the default behavior |
| 3221 | * of not grouping. |
| 3222 | * @param importance Additional importance of the processes within a group. Upon calling |
Dianne Hackborn | cc67f96 | 2019-04-29 16:32:44 -0700 | [diff] [blame] | 3223 | * here, this will override any previous importance that was set for that |
| 3224 | * process. The most important process is 0, and higher values are |
| 3225 | * successively less important. You can view this as describing how |
| 3226 | * to order the processes in an array, with the processes at the end of |
| 3227 | * the array being the least important. This value has no meaning besides |
| 3228 | * indicating how processes should be ordered in that array one after the |
| 3229 | * other. This provides a way to fine-tune the system's process killing, |
| 3230 | * guiding it to kill processes at the end of the array first. |
| 3231 | * |
| 3232 | * @see #bindIsolatedService |
Dianne Hackborn | a631d56 | 2018-11-20 15:58:15 -0800 | [diff] [blame] | 3233 | */ |
Adrian Roos | fe6aeaf | 2019-01-22 16:58:56 +0100 | [diff] [blame] | 3234 | public void updateServiceGroup(@NonNull ServiceConnection conn, int group, |
| 3235 | int importance) { |
| 3236 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 3237 | } |
Dianne Hackborn | a631d56 | 2018-11-20 15:58:15 -0800 | [diff] [blame] | 3238 | |
| 3239 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3240 | * Disconnect from an application service. You will no longer receive |
| 3241 | * calls as the service is restarted, and the service is now allowed to |
| 3242 | * stop at any time. |
| 3243 | * |
| 3244 | * @param conn The connection interface previously supplied to |
Christopher Tate | 79b3317 | 2012-06-18 14:54:21 -0700 | [diff] [blame] | 3245 | * bindService(). This parameter must not be null. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3246 | * |
| 3247 | * @see #bindService |
| 3248 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3249 | public abstract void unbindService(@NonNull ServiceConnection conn); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3250 | |
| 3251 | /** |
| 3252 | * Start executing an {@link android.app.Instrumentation} class. The given |
| 3253 | * Instrumentation component will be run by killing its target application |
| 3254 | * (if currently running), starting the target process, instantiating the |
| 3255 | * instrumentation component, and then letting it drive the application. |
| 3256 | * |
| 3257 | * <p>This function is not synchronous -- it returns as soon as the |
| 3258 | * instrumentation has started and while it is running. |
| 3259 | * |
| 3260 | * <p>Instrumentation is normally only allowed to run against a package |
| 3261 | * that is either unsigned or signed with a signature that the |
| 3262 | * the instrumentation package is also signed with (ensuring the target |
| 3263 | * trusts the instrumentation). |
| 3264 | * |
| 3265 | * @param className Name of the Instrumentation component to be run. |
| 3266 | * @param profileFile Optional path to write profiling data as the |
| 3267 | * instrumentation runs, or null for no profiling. |
| 3268 | * @param arguments Additional optional arguments to pass to the |
| 3269 | * instrumentation, or null. |
| 3270 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3271 | * @return {@code true} if the instrumentation was successfully started, |
| 3272 | * else {@code false} if it could not be found. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3273 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3274 | public abstract boolean startInstrumentation(@NonNull ComponentName className, |
| 3275 | @Nullable String profileFile, @Nullable Bundle arguments); |
| 3276 | |
| 3277 | /** @hide */ |
Jeff Sharkey | 5db9a91 | 2017-12-08 17:32:32 -0700 | [diff] [blame] | 3278 | @StringDef(suffix = { "_SERVICE" }, value = { |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3279 | POWER_SERVICE, |
| 3280 | WINDOW_SERVICE, |
| 3281 | LAYOUT_INFLATER_SERVICE, |
| 3282 | ACCOUNT_SERVICE, |
| 3283 | ACTIVITY_SERVICE, |
| 3284 | ALARM_SERVICE, |
| 3285 | NOTIFICATION_SERVICE, |
| 3286 | ACCESSIBILITY_SERVICE, |
| 3287 | CAPTIONING_SERVICE, |
| 3288 | KEYGUARD_SERVICE, |
| 3289 | LOCATION_SERVICE, |
| 3290 | //@hide: COUNTRY_DETECTOR, |
| 3291 | SEARCH_SERVICE, |
| 3292 | SENSOR_SERVICE, |
Chad Brubaker | 90f391f | 2018-10-19 10:26:19 -0700 | [diff] [blame] | 3293 | SENSOR_PRIVACY_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3294 | STORAGE_SERVICE, |
Jeff Sharkey | e8cece9 | 2017-01-04 11:33:33 -0700 | [diff] [blame] | 3295 | STORAGE_STATS_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3296 | WALLPAPER_SERVICE, |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 3297 | TIME_ZONE_RULES_MANAGER_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3298 | VIBRATOR_SERVICE, |
| 3299 | //@hide: STATUS_BAR_SERVICE, |
| 3300 | CONNECTIVITY_SERVICE, |
Chalard Jean | 8c141bd | 2018-12-04 20:20:56 +0900 | [diff] [blame] | 3301 | //@hide: IP_MEMORY_STORE_SERVICE, |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 3302 | IPSEC_SERVICE, |
Benedict Wong | 99a4841 | 2018-11-09 14:45:34 -0800 | [diff] [blame] | 3303 | TEST_NETWORK_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3304 | //@hide: UPDATE_LOCK_SERVICE, |
| 3305 | //@hide: NETWORKMANAGEMENT_SERVICE, |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3306 | NETWORK_STATS_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3307 | //@hide: NETWORK_POLICY_SERVICE, |
| 3308 | WIFI_SERVICE, |
Etan Cohen | 0413327 | 2016-10-26 11:22:06 -0700 | [diff] [blame] | 3309 | WIFI_AWARE_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3310 | WIFI_P2P_SERVICE, |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 3311 | WIFI_SCANNING_SERVICE, |
Robert Quattlebaum | 87a7104 | 2017-05-15 15:45:20 -0700 | [diff] [blame] | 3312 | //@hide: LOWPAN_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3313 | //@hide: WIFI_RTT_SERVICE, |
Lorenzo Colitti | bd8a374 | 2014-05-22 11:51:27 -0700 | [diff] [blame] | 3314 | //@hide: ETHERNET_SERVICE, |
Etan Cohen | 46efb48 | 2017-12-07 13:50:57 -0800 | [diff] [blame] | 3315 | WIFI_RTT_RANGING_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3316 | NSD_SERVICE, |
| 3317 | AUDIO_SERVICE, |
Ilya Matyukhin | e4675b3 | 2019-11-07 16:07:19 -0800 | [diff] [blame] | 3318 | AUTH_SERVICE, |
Jim Miller | ce7eb6d | 2015-04-03 19:29:13 -0700 | [diff] [blame] | 3319 | FINGERPRINT_SERVICE, |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 3320 | //@hide: FACE_SERVICE, |
Kevin Chyn | 05c2150 | 2018-09-18 13:07:19 -0700 | [diff] [blame] | 3321 | BIOMETRIC_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3322 | MEDIA_ROUTER_SERVICE, |
| 3323 | TELEPHONY_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3324 | TELEPHONY_SUBSCRIPTION_SERVICE, |
Jonathan Basseri | 9a1c9b6 | 2015-02-25 13:01:52 -0800 | [diff] [blame] | 3325 | CARRIER_CONFIG_SERVICE, |
hyunhae.lee | 75fdafa | 2019-07-19 22:08:41 +0900 | [diff] [blame] | 3326 | EUICC_SERVICE, |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 3327 | TELECOM_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3328 | CLIPBOARD_SERVICE, |
| 3329 | INPUT_METHOD_SERVICE, |
| 3330 | TEXT_SERVICES_MANAGER_SERVICE, |
Abodunrinwa Toki | 3de110b | 2017-05-04 16:29:04 +0100 | [diff] [blame] | 3331 | TEXT_CLASSIFICATION_SERVICE, |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 3332 | APPWIDGET_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3333 | //@hide: VOICE_INTERACTION_MANAGER_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3334 | //@hide: BACKUP_SERVICE, |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 3335 | ROLLBACK_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3336 | DROPBOX_SERVICE, |
Dianne Hackborn | 1958e5e | 2015-06-12 18:11:41 -0700 | [diff] [blame] | 3337 | //@hide: DEVICE_IDLE_CONTROLLER, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3338 | DEVICE_POLICY_SERVICE, |
| 3339 | UI_MODE_SERVICE, |
| 3340 | DOWNLOAD_SERVICE, |
| 3341 | NFC_SERVICE, |
| 3342 | BLUETOOTH_SERVICE, |
| 3343 | //@hide: SIP_SERVICE, |
| 3344 | USB_SERVICE, |
Amith Yamasani | 4f58263 | 2014-02-19 14:31:52 -0800 | [diff] [blame] | 3345 | LAUNCHER_APPS_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3346 | //@hide: SERIAL_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3347 | //@hide: HDMI_CONTROL_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3348 | INPUT_SERVICE, |
| 3349 | DISPLAY_SERVICE, |
Christine Franks | 39b0311 | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 3350 | //@hide COLOR_DISPLAY_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3351 | USER_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3352 | RESTRICTIONS_SERVICE, |
| 3353 | APP_OPS_SERVICE, |
Hai Zhang | b777668 | 2018-09-25 15:10:57 -0700 | [diff] [blame] | 3354 | ROLE_SERVICE, |
Hai Zhang | a4959e5 | 2019-03-06 12:21:07 -0800 | [diff] [blame] | 3355 | //@hide ROLE_CONTROLLER_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3356 | CAMERA_SERVICE, |
atrost | de54a8ac | 2019-08-15 16:53:01 +0100 | [diff] [blame] | 3357 | //@hide: PLATFORM_COMPAT_SERVICE, |
atrost | 8748835 | 2019-10-10 19:27:31 +0100 | [diff] [blame] | 3358 | //@hide: PLATFORM_COMPAT_NATIVE_SERVICE, |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 3359 | PRINT_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3360 | CONSUMER_IR_SERVICE, |
| 3361 | //@hide: TRUST_SERVICE, |
| 3362 | TV_INPUT_SERVICE, |
| 3363 | //@hide: NETWORK_SCORE_SERVICE, |
| 3364 | USAGE_STATS_SERVICE, |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 3365 | MEDIA_SESSION_SERVICE, |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 3366 | BATTERY_SERVICE, |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 3367 | JOB_SCHEDULER_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3368 | //@hide: PERSISTENT_DATA_BLOCK_SERVICE, |
Andrew Scull | 3b8b46f | 2017-02-13 18:12:15 +0000 | [diff] [blame] | 3369 | //@hide: OEM_LOCK_SERVICE, |
Michael Wright | 446e019 | 2014-12-22 09:38:43 -0800 | [diff] [blame] | 3370 | MEDIA_PROJECTION_SERVICE, |
Mike Lockwood | 67f8e8b | 2014-12-01 13:54:59 -0800 | [diff] [blame] | 3371 | MIDI_SERVICE, |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 3372 | RADIO_SERVICE, |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 3373 | HARDWARE_PROPERTIES_SERVICE, |
Arunesh Mishra | a772e5f | 2016-01-25 10:33:11 -0800 | [diff] [blame] | 3374 | //@hide: SOUND_TRIGGER_SERVICE, |
Makoto Onuki | 6f7362d9 | 2016-03-04 13:39:41 -0800 | [diff] [blame] | 3375 | SHORTCUT_SERVICE, |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 3376 | //@hide: CONTEXTHUB_SERVICE, |
Joe Onorato | 1754d74 | 2016-11-21 17:51:35 -0800 | [diff] [blame] | 3377 | SYSTEM_HEALTH_SERVICE, |
Tor Norbye | 8246c07 | 2017-07-07 10:21:09 -0700 | [diff] [blame] | 3378 | //@hide: INCIDENT_SERVICE, |
Joe Onorato | e21ab7e | 2018-12-18 15:00:25 -0800 | [diff] [blame] | 3379 | //@hide: INCIDENT_COMPANION_SERVICE, |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 3380 | //@hide: STATS_COMPANION_SERVICE, |
Tony Mak | 9240c7f | 2017-12-29 11:02:02 +0000 | [diff] [blame] | 3381 | COMPANION_DEVICE_SERVICE, |
Tao Bao | 07342dc | 2017-01-24 15:08:21 -0800 | [diff] [blame] | 3382 | CROSS_PROFILE_APPS_SERVICE, |
| 3383 | //@hide: SYSTEM_UPDATE_SERVICE, |
Neil Fuller | feeee68 | 2018-05-30 14:35:24 +0100 | [diff] [blame] | 3384 | //@hide: TIME_DETECTOR_SERVICE, |
Philip P. Moltmann | 039678e | 2018-09-18 13:04:38 -0700 | [diff] [blame] | 3385 | PERMISSION_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3386 | }) |
| 3387 | @Retention(RetentionPolicy.SOURCE) |
| 3388 | public @interface ServiceName {} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3389 | |
| 3390 | /** |
| 3391 | * Return the handle to a system-level service by name. The class of the |
| 3392 | * returned object varies by the requested name. Currently available names |
| 3393 | * are: |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3394 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3395 | * <dl> |
| 3396 | * <dt> {@link #WINDOW_SERVICE} ("window") |
| 3397 | * <dd> The top-level window manager in which you can place custom |
| 3398 | * windows. The returned object is a {@link android.view.WindowManager}. |
| 3399 | * <dt> {@link #LAYOUT_INFLATER_SERVICE} ("layout_inflater") |
| 3400 | * <dd> A {@link android.view.LayoutInflater} for inflating layout resources |
| 3401 | * in this context. |
| 3402 | * <dt> {@link #ACTIVITY_SERVICE} ("activity") |
| 3403 | * <dd> A {@link android.app.ActivityManager} for interacting with the |
| 3404 | * global activity state of the system. |
| 3405 | * <dt> {@link #POWER_SERVICE} ("power") |
| 3406 | * <dd> A {@link android.os.PowerManager} for controlling power |
| 3407 | * management. |
| 3408 | * <dt> {@link #ALARM_SERVICE} ("alarm") |
| 3409 | * <dd> A {@link android.app.AlarmManager} for receiving intents at the |
| 3410 | * time of your choosing. |
| 3411 | * <dt> {@link #NOTIFICATION_SERVICE} ("notification") |
| 3412 | * <dd> A {@link android.app.NotificationManager} for informing the user |
| 3413 | * of background events. |
| 3414 | * <dt> {@link #KEYGUARD_SERVICE} ("keyguard") |
| 3415 | * <dd> A {@link android.app.KeyguardManager} for controlling keyguard. |
| 3416 | * <dt> {@link #LOCATION_SERVICE} ("location") |
| 3417 | * <dd> A {@link android.location.LocationManager} for controlling location |
| 3418 | * (e.g., GPS) updates. |
| 3419 | * <dt> {@link #SEARCH_SERVICE} ("search") |
| 3420 | * <dd> A {@link android.app.SearchManager} for handling search. |
| 3421 | * <dt> {@link #VIBRATOR_SERVICE} ("vibrator") |
| 3422 | * <dd> A {@link android.os.Vibrator} for interacting with the vibrator |
| 3423 | * hardware. |
Sudheer Shanka | 09b0ee6 | 2019-10-03 14:45:15 -0700 | [diff] [blame] | 3424 | * <dt> {@link #CONNECTIVITY_SERVICE} ("connectivity") |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3425 | * <dd> A {@link android.net.ConnectivityManager ConnectivityManager} for |
| 3426 | * handling management of network connections. |
Nathan Harold | d999d22 | 2017-09-11 19:53:33 -0700 | [diff] [blame] | 3427 | * <dt> {@link #IPSEC_SERVICE} ("ipsec") |
| 3428 | * <dd> A {@link android.net.IpSecManager IpSecManager} for managing IPSec on |
| 3429 | * sockets and networks. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3430 | * <dt> {@link #WIFI_SERVICE} ("wifi") |
Paul Stewart | 0e164b1 | 2016-08-08 10:20:13 -0700 | [diff] [blame] | 3431 | * <dd> A {@link android.net.wifi.WifiManager WifiManager} for management of Wi-Fi |
| 3432 | * connectivity. On releases before NYC, it should only be obtained from an application |
| 3433 | * context, and not from any other derived context to avoid memory leaks within the calling |
| 3434 | * process. |
Etan Cohen | 6a4b323 | 2017-01-09 21:47:32 -0800 | [diff] [blame] | 3435 | * <dt> {@link #WIFI_AWARE_SERVICE} ("wifiaware") |
| 3436 | * <dd> A {@link android.net.wifi.aware.WifiAwareManager WifiAwareManager} for management of |
| 3437 | * Wi-Fi Aware discovery and connectivity. |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 3438 | * <dt> {@link #WIFI_P2P_SERVICE} ("wifip2p") |
| 3439 | * <dd> A {@link android.net.wifi.p2p.WifiP2pManager WifiP2pManager} for management of |
| 3440 | * Wi-Fi Direct connectivity. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3441 | * <dt> {@link #INPUT_METHOD_SERVICE} ("input_method") |
| 3442 | * <dd> An {@link android.view.inputmethod.InputMethodManager InputMethodManager} |
| 3443 | * for management of input methods. |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 3444 | * <dt> {@link #UI_MODE_SERVICE} ("uimode") |
| 3445 | * <dd> An {@link android.app.UiModeManager} for controlling UI modes. |
Steve Howard | 7083c42 | 2010-07-28 16:01:23 -0700 | [diff] [blame] | 3446 | * <dt> {@link #DOWNLOAD_SERVICE} ("download") |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 3447 | * <dd> A {@link android.app.DownloadManager} for requesting HTTP downloads |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 3448 | * <dt> {@link #BATTERY_SERVICE} ("batterymanager") |
Todd Poynor | 99f7e12 | 2014-04-15 16:03:42 -0700 | [diff] [blame] | 3449 | * <dd> A {@link android.os.BatteryManager} for managing battery state |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 3450 | * <dt> {@link #JOB_SCHEDULER_SERVICE} ("taskmanager") |
| 3451 | * <dd> A {@link android.app.job.JobScheduler} for managing scheduled tasks |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3452 | * <dt> {@link #NETWORK_STATS_SERVICE} ("netstats") |
| 3453 | * <dd> A {@link android.app.usage.NetworkStatsManager NetworkStatsManager} for querying network |
| 3454 | * usage statistics. |
Polina Bondarenko | 8333c73 | 2016-03-09 18:08:42 +0100 | [diff] [blame] | 3455 | * <dt> {@link #HARDWARE_PROPERTIES_SERVICE} ("hardware_properties") |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 3456 | * <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] | 3457 | * </dl> |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3458 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3459 | * <p>Note: System services obtained via this API may be closely associated with |
| 3460 | * the Context in which they are obtained from. In general, do not share the |
| 3461 | * service objects between various different contexts (Activities, Applications, |
| 3462 | * Services, Providers, etc.) |
| 3463 | * |
Svet Ganov | 8f90bcc | 2017-12-22 23:29:24 -0800 | [diff] [blame] | 3464 | * <p>Note: Instant apps, for which {@link PackageManager#isInstantApp()} returns true, |
| 3465 | * 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] | 3466 | * {@link #FINGERPRINT_SERVICE}, {@link #KEYGUARD_SERVICE}, {@link #SHORTCUT_SERVICE}, |
| 3467 | * {@link #USB_SERVICE}, {@link #WALLPAPER_SERVICE}, {@link #WIFI_P2P_SERVICE}, |
| 3468 | * {@link #WIFI_SERVICE}, {@link #WIFI_AWARE_SERVICE}. For these services this method will |
| 3469 | * return <code>null</code>. Generally, if you are running as an instant app you should always |
Felipe Leme | 4685b86 | 2019-03-06 10:32:33 -0800 | [diff] [blame] | 3470 | * check whether the result of this method is {@code null}. |
| 3471 | * |
| 3472 | * <p>Note: When implementing this method, keep in mind that new services can be added on newer |
| 3473 | * Android releases, so if you're looking for just the explicit names mentioned above, make sure |
| 3474 | * to return {@code null} when you don't recognize the name — if you throw a |
| 3475 | * {@link RuntimeException} exception instead, you're app might break on new Android releases. |
Svet Ganov | 8f90bcc | 2017-12-22 23:29:24 -0800 | [diff] [blame] | 3476 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3477 | * @param name The name of the desired service. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3478 | * |
Felipe Leme | 4685b86 | 2019-03-06 10:32:33 -0800 | [diff] [blame] | 3479 | * @return The service or {@code null} if the name does not exist. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3480 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3481 | * @see #WINDOW_SERVICE |
| 3482 | * @see android.view.WindowManager |
| 3483 | * @see #LAYOUT_INFLATER_SERVICE |
| 3484 | * @see android.view.LayoutInflater |
| 3485 | * @see #ACTIVITY_SERVICE |
| 3486 | * @see android.app.ActivityManager |
| 3487 | * @see #POWER_SERVICE |
| 3488 | * @see android.os.PowerManager |
| 3489 | * @see #ALARM_SERVICE |
| 3490 | * @see android.app.AlarmManager |
| 3491 | * @see #NOTIFICATION_SERVICE |
| 3492 | * @see android.app.NotificationManager |
| 3493 | * @see #KEYGUARD_SERVICE |
| 3494 | * @see android.app.KeyguardManager |
| 3495 | * @see #LOCATION_SERVICE |
| 3496 | * @see android.location.LocationManager |
| 3497 | * @see #SEARCH_SERVICE |
| 3498 | * @see android.app.SearchManager |
| 3499 | * @see #SENSOR_SERVICE |
| 3500 | * @see android.hardware.SensorManager |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 3501 | * @see #STORAGE_SERVICE |
San Mehat | b104340 | 2010-02-05 08:26:50 -0800 | [diff] [blame] | 3502 | * @see android.os.storage.StorageManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3503 | * @see #VIBRATOR_SERVICE |
| 3504 | * @see android.os.Vibrator |
| 3505 | * @see #CONNECTIVITY_SERVICE |
| 3506 | * @see android.net.ConnectivityManager |
| 3507 | * @see #WIFI_SERVICE |
| 3508 | * @see android.net.wifi.WifiManager |
| 3509 | * @see #AUDIO_SERVICE |
| 3510 | * @see android.media.AudioManager |
Dianne Hackborn | b58b8f8 | 2012-06-11 15:08:39 -0700 | [diff] [blame] | 3511 | * @see #MEDIA_ROUTER_SERVICE |
| 3512 | * @see android.media.MediaRouter |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3513 | * @see #TELEPHONY_SERVICE |
| 3514 | * @see android.telephony.TelephonyManager |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 3515 | * @see #TELEPHONY_SUBSCRIPTION_SERVICE |
| 3516 | * @see android.telephony.SubscriptionManager |
Jonathan Basseri | 9a1c9b6 | 2015-02-25 13:01:52 -0800 | [diff] [blame] | 3517 | * @see #CARRIER_CONFIG_SERVICE |
| 3518 | * @see android.telephony.CarrierConfigManager |
hyunhae.lee | 75fdafa | 2019-07-19 22:08:41 +0900 | [diff] [blame] | 3519 | * @see #EUICC_SERVICE |
| 3520 | * @see android.telephony.euicc.EuiccManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3521 | * @see #INPUT_METHOD_SERVICE |
| 3522 | * @see android.view.inputmethod.InputMethodManager |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 3523 | * @see #UI_MODE_SERVICE |
| 3524 | * @see android.app.UiModeManager |
Steve Howard | 7083c42 | 2010-07-28 16:01:23 -0700 | [diff] [blame] | 3525 | * @see #DOWNLOAD_SERVICE |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 3526 | * @see android.app.DownloadManager |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 3527 | * @see #BATTERY_SERVICE |
| 3528 | * @see android.os.BatteryManager |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 3529 | * @see #JOB_SCHEDULER_SERVICE |
| 3530 | * @see android.app.job.JobScheduler |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3531 | * @see #NETWORK_STATS_SERVICE |
| 3532 | * @see android.app.usage.NetworkStatsManager |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 3533 | * @see android.os.HardwarePropertiesManager |
| 3534 | * @see #HARDWARE_PROPERTIES_SERVICE |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3535 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 3536 | public abstract @Nullable Object getSystemService(@ServiceName @NonNull String name); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3537 | |
| 3538 | /** |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3539 | * Return the handle to a system-level service by class. |
| 3540 | * <p> |
| 3541 | * Currently available classes are: |
| 3542 | * {@link android.view.WindowManager}, {@link android.view.LayoutInflater}, |
| 3543 | * {@link android.app.ActivityManager}, {@link android.os.PowerManager}, |
| 3544 | * {@link android.app.AlarmManager}, {@link android.app.NotificationManager}, |
| 3545 | * {@link android.app.KeyguardManager}, {@link android.location.LocationManager}, |
| 3546 | * {@link android.app.SearchManager}, {@link android.os.Vibrator}, |
| 3547 | * {@link android.net.ConnectivityManager}, |
| 3548 | * {@link android.net.wifi.WifiManager}, |
| 3549 | * {@link android.media.AudioManager}, {@link android.media.MediaRouter}, |
| 3550 | * {@link android.telephony.TelephonyManager}, {@link android.telephony.SubscriptionManager}, |
| 3551 | * {@link android.view.inputmethod.InputMethodManager}, |
| 3552 | * {@link android.app.UiModeManager}, {@link android.app.DownloadManager}, |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3553 | * {@link android.os.BatteryManager}, {@link android.app.job.JobScheduler}, |
| 3554 | * {@link android.app.usage.NetworkStatsManager}. |
Felipe Leme | 4685b86 | 2019-03-06 10:32:33 -0800 | [diff] [blame] | 3555 | * </p> |
| 3556 | * |
| 3557 | * <p> |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3558 | * Note: System services obtained via this API may be closely associated with |
| 3559 | * the Context in which they are obtained from. In general, do not share the |
| 3560 | * service objects between various different contexts (Activities, Applications, |
| 3561 | * Services, Providers, etc.) |
| 3562 | * </p> |
| 3563 | * |
Svet Ganov | 8f90bcc | 2017-12-22 23:29:24 -0800 | [diff] [blame] | 3564 | * <p>Note: Instant apps, for which {@link PackageManager#isInstantApp()} returns true, |
| 3565 | * 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] | 3566 | * {@link #FINGERPRINT_SERVICE}, {@link #KEYGUARD_SERVICE}, {@link #SHORTCUT_SERVICE}, |
| 3567 | * {@link #USB_SERVICE}, {@link #WALLPAPER_SERVICE}, {@link #WIFI_P2P_SERVICE}, |
| 3568 | * {@link #WIFI_SERVICE}, {@link #WIFI_AWARE_SERVICE}. For these services this method will |
Felipe Leme | 4685b86 | 2019-03-06 10:32:33 -0800 | [diff] [blame] | 3569 | * return {@code null}. Generally, if you are running as an instant app you should always |
| 3570 | * check whether the result of this method is {@code null}. |
| 3571 | * </p> |
Svet Ganov | 8f90bcc | 2017-12-22 23:29:24 -0800 | [diff] [blame] | 3572 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3573 | * @param serviceClass The class of the desired service. |
Felipe Leme | 4685b86 | 2019-03-06 10:32:33 -0800 | [diff] [blame] | 3574 | * @return The service or {@code null} if the class is not a supported system service. Note: |
| 3575 | * <b>never</b> throw a {@link RuntimeException} if the name is not supported. |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3576 | */ |
| 3577 | @SuppressWarnings("unchecked") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 3578 | public final @Nullable <T> T getSystemService(@NonNull Class<T> serviceClass) { |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3579 | // Because subclasses may override getSystemService(String) we cannot |
| 3580 | // perform a lookup by class alone. We must first map the class to its |
| 3581 | // service name then invoke the string-based method. |
| 3582 | String serviceName = getSystemServiceName(serviceClass); |
| 3583 | return serviceName != null ? (T)getSystemService(serviceName) : null; |
| 3584 | } |
| 3585 | |
| 3586 | /** |
| 3587 | * Gets the name of the system-level service that is represented by the specified class. |
| 3588 | * |
| 3589 | * @param serviceClass The class of the desired service. |
| 3590 | * @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] | 3591 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 3592 | public abstract @Nullable String getSystemServiceName(@NonNull Class<?> serviceClass); |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3593 | |
| 3594 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3595 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3596 | * {@link android.os.PowerManager} for controlling power management, |
| 3597 | * including "wake locks," which let you keep the device on while |
| 3598 | * you're running long tasks. |
| 3599 | */ |
| 3600 | public static final String POWER_SERVICE = "power"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3601 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3602 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3603 | * Use with {@link #getSystemService(String)} to retrieve a |
Tao Bao | e8a403d | 2015-12-31 07:44:55 -0800 | [diff] [blame] | 3604 | * {@link android.os.RecoverySystem} for accessing the recovery system |
| 3605 | * service. |
| 3606 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3607 | * @see #getSystemService(String) |
Tao Bao | e8a403d | 2015-12-31 07:44:55 -0800 | [diff] [blame] | 3608 | * @hide |
| 3609 | */ |
| 3610 | public static final String RECOVERY_SERVICE = "recovery"; |
| 3611 | |
| 3612 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3613 | * Use with {@link #getSystemService(String)} to retrieve a |
Tao Bao | 07342dc | 2017-01-24 15:08:21 -0800 | [diff] [blame] | 3614 | * {@link android.os.SystemUpdateManager} for accessing the system update |
| 3615 | * manager service. |
| 3616 | * |
| 3617 | * @see #getSystemService(String) |
| 3618 | * @hide |
| 3619 | */ |
| 3620 | @SystemApi |
| 3621 | public static final String SYSTEM_UPDATE_SERVICE = "system_update"; |
| 3622 | |
| 3623 | /** |
| 3624 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3625 | * {@link android.view.WindowManager} for accessing the system's window |
| 3626 | * manager. |
| 3627 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3628 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3629 | * @see android.view.WindowManager |
| 3630 | */ |
| 3631 | public static final String WINDOW_SERVICE = "window"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3632 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3633 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3634 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3635 | * {@link android.view.LayoutInflater} for inflating layout resources in this |
| 3636 | * context. |
| 3637 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3638 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3639 | * @see android.view.LayoutInflater |
| 3640 | */ |
| 3641 | public static final String LAYOUT_INFLATER_SERVICE = "layout_inflater"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3642 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3643 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3644 | * Use with {@link #getSystemService(String)} to retrieve a |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 3645 | * {@link android.accounts.AccountManager} for receiving intents at a |
| 3646 | * time of your choosing. |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 3647 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3648 | * @see #getSystemService(String) |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 3649 | * @see android.accounts.AccountManager |
| 3650 | */ |
| 3651 | public static final String ACCOUNT_SERVICE = "account"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3652 | |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 3653 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3654 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3655 | * {@link android.app.ActivityManager} for interacting with the global |
| 3656 | * system state. |
| 3657 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3658 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3659 | * @see android.app.ActivityManager |
| 3660 | */ |
| 3661 | public static final String ACTIVITY_SERVICE = "activity"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3662 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3663 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3664 | * Use with {@link #getSystemService(String)} to retrieve a |
Wale Ogunwale | 65ebd95 | 2018-04-25 15:41:44 -0700 | [diff] [blame] | 3665 | * {@link android.app.ActivityTaskManager} for interacting with the global system state. |
| 3666 | * |
| 3667 | * @see #getSystemService(String) |
| 3668 | * @see android.app.ActivityTaskManager |
| 3669 | * @hide |
| 3670 | */ |
| 3671 | public static final String ACTIVITY_TASK_SERVICE = "activity_task"; |
| 3672 | |
| 3673 | /** |
| 3674 | * Use with {@link #getSystemService(String)} to retrieve a |
Wale Ogunwale | 6d50dcc | 2018-07-21 23:00:40 -0700 | [diff] [blame] | 3675 | * {@link android.app.UriGrantsManager} for interacting with the global system state. |
| 3676 | * |
| 3677 | * @see #getSystemService(String) |
| 3678 | * @see android.app.UriGrantsManager |
| 3679 | * @hide |
| 3680 | */ |
| 3681 | public static final String URI_GRANTS_SERVICE = "uri_grants"; |
| 3682 | |
| 3683 | /** |
| 3684 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3685 | * {@link android.app.AlarmManager} for receiving intents at a |
| 3686 | * time of your choosing. |
| 3687 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3688 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3689 | * @see android.app.AlarmManager |
| 3690 | */ |
| 3691 | public static final String ALARM_SERVICE = "alarm"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3692 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3693 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3694 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3695 | * {@link android.app.NotificationManager} for informing the user of |
| 3696 | * background events. |
| 3697 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3698 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3699 | * @see android.app.NotificationManager |
| 3700 | */ |
| 3701 | public static final String NOTIFICATION_SERVICE = "notification"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3702 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3703 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3704 | * Use with {@link #getSystemService(String)} to retrieve a |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 3705 | * {@link android.view.accessibility.AccessibilityManager} for giving the user |
| 3706 | * feedback for UI events through the registered event listeners. |
| 3707 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3708 | * @see #getSystemService(String) |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 3709 | * @see android.view.accessibility.AccessibilityManager |
| 3710 | */ |
| 3711 | public static final String ACCESSIBILITY_SERVICE = "accessibility"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3712 | |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 3713 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3714 | * Use with {@link #getSystemService(String)} to retrieve a |
Alan Viverette | 69ce69b | 2013-08-29 12:23:48 -0700 | [diff] [blame] | 3715 | * {@link android.view.accessibility.CaptioningManager} for obtaining |
| 3716 | * captioning properties and listening for changes in captioning |
| 3717 | * preferences. |
| 3718 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3719 | * @see #getSystemService(String) |
Alan Viverette | 69ce69b | 2013-08-29 12:23:48 -0700 | [diff] [blame] | 3720 | * @see android.view.accessibility.CaptioningManager |
| 3721 | */ |
| 3722 | public static final String CAPTIONING_SERVICE = "captioning"; |
| 3723 | |
| 3724 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3725 | * Use with {@link #getSystemService(String)} to retrieve a |
kopriva | 5495dbb | 2018-09-13 14:18:34 -0700 | [diff] [blame] | 3726 | * {@link android.app.KeyguardManager} for controlling keyguard. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3727 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3728 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3729 | * @see android.app.KeyguardManager |
| 3730 | */ |
| 3731 | public static final String KEYGUARD_SERVICE = "keyguard"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3732 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3733 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3734 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3735 | * android.location.LocationManager} for controlling location |
| 3736 | * updates. |
| 3737 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3738 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3739 | * @see android.location.LocationManager |
| 3740 | */ |
| 3741 | public static final String LOCATION_SERVICE = "location"; |
Bai Tao | a58a875 | 2010-07-13 15:32:16 +0800 | [diff] [blame] | 3742 | |
| 3743 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3744 | * Use with {@link #getSystemService(String)} to retrieve a |
Bai Tao | a58a875 | 2010-07-13 15:32:16 +0800 | [diff] [blame] | 3745 | * {@link android.location.CountryDetector} for detecting the country that |
| 3746 | * the user is in. |
| 3747 | * |
| 3748 | * @hide |
| 3749 | */ |
Mathew Inwood | 8c854f8 | 2018-09-14 12:35:36 +0100 | [diff] [blame] | 3750 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Bai Tao | a58a875 | 2010-07-13 15:32:16 +0800 | [diff] [blame] | 3751 | public static final String COUNTRY_DETECTOR = "country_detector"; |
| 3752 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3753 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3754 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3755 | * android.app.SearchManager} for handling searches. |
| 3756 | * |
Erik Wolsheimer | ac5cecd | 2017-12-05 13:11:50 -0800 | [diff] [blame] | 3757 | * <p> |
| 3758 | * {@link Configuration#UI_MODE_TYPE_WATCH} does not support |
| 3759 | * {@link android.app.SearchManager}. |
| 3760 | * |
| 3761 | * @see #getSystemService |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3762 | * @see android.app.SearchManager |
| 3763 | */ |
| 3764 | public static final String SEARCH_SERVICE = "search"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3765 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3766 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3767 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3768 | * android.hardware.SensorManager} for accessing sensors. |
| 3769 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3770 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3771 | * @see android.hardware.SensorManager |
| 3772 | */ |
| 3773 | public static final String SENSOR_SERVICE = "sensor"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3774 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3775 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3776 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Chad Brubaker | 90f391f | 2018-10-19 10:26:19 -0700 | [diff] [blame] | 3777 | * android.hardware.SensorPrivacyManager} for accessing sensor privacy |
| 3778 | * functions. |
| 3779 | * |
| 3780 | * @see #getSystemService(String) |
| 3781 | * @see android.hardware.SensorPrivacyManager |
| 3782 | * |
| 3783 | * @hide |
| 3784 | */ |
| 3785 | public static final String SENSOR_PRIVACY_SERVICE = "sensor_privacy"; |
| 3786 | |
| 3787 | /** |
| 3788 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Kenny Root | 02c8730 | 2010-07-01 08:10:18 -0700 | [diff] [blame] | 3789 | * android.os.storage.StorageManager} for accessing system storage |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 3790 | * functions. |
| 3791 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3792 | * @see #getSystemService(String) |
San Mehat | b104340 | 2010-02-05 08:26:50 -0800 | [diff] [blame] | 3793 | * @see android.os.storage.StorageManager |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 3794 | */ |
| 3795 | public static final String STORAGE_SERVICE = "storage"; |
| 3796 | |
| 3797 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3798 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Jeff Sharkey | e8cece9 | 2017-01-04 11:33:33 -0700 | [diff] [blame] | 3799 | * android.app.usage.StorageStatsManager} for accessing system storage |
| 3800 | * statistics. |
| 3801 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3802 | * @see #getSystemService(String) |
Jeff Sharkey | e8cece9 | 2017-01-04 11:33:33 -0700 | [diff] [blame] | 3803 | * @see android.app.usage.StorageStatsManager |
| 3804 | */ |
| 3805 | public static final String STORAGE_STATS_SERVICE = "storagestats"; |
| 3806 | |
| 3807 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3808 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3809 | * com.android.server.WallpaperService for accessing wallpapers. |
| 3810 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3811 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3812 | */ |
| 3813 | public static final String WALLPAPER_SERVICE = "wallpaper"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3814 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3815 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3816 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3817 | * android.os.Vibrator} for interacting with the vibration hardware. |
| 3818 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3819 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3820 | * @see android.os.Vibrator |
| 3821 | */ |
| 3822 | public static final String VIBRATOR_SERVICE = "vibrator"; |
Robert Greenwalt | 9e696c2 | 2010-04-01 14:45:18 -0700 | [diff] [blame] | 3823 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3824 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3825 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3826 | * android.app.StatusBarManager} for interacting with the status bar. |
| 3827 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3828 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3829 | * @see android.app.StatusBarManager |
Evan Laird | edd016f | 2019-01-23 18:36:29 -0500 | [diff] [blame] | 3830 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3831 | * @hide |
| 3832 | */ |
Evan Laird | edd016f | 2019-01-23 18:36:29 -0500 | [diff] [blame] | 3833 | @SystemApi |
Evan Laird | 418ba8f | 2019-04-17 15:55:21 -0400 | [diff] [blame] | 3834 | @TestApi |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3835 | public static final String STATUS_BAR_SERVICE = "statusbar"; |
| 3836 | |
| 3837 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3838 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3839 | * android.net.ConnectivityManager} for handling management of |
| 3840 | * network connections. |
| 3841 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3842 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3843 | * @see android.net.ConnectivityManager |
| 3844 | */ |
| 3845 | public static final String CONNECTIVITY_SERVICE = "connectivity"; |
| 3846 | |
| 3847 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3848 | * Use with {@link #getSystemService(String)} to retrieve a |
Remi NGUYEN VAN | 3193598 | 2019-01-28 11:40:08 +0900 | [diff] [blame] | 3849 | * {@link android.net.INetd} for communicating with the network stack |
| 3850 | * @hide |
| 3851 | * @see #getSystemService(String) |
| 3852 | * @hide |
| 3853 | */ |
| 3854 | @SystemApi |
| 3855 | public static final String NETD_SERVICE = "netd"; |
| 3856 | |
| 3857 | /** |
Remi NGUYEN VAN | 310da6f | 2019-02-14 18:04:20 +0900 | [diff] [blame] | 3858 | * Use with {@link android.os.ServiceManager.getService()} to retrieve a |
| 3859 | * {@link NetworkStackClient} IBinder for communicating with the network stack |
Remi NGUYEN VAN | c094a54 | 2018-12-07 16:52:24 +0900 | [diff] [blame] | 3860 | * @hide |
Remi NGUYEN VAN | 310da6f | 2019-02-14 18:04:20 +0900 | [diff] [blame] | 3861 | * @see NetworkStackClient |
Remi NGUYEN VAN | c094a54 | 2018-12-07 16:52:24 +0900 | [diff] [blame] | 3862 | */ |
| 3863 | public static final String NETWORK_STACK_SERVICE = "network_stack"; |
| 3864 | |
| 3865 | /** |
Roshan Pius | 6f5338d | 2019-06-14 14:37:14 -0700 | [diff] [blame] | 3866 | * Use with {@link android.os.ServiceManager.getService()} to retrieve a |
| 3867 | * {@link android.net.WifiStackClient} IBinder for communicating with the network stack |
| 3868 | * @hide |
| 3869 | * @see android.net.WifiStackClient |
| 3870 | */ |
| 3871 | public static final String WIFI_STACK_SERVICE = "wifi_stack"; |
| 3872 | |
| 3873 | /** |
Remi NGUYEN VAN | c094a54 | 2018-12-07 16:52:24 +0900 | [diff] [blame] | 3874 | * Use with {@link #getSystemService(String)} to retrieve a |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 3875 | * {@link android.net.IpSecManager} for encrypting Sockets or Networks with |
| 3876 | * IPSec. |
| 3877 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3878 | * @see #getSystemService(String) |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 3879 | */ |
| 3880 | public static final String IPSEC_SERVICE = "ipsec"; |
| 3881 | |
| 3882 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3883 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Benedict Wong | 99a4841 | 2018-11-09 14:45:34 -0800 | [diff] [blame] | 3884 | * android.net.TestNetworkManager} for building TUNs and limited-use Networks |
| 3885 | * |
| 3886 | * @see #getSystemService(String) |
| 3887 | * @hide |
| 3888 | */ |
| 3889 | @TestApi public static final String TEST_NETWORK_SERVICE = "test_network"; |
| 3890 | |
| 3891 | /** |
| 3892 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Christopher Tate | 8662cab5 | 2012-02-23 14:59:36 -0800 | [diff] [blame] | 3893 | * android.os.IUpdateLock} for managing runtime sequences that |
| 3894 | * must not be interrupted by headless OTA application or similar. |
| 3895 | * |
| 3896 | * @hide |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3897 | * @see #getSystemService(String) |
Christopher Tate | 8662cab5 | 2012-02-23 14:59:36 -0800 | [diff] [blame] | 3898 | * @see android.os.UpdateLock |
| 3899 | */ |
| 3900 | public static final String UPDATE_LOCK_SERVICE = "updatelock"; |
| 3901 | |
| 3902 | /** |
Dianne Hackborn | 35f72be | 2013-09-16 10:57:39 -0700 | [diff] [blame] | 3903 | * Constant for the internal network management service, not really a Context service. |
Dianne Hackborn | 0a6a80f | 2013-09-16 15:20:27 -0700 | [diff] [blame] | 3904 | * @hide |
San Mehat | d1df8ac | 2010-01-26 06:17:26 -0800 | [diff] [blame] | 3905 | */ |
| 3906 | public static final String NETWORKMANAGEMENT_SERVICE = "network_management"; |
| 3907 | |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3908 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3909 | * Use with {@link #getSystemService(String)} to retrieve a |
Jason Monk | 8f5f7ff | 2017-10-17 14:12:42 -0400 | [diff] [blame] | 3910 | * {@link com.android.server.slice.SliceManagerService} for managing slices. |
| 3911 | * @hide |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3912 | * @see #getSystemService(String) |
Jason Monk | 8f5f7ff | 2017-10-17 14:12:42 -0400 | [diff] [blame] | 3913 | */ |
| 3914 | public static final String SLICE_SERVICE = "slice"; |
| 3915 | |
| 3916 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3917 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3918 | * android.app.usage.NetworkStatsManager} for querying network usage stats. |
| 3919 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3920 | * @see #getSystemService(String) |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3921 | * @see android.app.usage.NetworkStatsManager |
| 3922 | */ |
Jeff Sharkey | 7527990 | 2011-05-24 18:39:45 -0700 | [diff] [blame] | 3923 | public static final String NETWORK_STATS_SERVICE = "netstats"; |
| 3924 | /** {@hide} */ |
Jeff Sharkey | eedcb95 | 2011-05-17 14:55:15 -0700 | [diff] [blame] | 3925 | public static final String NETWORK_POLICY_SERVICE = "netpolicy"; |
Ricky Wai | 1a6e667 | 2017-10-27 14:46:01 +0100 | [diff] [blame] | 3926 | /** {@hide} */ |
| 3927 | public static final String NETWORK_WATCHLIST_SERVICE = "network_watchlist"; |
Jeff Sharkey | eedcb95 | 2011-05-17 14:55:15 -0700 | [diff] [blame] | 3928 | |
San Mehat | d1df8ac | 2010-01-26 06:17:26 -0800 | [diff] [blame] | 3929 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3930 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3931 | * android.net.wifi.WifiManager} for handling management of |
| 3932 | * Wi-Fi access. |
| 3933 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3934 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3935 | * @see android.net.wifi.WifiManager |
| 3936 | */ |
| 3937 | public static final String WIFI_SERVICE = "wifi"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3938 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3939 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3940 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 3941 | * android.net.wifi.p2p.WifiP2pManager} for handling management of |
Irfan Sheriff | 651cdfc | 2011-09-07 00:31:20 -0700 | [diff] [blame] | 3942 | * Wi-Fi peer-to-peer connections. |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 3943 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3944 | * @see #getSystemService(String) |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 3945 | * @see android.net.wifi.p2p.WifiP2pManager |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 3946 | */ |
| 3947 | public static final String WIFI_P2P_SERVICE = "wifip2p"; |
| 3948 | |
| 3949 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3950 | * Use with {@link #getSystemService(String)} to retrieve a |
Etan Cohen | 0413327 | 2016-10-26 11:22:06 -0700 | [diff] [blame] | 3951 | * {@link android.net.wifi.aware.WifiAwareManager} for handling management of |
| 3952 | * Wi-Fi Aware. |
Etan Cohen | 20d329b | 2015-09-29 13:49:02 -0700 | [diff] [blame] | 3953 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3954 | * @see #getSystemService(String) |
Etan Cohen | 0413327 | 2016-10-26 11:22:06 -0700 | [diff] [blame] | 3955 | * @see android.net.wifi.aware.WifiAwareManager |
Etan Cohen | 20d329b | 2015-09-29 13:49:02 -0700 | [diff] [blame] | 3956 | */ |
Etan Cohen | 0413327 | 2016-10-26 11:22:06 -0700 | [diff] [blame] | 3957 | public static final String WIFI_AWARE_SERVICE = "wifiaware"; |
Etan Cohen | 20d329b | 2015-09-29 13:49:02 -0700 | [diff] [blame] | 3958 | |
| 3959 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3960 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 3961 | * android.net.wifi.WifiScanner} for scanning the wifi universe |
| 3962 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3963 | * @see #getSystemService(String) |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 3964 | * @see android.net.wifi.WifiScanner |
| 3965 | * @hide |
| 3966 | */ |
Wei Wang | 35d552f | 2014-07-08 21:37:01 -0700 | [diff] [blame] | 3967 | @SystemApi |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 3968 | public static final String WIFI_SCANNING_SERVICE = "wifiscanner"; |
| 3969 | |
| 3970 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3971 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Vinit Deshpande | 7686c06 | 2014-06-30 15:25:01 -0700 | [diff] [blame] | 3972 | * android.net.wifi.RttManager} for ranging devices with wifi |
| 3973 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3974 | * @see #getSystemService(String) |
Vinit Deshpande | 7686c06 | 2014-06-30 15:25:01 -0700 | [diff] [blame] | 3975 | * @see android.net.wifi.RttManager |
| 3976 | * @hide |
| 3977 | */ |
| 3978 | @SystemApi |
Etan Cohen | d0acccd | 2018-01-31 08:36:33 -0800 | [diff] [blame] | 3979 | @Deprecated |
Vinit Deshpande | 7686c06 | 2014-06-30 15:25:01 -0700 | [diff] [blame] | 3980 | public static final String WIFI_RTT_SERVICE = "rttmanager"; |
| 3981 | |
| 3982 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3983 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Etan Cohen | f4062a9 | 2019-04-11 07:00:42 -0700 | [diff] [blame] | 3984 | * android.net.wifi.rtt.WifiRttManager} for ranging devices with wifi. |
Etan Cohen | 17ba472 | 2017-08-21 10:52:17 -0700 | [diff] [blame] | 3985 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3986 | * @see #getSystemService(String) |
Etan Cohen | 17ba472 | 2017-08-21 10:52:17 -0700 | [diff] [blame] | 3987 | * @see android.net.wifi.rtt.WifiRttManager |
Etan Cohen | 17ba472 | 2017-08-21 10:52:17 -0700 | [diff] [blame] | 3988 | */ |
Etan Cohen | 091d777 | 2018-01-04 17:47:37 -0800 | [diff] [blame] | 3989 | public static final String WIFI_RTT_RANGING_SERVICE = "wifirtt"; |
Etan Cohen | 17ba472 | 2017-08-21 10:52:17 -0700 | [diff] [blame] | 3990 | |
| 3991 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3992 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Robert Quattlebaum | 87a7104 | 2017-05-15 15:45:20 -0700 | [diff] [blame] | 3993 | * android.net.lowpan.LowpanManager} for handling management of |
| 3994 | * LoWPAN access. |
| 3995 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3996 | * @see #getSystemService(String) |
Robert Quattlebaum | 87a7104 | 2017-05-15 15:45:20 -0700 | [diff] [blame] | 3997 | * @see android.net.lowpan.LowpanManager |
| 3998 | * |
| 3999 | * @hide |
| 4000 | */ |
| 4001 | public static final String LOWPAN_SERVICE = "lowpan"; |
| 4002 | |
| 4003 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4004 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Dianne Hackborn | fee756f | 2014-07-16 17:31:10 -0700 | [diff] [blame] | 4005 | * android.net.EthernetManager} for handling management of |
Lorenzo Colitti | f9ff2c9 | 2014-05-21 16:32:11 -0700 | [diff] [blame] | 4006 | * Ethernet access. |
| 4007 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4008 | * @see #getSystemService(String) |
Dianne Hackborn | fee756f | 2014-07-16 17:31:10 -0700 | [diff] [blame] | 4009 | * @see android.net.EthernetManager |
Lorenzo Colitti | f9ff2c9 | 2014-05-21 16:32:11 -0700 | [diff] [blame] | 4010 | * |
| 4011 | * @hide |
| 4012 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 4013 | @UnsupportedAppUsage |
Lorenzo Colitti | f9ff2c9 | 2014-05-21 16:32:11 -0700 | [diff] [blame] | 4014 | public static final String ETHERNET_SERVICE = "ethernet"; |
| 4015 | |
| 4016 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4017 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Irfan Sheriff | 60309fc | 2012-04-24 14:52:37 -0700 | [diff] [blame] | 4018 | * android.net.nsd.NsdManager} for handling management of network service |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 4019 | * discovery |
| 4020 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4021 | * @see #getSystemService(String) |
Irfan Sheriff | 60309fc | 2012-04-24 14:52:37 -0700 | [diff] [blame] | 4022 | * @see android.net.nsd.NsdManager |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 4023 | */ |
| 4024 | public static final String NSD_SERVICE = "servicediscovery"; |
| 4025 | |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 4026 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4027 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4028 | * {@link android.media.AudioManager} for handling management of volume, |
| 4029 | * ringer modes and audio routing. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4030 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4031 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4032 | * @see android.media.AudioManager |
| 4033 | */ |
| 4034 | public static final String AUDIO_SERVICE = "audio"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4035 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4036 | /** |
Ilya Matyukhin | e4675b3 | 2019-11-07 16:07:19 -0800 | [diff] [blame] | 4037 | * AuthService orchestrates biometric and PIN/pattern/password authentication. |
| 4038 | * |
| 4039 | * BiometricService was split into two services, AuthService and BiometricService, where |
| 4040 | * AuthService is the high level service that orchestrates all types of authentication, and |
| 4041 | * BiometricService is a lower layer responsible only for biometric authentication. |
| 4042 | * |
| 4043 | * Ideally we should have renamed BiometricManager to AuthManager, because it logically |
| 4044 | * corresponds to AuthService. However, because BiometricManager is a public API, we kept |
| 4045 | * the old name but changed the internal implementation to use AuthService. |
| 4046 | * |
| 4047 | * As of now, the AUTH_SERVICE constant is only used to identify the service in |
| 4048 | * SystemServiceRegistry and SELinux. To obtain the manager for AUTH_SERVICE, one should use |
| 4049 | * BIOMETRIC_SERVICE with {@link #getSystemService(String)} to retrieve a |
| 4050 | * {@link android.hardware.biometrics.BiometricManager} |
| 4051 | * |
| 4052 | * Map of the two services and their managers: |
| 4053 | * [Service] [Manager] |
| 4054 | * AuthService BiometricManager |
| 4055 | * BiometricService N/A |
| 4056 | * |
| 4057 | * @hide |
| 4058 | */ |
| 4059 | public static final String AUTH_SERVICE = "auth"; |
| 4060 | |
| 4061 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4062 | * Use with {@link #getSystemService(String)} to retrieve a |
Jim Miller | ce7eb6d | 2015-04-03 19:29:13 -0700 | [diff] [blame] | 4063 | * {@link android.hardware.fingerprint.FingerprintManager} for handling management |
Jim Miller | 08fa40c | 2014-04-29 18:18:47 -0700 | [diff] [blame] | 4064 | * of fingerprints. |
| 4065 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4066 | * @see #getSystemService(String) |
Jim Miller | ce7eb6d | 2015-04-03 19:29:13 -0700 | [diff] [blame] | 4067 | * @see android.hardware.fingerprint.FingerprintManager |
Jim Miller | 08fa40c | 2014-04-29 18:18:47 -0700 | [diff] [blame] | 4068 | */ |
| 4069 | public static final String FINGERPRINT_SERVICE = "fingerprint"; |
| 4070 | |
| 4071 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4072 | * Use with {@link #getSystemService(String)} to retrieve a |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 4073 | * {@link android.hardware.face.FaceManager} for handling management |
| 4074 | * of face authentication. |
| 4075 | * |
| 4076 | * @hide |
| 4077 | * @see #getSystemService |
| 4078 | * @see android.hardware.face.FaceManager |
| 4079 | */ |
| 4080 | public static final String FACE_SERVICE = "face"; |
| 4081 | |
| 4082 | /** |
Kevin Chyn | 05c2150 | 2018-09-18 13:07:19 -0700 | [diff] [blame] | 4083 | * Use with {@link #getSystemService(String)} to retrieve a |
Kevin Chyn | 51676d2 | 2018-11-05 18:00:43 -0800 | [diff] [blame] | 4084 | * {@link android.hardware.iris.IrisManager} for handling management |
| 4085 | * of iris authentication. |
| 4086 | * |
| 4087 | * @hide |
| 4088 | * @see #getSystemService |
| 4089 | * @see android.hardware.iris.IrisManager |
| 4090 | */ |
| 4091 | public static final String IRIS_SERVICE = "iris"; |
| 4092 | |
| 4093 | /** |
| 4094 | * Use with {@link #getSystemService(String)} to retrieve a |
Ilya Matyukhin | e4675b3 | 2019-11-07 16:07:19 -0800 | [diff] [blame] | 4095 | * {@link android.hardware.biometrics.BiometricManager} for handling |
| 4096 | * biometric and PIN/pattern/password authentication. |
Kevin Chyn | 05c2150 | 2018-09-18 13:07:19 -0700 | [diff] [blame] | 4097 | * |
| 4098 | * @see #getSystemService |
| 4099 | * @see android.hardware.biometrics.BiometricManager |
| 4100 | */ |
| 4101 | public static final String BIOMETRIC_SERVICE = "biometric"; |
| 4102 | |
| 4103 | /** |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 4104 | * Use with {@link #getSystemService} to retrieve a |
Dianne Hackborn | b58b8f8 | 2012-06-11 15:08:39 -0700 | [diff] [blame] | 4105 | * {@link android.media.MediaRouter} for controlling and managing |
| 4106 | * routing of media. |
| 4107 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4108 | * @see #getSystemService(String) |
Dianne Hackborn | b58b8f8 | 2012-06-11 15:08:39 -0700 | [diff] [blame] | 4109 | * @see android.media.MediaRouter |
| 4110 | */ |
| 4111 | public static final String MEDIA_ROUTER_SERVICE = "media_router"; |
| 4112 | |
| 4113 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4114 | * Use with {@link #getSystemService(String)} to retrieve a |
RoboErik | 42ea7ee | 2014-05-16 16:27:35 -0700 | [diff] [blame] | 4115 | * {@link android.media.session.MediaSessionManager} for managing media Sessions. |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 4116 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4117 | * @see #getSystemService(String) |
RoboErik | 42ea7ee | 2014-05-16 16:27:35 -0700 | [diff] [blame] | 4118 | * @see android.media.session.MediaSessionManager |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 4119 | */ |
| 4120 | public static final String MEDIA_SESSION_SERVICE = "media_session"; |
| 4121 | |
| 4122 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4123 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4124 | * {@link android.telephony.TelephonyManager} for handling management the |
| 4125 | * telephony features of the device. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4126 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4127 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4128 | * @see android.telephony.TelephonyManager |
| 4129 | */ |
| 4130 | public static final String TELEPHONY_SERVICE = "phone"; |
| 4131 | |
| 4132 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4133 | * Use with {@link #getSystemService(String)} to retrieve a |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 4134 | * {@link android.telephony.SubscriptionManager} for handling management the |
| 4135 | * telephony subscriptions of the device. |
| 4136 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4137 | * @see #getSystemService(String) |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 4138 | * @see android.telephony.SubscriptionManager |
| 4139 | */ |
| 4140 | public static final String TELEPHONY_SUBSCRIPTION_SERVICE = "telephony_subscription_service"; |
| 4141 | |
| 4142 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4143 | * Use with {@link #getSystemService(String)} to retrieve a |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 4144 | * {@link android.telecom.TelecomManager} to manage telecom-related features |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 4145 | * of the device. |
| 4146 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4147 | * @see #getSystemService(String) |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 4148 | * @see android.telecom.TelecomManager |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 4149 | */ |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 4150 | public static final String TELECOM_SERVICE = "telecom"; |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 4151 | |
| 4152 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4153 | * Use with {@link #getSystemService(String)} to retrieve a |
Jonathan Basseri | 9a1c9b6 | 2015-02-25 13:01:52 -0800 | [diff] [blame] | 4154 | * {@link android.telephony.CarrierConfigManager} for reading carrier configuration values. |
| 4155 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4156 | * @see #getSystemService(String) |
Jonathan Basseri | 9a1c9b6 | 2015-02-25 13:01:52 -0800 | [diff] [blame] | 4157 | * @see android.telephony.CarrierConfigManager |
| 4158 | */ |
| 4159 | public static final String CARRIER_CONFIG_SERVICE = "carrier_config"; |
| 4160 | |
| 4161 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4162 | * Use with {@link #getSystemService(String)} to retrieve a |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 4163 | * {@link android.telephony.euicc.EuiccManager} to manage the device eUICC (embedded SIM). |
| 4164 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4165 | * @see #getSystemService(String) |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 4166 | * @see android.telephony.euicc.EuiccManager |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 4167 | */ |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 4168 | public static final String EUICC_SERVICE = "euicc"; |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 4169 | |
| 4170 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4171 | * Use with {@link #getSystemService(String)} to retrieve a |
Holly Jiuyu Sun | 5c11024 | 2017-12-21 18:44:59 -0800 | [diff] [blame] | 4172 | * {@link android.telephony.euicc.EuiccCardManager} to access the device eUICC (embedded SIM). |
| 4173 | * |
| 4174 | * @see #getSystemService(String) |
| 4175 | * @see android.telephony.euicc.EuiccCardManager |
Holly Jiuyu Sun | 5c11024 | 2017-12-21 18:44:59 -0800 | [diff] [blame] | 4176 | * @hide |
| 4177 | */ |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 4178 | @SystemApi |
| 4179 | public static final String EUICC_CARD_SERVICE = "euicc_card"; |
Holly Jiuyu Sun | 5c11024 | 2017-12-21 18:44:59 -0800 | [diff] [blame] | 4180 | |
| 4181 | /** |
| 4182 | * Use with {@link #getSystemService(String)} to retrieve a |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 4183 | * {@link android.content.ClipboardManager} for accessing and modifying |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4184 | * the contents of the global clipboard. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4185 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4186 | * @see #getSystemService(String) |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 4187 | * @see android.content.ClipboardManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4188 | */ |
| 4189 | public static final String CLIPBOARD_SERVICE = "clipboard"; |
| 4190 | |
| 4191 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4192 | * Use with {@link #getSystemService(String)} to retrieve a |
Abodunrinwa Toki | f001fef | 2017-01-04 23:51:42 +0000 | [diff] [blame] | 4193 | * {@link TextClassificationManager} for text classification services. |
Abodunrinwa Toki | 8158af5 | 2016-11-23 20:41:09 +0000 | [diff] [blame] | 4194 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4195 | * @see #getSystemService(String) |
Abodunrinwa Toki | f001fef | 2017-01-04 23:51:42 +0000 | [diff] [blame] | 4196 | * @see TextClassificationManager |
Abodunrinwa Toki | 8158af5 | 2016-11-23 20:41:09 +0000 | [diff] [blame] | 4197 | */ |
| 4198 | public static final String TEXT_CLASSIFICATION_SERVICE = "textclassification"; |
| 4199 | |
| 4200 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4201 | * Use with {@link #getSystemService(String)} to retrieve a |
Alex Salo | 5f5b5f4 | 2019-02-27 10:49:00 -0800 | [diff] [blame] | 4202 | * {@link com.android.server.attention.AttentionManagerService} for attention services. |
| 4203 | * |
| 4204 | * @see #getSystemService(String) |
| 4205 | * @see android.server.attention.AttentionManagerService |
| 4206 | * @hide |
| 4207 | */ |
| 4208 | public static final String ATTENTION_SERVICE = "attention"; |
| 4209 | |
| 4210 | /** |
| 4211 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4212 | * {@link android.view.inputmethod.InputMethodManager} for accessing input |
| 4213 | * methods. |
| 4214 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4215 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4216 | */ |
| 4217 | public static final String INPUT_METHOD_SERVICE = "input_method"; |
| 4218 | |
| 4219 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4220 | * Use with {@link #getSystemService(String)} to retrieve a |
satok | 988323c | 2011-06-22 16:38:13 +0900 | [diff] [blame] | 4221 | * {@link android.view.textservice.TextServicesManager} for accessing |
| 4222 | * text services. |
| 4223 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4224 | * @see #getSystemService(String) |
satok | 988323c | 2011-06-22 16:38:13 +0900 | [diff] [blame] | 4225 | */ |
| 4226 | public static final String TEXT_SERVICES_MANAGER_SERVICE = "textservices"; |
| 4227 | |
| 4228 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4229 | * Use with {@link #getSystemService(String)} to retrieve a |
Dan Egnor | e38d58b | 2009-12-30 19:29:03 -0800 | [diff] [blame] | 4230 | * {@link android.appwidget.AppWidgetManager} for accessing AppWidgets. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4231 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4232 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4233 | */ |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 4234 | public static final String APPWIDGET_SERVICE = "appwidget"; |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 4235 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4236 | /** |
Dianne Hackborn | 91097de | 2014-04-04 18:02:06 -0700 | [diff] [blame] | 4237 | * Official published name of the (internal) voice interaction manager service. |
| 4238 | * |
| 4239 | * @hide |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4240 | * @see #getSystemService(String) |
Dianne Hackborn | 91097de | 2014-04-04 18:02:06 -0700 | [diff] [blame] | 4241 | */ |
| 4242 | public static final String VOICE_INTERACTION_MANAGER_SERVICE = "voiceinteraction"; |
| 4243 | |
| 4244 | /** |
Felipe Leme | 640f30a | 2017-03-06 15:44:06 -0800 | [diff] [blame] | 4245 | * Official published name of the (internal) autofill service. |
Felipe Leme | 5381aa4 | 2016-10-13 09:02:32 -0700 | [diff] [blame] | 4246 | * |
| 4247 | * @hide |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4248 | * @see #getSystemService(String) |
Felipe Leme | 5381aa4 | 2016-10-13 09:02:32 -0700 | [diff] [blame] | 4249 | */ |
Felipe Leme | 640f30a | 2017-03-06 15:44:06 -0800 | [diff] [blame] | 4250 | public static final String AUTOFILL_MANAGER_SERVICE = "autofill"; |
Felipe Leme | 5381aa4 | 2016-10-13 09:02:32 -0700 | [diff] [blame] | 4251 | |
| 4252 | /** |
Felipe Leme | 749b889 | 2018-12-03 16:30:30 -0800 | [diff] [blame] | 4253 | * Official published name of the content capture service. |
Felipe Leme | e348dc3 | 2018-11-05 12:35:29 -0800 | [diff] [blame] | 4254 | * |
| 4255 | * @hide |
| 4256 | * @see #getSystemService(String) |
| 4257 | */ |
Felipe Leme | a7e4ca6 | 2019-05-23 13:32:40 -0700 | [diff] [blame] | 4258 | @TestApi |
Felipe Leme | 749b889 | 2018-12-03 16:30:30 -0800 | [diff] [blame] | 4259 | public static final String CONTENT_CAPTURE_MANAGER_SERVICE = "content_capture"; |
Felipe Leme | e348dc3 | 2018-11-05 12:35:29 -0800 | [diff] [blame] | 4260 | |
| 4261 | /** |
Winson Chung | 3fb0f25 | 2019-01-08 17:41:55 -0800 | [diff] [blame] | 4262 | * Used for getting content selections and classifications for task snapshots. |
| 4263 | * |
| 4264 | * @hide |
| 4265 | * @see #getSystemService(String) |
| 4266 | */ |
| 4267 | @SystemApi |
| 4268 | public static final String CONTENT_SUGGESTIONS_SERVICE = "content_suggestions"; |
| 4269 | |
| 4270 | /** |
Sunny Goyal | 54e9134 | 2018-11-14 11:59:02 -0800 | [diff] [blame] | 4271 | * Official published name of the app prediction service. |
| 4272 | * |
Felipe Leme | 6378bd4 | 2019-08-14 18:14:55 -0700 | [diff] [blame] | 4273 | * <p><b>NOTE: </b> this service is optional; callers of |
| 4274 | * {@code Context.getSystemServiceName(APP_PREDICTION_SERVICE)} should check for {@code null}. |
| 4275 | * |
Sunny Goyal | 54e9134 | 2018-11-14 11:59:02 -0800 | [diff] [blame] | 4276 | * @hide |
| 4277 | * @see #getSystemService(String) |
| 4278 | */ |
| 4279 | @SystemApi |
| 4280 | public static final String APP_PREDICTION_SERVICE = "app_prediction"; |
| 4281 | |
| 4282 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4283 | * Use with {@link #getSystemService(String)} to access the |
Arunesh Mishra | a772e5f | 2016-01-25 10:33:11 -0800 | [diff] [blame] | 4284 | * {@link com.android.server.voiceinteraction.SoundTriggerService}. |
| 4285 | * |
| 4286 | * @hide |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4287 | * @see #getSystemService(String) |
Arunesh Mishra | a772e5f | 2016-01-25 10:33:11 -0800 | [diff] [blame] | 4288 | */ |
| 4289 | public static final String SOUND_TRIGGER_SERVICE = "soundtrigger"; |
| 4290 | |
Philip P. Moltmann | 039678e | 2018-09-18 13:04:38 -0700 | [diff] [blame] | 4291 | /** |
| 4292 | * Official published name of the (internal) permission service. |
| 4293 | * |
| 4294 | * @see #getSystemService(String) |
| 4295 | * @hide |
| 4296 | */ |
Winson | f27394e | 2019-06-07 14:44:40 -0700 | [diff] [blame] | 4297 | @TestApi |
Philip P. Moltmann | 039678e | 2018-09-18 13:04:38 -0700 | [diff] [blame] | 4298 | @SystemApi |
| 4299 | public static final String PERMISSION_SERVICE = "permission"; |
Arunesh Mishra | a772e5f | 2016-01-25 10:33:11 -0800 | [diff] [blame] | 4300 | |
| 4301 | /** |
Philip P. Moltmann | bc054d8 | 2018-12-21 09:41:58 -0800 | [diff] [blame] | 4302 | * Official published name of the (internal) permission controller service. |
| 4303 | * |
| 4304 | * @see #getSystemService(String) |
| 4305 | * @hide |
| 4306 | */ |
| 4307 | public static final String PERMISSION_CONTROLLER_SERVICE = "permission_controller"; |
| 4308 | |
| 4309 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4310 | * Use with {@link #getSystemService(String)} to retrieve an |
Christopher Tate | 4528186 | 2010-03-05 15:46:30 -0800 | [diff] [blame] | 4311 | * {@link android.app.backup.IBackupManager IBackupManager} for communicating |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 4312 | * with the backup mechanism. |
Dianne Hackborn | 7f20543 | 2009-07-28 00:13:47 -0700 | [diff] [blame] | 4313 | * @hide |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4314 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4315 | * @see #getSystemService(String) |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 4316 | */ |
Christopher Tate | d5cf722 | 2014-07-29 16:53:09 -0700 | [diff] [blame] | 4317 | @SystemApi |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 4318 | public static final String BACKUP_SERVICE = "backup"; |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 4319 | |
| 4320 | /** |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 4321 | * Use with {@link #getSystemService(String)} to retrieve an |
| 4322 | * {@link android.content.rollback.RollbackManager} for communicating |
| 4323 | * with the rollback manager |
| 4324 | * |
| 4325 | * @see #getSystemService(String) |
Richard Uhler | c739c8c | 2018-12-12 11:03:34 +0000 | [diff] [blame] | 4326 | * @hide |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 4327 | */ |
Richard Uhler | 8a97745 | 2019-03-08 13:27:17 +0000 | [diff] [blame] | 4328 | @SystemApi @TestApi |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 4329 | public static final String ROLLBACK_SERVICE = "rollback"; |
| 4330 | |
| 4331 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4332 | * Use with {@link #getSystemService(String)} to retrieve a |
Dan Egnor | 1337b01 | 2010-01-04 11:01:44 -0800 | [diff] [blame] | 4333 | * {@link android.os.DropBoxManager} instance for recording |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 4334 | * diagnostic logs. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4335 | * @see #getSystemService(String) |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 4336 | */ |
| 4337 | public static final String DROPBOX_SERVICE = "dropbox"; |
| 4338 | |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 4339 | /** |
Philip P. Moltmann | f80809f | 2018-04-04 11:20:44 -0700 | [diff] [blame] | 4340 | * System service name for the DeviceIdleManager. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4341 | * @see #getSystemService(String) |
Dianne Hackborn | 1958e5e | 2015-06-12 18:11:41 -0700 | [diff] [blame] | 4342 | * @hide |
| 4343 | */ |
Makoto Onuki | 7d6d9ca | 2019-08-13 11:45:45 -0700 | [diff] [blame] | 4344 | @TestApi |
Dianne Hackborn | 1958e5e | 2015-06-12 18:11:41 -0700 | [diff] [blame] | 4345 | public static final String DEVICE_IDLE_CONTROLLER = "deviceidle"; |
| 4346 | |
| 4347 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4348 | * Use with {@link #getSystemService(String)} to retrieve a |
Dianne Hackborn | 87bba1e | 2010-02-26 17:25:54 -0800 | [diff] [blame] | 4349 | * {@link android.app.admin.DevicePolicyManager} for working with global |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 4350 | * device policy management. |
| 4351 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4352 | * @see #getSystemService(String) |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 4353 | */ |
| 4354 | public static final String DEVICE_POLICY_SERVICE = "device_policy"; |
| 4355 | |
| 4356 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4357 | * Use with {@link #getSystemService(String)} to retrieve a |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 4358 | * {@link android.app.UiModeManager} for controlling UI modes. |
| 4359 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4360 | * @see #getSystemService(String) |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 4361 | */ |
| 4362 | public static final String UI_MODE_SERVICE = "uimode"; |
| 4363 | |
| 4364 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4365 | * Use with {@link #getSystemService(String)} to retrieve a |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 4366 | * {@link android.app.DownloadManager} for requesting HTTP downloads. |
Steve Howard | a270936 | 2010-07-02 17:12:48 -0700 | [diff] [blame] | 4367 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4368 | * @see #getSystemService(String) |
Steve Howard | a270936 | 2010-07-02 17:12:48 -0700 | [diff] [blame] | 4369 | */ |
| 4370 | public static final String DOWNLOAD_SERVICE = "download"; |
| 4371 | |
| 4372 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4373 | * Use with {@link #getSystemService(String)} to retrieve a |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 4374 | * {@link android.os.BatteryManager} for managing battery state. |
| 4375 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4376 | * @see #getSystemService(String) |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 4377 | */ |
| 4378 | public static final String BATTERY_SERVICE = "batterymanager"; |
| 4379 | |
| 4380 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4381 | * Use with {@link #getSystemService(String)} to retrieve a |
Nick Pelly | 50b4d8f | 2010-12-07 22:40:28 -0800 | [diff] [blame] | 4382 | * {@link android.nfc.NfcManager} for using NFC. |
| 4383 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4384 | * @see #getSystemService(String) |
Nick Pelly | 50b4d8f | 2010-12-07 22:40:28 -0800 | [diff] [blame] | 4385 | */ |
| 4386 | public static final String NFC_SERVICE = "nfc"; |
| 4387 | |
| 4388 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4389 | * Use with {@link #getSystemService(String)} to retrieve a |
Florian Salbrechter | 084da9b | 2015-03-25 11:00:55 +0000 | [diff] [blame] | 4390 | * {@link android.bluetooth.BluetoothManager} for using Bluetooth. |
Jaikumar Ganesh | 1abb1cb | 2012-01-25 16:14:50 -0800 | [diff] [blame] | 4391 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4392 | * @see #getSystemService(String) |
Jaikumar Ganesh | 1abb1cb | 2012-01-25 16:14:50 -0800 | [diff] [blame] | 4393 | */ |
| 4394 | public static final String BLUETOOTH_SERVICE = "bluetooth"; |
| 4395 | |
| 4396 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4397 | * Use with {@link #getSystemService(String)} to retrieve a |
Chung-yih Wang | 2d94231 | 2010-08-05 12:17:37 +0800 | [diff] [blame] | 4398 | * {@link android.net.sip.SipManager} for accessing the SIP related service. |
| 4399 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4400 | * @see #getSystemService(String) |
Chung-yih Wang | 2d94231 | 2010-08-05 12:17:37 +0800 | [diff] [blame] | 4401 | */ |
| 4402 | /** @hide */ |
| 4403 | public static final String SIP_SERVICE = "sip"; |
| 4404 | |
| 4405 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4406 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Mike Lockwood | c4308f0 | 2011-03-01 08:04:54 -0800 | [diff] [blame] | 4407 | * 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] | 4408 | * and for controlling this device's behavior as a USB device. |
| 4409 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4410 | * @see #getSystemService(String) |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4411 | * @see android.hardware.usb.UsbManager |
Mike Lockwood | e7d511e | 2010-12-30 13:39:37 -0500 | [diff] [blame] | 4412 | */ |
| 4413 | public static final String USB_SERVICE = "usb"; |
| 4414 | |
| 4415 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4416 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Kenny Root | f74bfde | 2018-01-18 15:42:48 -0800 | [diff] [blame] | 4417 | * Use with {@link #getSystemService} to retrieve a {@link |
| 4418 | * android.debug.AdbManager} for access to ADB debug functions. |
| 4419 | * |
| 4420 | * @see #getSystemService(String) |
| 4421 | * @see android.debug.AdbManager |
| 4422 | * |
| 4423 | * @hide |
| 4424 | */ |
| 4425 | public static final String ADB_SERVICE = "adb"; |
| 4426 | |
| 4427 | /** |
| 4428 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Mike Lockwood | b01e8bf | 2011-08-29 20:11:07 -0400 | [diff] [blame] | 4429 | * android.hardware.SerialManager} for access to serial ports. |
| 4430 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4431 | * @see #getSystemService(String) |
Dianne Hackborn | 35f72be | 2013-09-16 10:57:39 -0700 | [diff] [blame] | 4432 | * @see android.hardware.SerialManager |
Mike Lockwood | b01e8bf | 2011-08-29 20:11:07 -0400 | [diff] [blame] | 4433 | * |
| 4434 | * @hide |
| 4435 | */ |
| 4436 | public static final String SERIAL_SERVICE = "serial"; |
| 4437 | |
| 4438 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4439 | * Use with {@link #getSystemService(String)} to retrieve a |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 4440 | * {@link android.hardware.hdmi.HdmiControlManager} for controlling and managing |
| 4441 | * HDMI-CEC protocol. |
| 4442 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4443 | * @see #getSystemService(String) |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 4444 | * @see android.hardware.hdmi.HdmiControlManager |
Jinsuk Kim | 66d1eb2 | 2014-06-06 16:12:18 +0900 | [diff] [blame] | 4445 | * @hide |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 4446 | */ |
Jinsuk Kim | 66d1eb2 | 2014-06-06 16:12:18 +0900 | [diff] [blame] | 4447 | @SystemApi |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 4448 | public static final String HDMI_CONTROL_SERVICE = "hdmi_control"; |
Jinsuk Kim | fbcd503 | 2014-03-21 16:25:13 +0900 | [diff] [blame] | 4449 | |
| 4450 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4451 | * Use with {@link #getSystemService(String)} to retrieve a |
Jeff Brown | 9df6e7a | 2012-04-05 11:49:26 -0700 | [diff] [blame] | 4452 | * {@link android.hardware.input.InputManager} for interacting with input devices. |
| 4453 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4454 | * @see #getSystemService(String) |
Jeff Brown | 9df6e7a | 2012-04-05 11:49:26 -0700 | [diff] [blame] | 4455 | * @see android.hardware.input.InputManager |
| 4456 | */ |
| 4457 | public static final String INPUT_SERVICE = "input"; |
| 4458 | |
| 4459 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4460 | * Use with {@link #getSystemService(String)} to retrieve a |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 4461 | * {@link android.hardware.display.DisplayManager} for interacting with display devices. |
| 4462 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4463 | * @see #getSystemService(String) |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 4464 | * @see android.hardware.display.DisplayManager |
| 4465 | */ |
| 4466 | public static final String DISPLAY_SERVICE = "display"; |
| 4467 | |
| 4468 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4469 | * Use with {@link #getSystemService(String)} to retrieve a |
Christine Franks | 39b0311 | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 4470 | * {@link android.hardware.display.ColorDisplayManager} for controlling color transforms. |
| 4471 | * |
| 4472 | * @see #getSystemService(String) |
| 4473 | * @see android.hardware.display.ColorDisplayManager |
| 4474 | * @hide |
| 4475 | */ |
| 4476 | public static final String COLOR_DISPLAY_SERVICE = "color_display"; |
| 4477 | |
| 4478 | /** |
| 4479 | * Use with {@link #getSystemService(String)} to retrieve a |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 4480 | * {@link android.os.UserManager} for managing users on devices that support multiple users. |
| 4481 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4482 | * @see #getSystemService(String) |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 4483 | * @see android.os.UserManager |
| 4484 | */ |
| 4485 | public static final String USER_SERVICE = "user"; |
| 4486 | |
| 4487 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4488 | * Use with {@link #getSystemService(String)} to retrieve a |
Amith Yamasani | 4f58263 | 2014-02-19 14:31:52 -0800 | [diff] [blame] | 4489 | * {@link android.content.pm.LauncherApps} for querying and monitoring launchable apps across |
| 4490 | * profiles of a user. |
| 4491 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4492 | * @see #getSystemService(String) |
Amith Yamasani | 4f58263 | 2014-02-19 14:31:52 -0800 | [diff] [blame] | 4493 | * @see android.content.pm.LauncherApps |
| 4494 | */ |
| 4495 | public static final String LAUNCHER_APPS_SERVICE = "launcherapps"; |
| 4496 | |
| 4497 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4498 | * Use with {@link #getSystemService(String)} to retrieve a |
Amith Yamasani | f20d640 | 2014-05-24 15:34:37 -0700 | [diff] [blame] | 4499 | * {@link android.content.RestrictionsManager} for retrieving application restrictions |
| 4500 | * and requesting permissions for restricted operations. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4501 | * @see #getSystemService(String) |
Amith Yamasani | f20d640 | 2014-05-24 15:34:37 -0700 | [diff] [blame] | 4502 | * @see android.content.RestrictionsManager |
| 4503 | */ |
| 4504 | public static final String RESTRICTIONS_SERVICE = "restrictions"; |
| 4505 | |
| 4506 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4507 | * Use with {@link #getSystemService(String)} to retrieve a |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 4508 | * {@link android.app.AppOpsManager} for tracking application operations |
| 4509 | * on the device. |
| 4510 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4511 | * @see #getSystemService(String) |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 4512 | * @see android.app.AppOpsManager |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 4513 | */ |
| 4514 | public static final String APP_OPS_SERVICE = "appops"; |
| 4515 | |
| 4516 | /** |
Hai Zhang | b777668 | 2018-09-25 15:10:57 -0700 | [diff] [blame] | 4517 | * Use with {@link #getSystemService(String)} to retrieve a {@link android.app.role.RoleManager} |
| 4518 | * for managing roles. |
| 4519 | * |
| 4520 | * @see #getSystemService(String) |
| 4521 | * @see android.app.role.RoleManager |
| 4522 | */ |
| 4523 | public static final String ROLE_SERVICE = "role"; |
| 4524 | |
| 4525 | /** |
Hai Zhang | a4959e5 | 2019-03-06 12:21:07 -0800 | [diff] [blame] | 4526 | * Official published name of the (internal) role controller service. |
| 4527 | * |
| 4528 | * @see #getSystemService(String) |
| 4529 | * @see android.app.role.RoleControllerService |
| 4530 | * |
| 4531 | * @hide |
| 4532 | */ |
| 4533 | public static final String ROLE_CONTROLLER_SERVICE = "role_controller"; |
| 4534 | |
| 4535 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4536 | * Use with {@link #getSystemService(String)} to retrieve a |
Eino-Ville Talvala | 2f1a2e4 | 2013-07-25 17:12:05 -0700 | [diff] [blame] | 4537 | * {@link android.hardware.camera2.CameraManager} for interacting with |
Eino-Ville Talvala | b267554 | 2012-12-12 13:29:45 -0800 | [diff] [blame] | 4538 | * camera devices. |
| 4539 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4540 | * @see #getSystemService(String) |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 4541 | * @see android.hardware.camera2.CameraManager |
Eino-Ville Talvala | b267554 | 2012-12-12 13:29:45 -0800 | [diff] [blame] | 4542 | */ |
| 4543 | public static final String CAMERA_SERVICE = "camera"; |
| 4544 | |
| 4545 | /** |
Svetoslav Ganov | 4b9a4d1 | 2013-06-11 15:20:06 -0700 | [diff] [blame] | 4546 | * {@link android.print.PrintManager} for printing and managing |
Jeff Brown | 511cd35 | 2013-08-23 17:43:37 -0700 | [diff] [blame] | 4547 | * printers and print tasks. |
Svetoslav Ganov | 4b9a4d1 | 2013-06-11 15:20:06 -0700 | [diff] [blame] | 4548 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4549 | * @see #getSystemService(String) |
Svetoslav Ganov | 4b9a4d1 | 2013-06-11 15:20:06 -0700 | [diff] [blame] | 4550 | * @see android.print.PrintManager |
| 4551 | */ |
| 4552 | public static final String PRINT_SERVICE = "print"; |
| 4553 | |
| 4554 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4555 | * Use with {@link #getSystemService(String)} to retrieve a |
Eugene Susla | 6ed45d8 | 2017-01-22 13:52:51 -0800 | [diff] [blame] | 4556 | * {@link android.companion.CompanionDeviceManager} for managing companion devices |
| 4557 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4558 | * @see #getSystemService(String) |
Eugene Susla | 6ed45d8 | 2017-01-22 13:52:51 -0800 | [diff] [blame] | 4559 | * @see android.companion.CompanionDeviceManager |
| 4560 | */ |
Eugene Susla | d7355cc | 2017-04-20 11:14:45 -0700 | [diff] [blame] | 4561 | public static final String COMPANION_DEVICE_SERVICE = "companiondevice"; |
Eugene Susla | 6ed45d8 | 2017-01-22 13:52:51 -0800 | [diff] [blame] | 4562 | |
| 4563 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4564 | * Use with {@link #getSystemService(String)} to retrieve a |
Erik Gilling | 51e95df | 2013-06-26 11:06:51 -0700 | [diff] [blame] | 4565 | * {@link android.hardware.ConsumerIrManager} for transmitting infrared |
| 4566 | * signals from the device. |
| 4567 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4568 | * @see #getSystemService(String) |
Erik Gilling | 51e95df | 2013-06-26 11:06:51 -0700 | [diff] [blame] | 4569 | * @see android.hardware.ConsumerIrManager |
| 4570 | */ |
| 4571 | public static final String CONSUMER_IR_SERVICE = "consumer_ir"; |
| 4572 | |
| 4573 | /** |
Adrian Roos | 82142c2 | 2014-03-27 14:56:59 +0100 | [diff] [blame] | 4574 | * {@link android.app.trust.TrustManager} for managing trust agents. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4575 | * @see #getSystemService(String) |
Adrian Roos | 82142c2 | 2014-03-27 14:56:59 +0100 | [diff] [blame] | 4576 | * @see android.app.trust.TrustManager |
| 4577 | * @hide |
| 4578 | */ |
| 4579 | public static final String TRUST_SERVICE = "trust"; |
| 4580 | |
| 4581 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4582 | * Use with {@link #getSystemService(String)} to retrieve a |
Jae Seo | d5cc4a2 | 2014-05-30 16:57:43 -0700 | [diff] [blame] | 4583 | * {@link android.media.tv.TvInputManager} for interacting with TV inputs |
| 4584 | * on the device. |
Jae Seo | 3957091 | 2014-02-20 18:23:25 -0800 | [diff] [blame] | 4585 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4586 | * @see #getSystemService(String) |
Jae Seo | d5cc4a2 | 2014-05-30 16:57:43 -0700 | [diff] [blame] | 4587 | * @see android.media.tv.TvInputManager |
Jae Seo | 3957091 | 2014-02-20 18:23:25 -0800 | [diff] [blame] | 4588 | */ |
| 4589 | public static final String TV_INPUT_SERVICE = "tv_input"; |
| 4590 | |
| 4591 | /** |
Jeff Davidson | b51e0a6 | 2014-04-09 12:38:15 -0700 | [diff] [blame] | 4592 | * {@link android.net.NetworkScoreManager} for managing network scoring. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4593 | * @see #getSystemService(String) |
Jeff Davidson | b51e0a6 | 2014-04-09 12:38:15 -0700 | [diff] [blame] | 4594 | * @see android.net.NetworkScoreManager |
| 4595 | * @hide |
| 4596 | */ |
Jeff Davidson | 5ad2079 | 2014-07-21 13:55:42 -0700 | [diff] [blame] | 4597 | @SystemApi |
Jeff Davidson | b51e0a6 | 2014-04-09 12:38:15 -0700 | [diff] [blame] | 4598 | public static final String NETWORK_SCORE_SERVICE = "network_score"; |
| 4599 | |
| 4600 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4601 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Adam Lesinski | aa60767 | 2014-11-24 11:27:50 -0800 | [diff] [blame] | 4602 | * android.app.usage.UsageStatsManager} for querying device usage stats. |
Dianne Hackborn | e22b3b1 | 2014-05-07 18:06:44 -0700 | [diff] [blame] | 4603 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4604 | * @see #getSystemService(String) |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 4605 | * @see android.app.usage.UsageStatsManager |
Dianne Hackborn | e22b3b1 | 2014-05-07 18:06:44 -0700 | [diff] [blame] | 4606 | */ |
| 4607 | public static final String USAGE_STATS_SERVICE = "usagestats"; |
| 4608 | |
| 4609 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4610 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 4611 | * android.app.job.JobScheduler} instance for managing occasional |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 4612 | * background tasks. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4613 | * @see #getSystemService(String) |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 4614 | * @see android.app.job.JobScheduler |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 4615 | */ |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 4616 | public static final String JOB_SCHEDULER_SERVICE = "jobscheduler"; |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 4617 | |
| 4618 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4619 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Andres Morales | 33df937 | 2014-09-26 17:08:59 -0700 | [diff] [blame] | 4620 | * android.service.persistentdata.PersistentDataBlockManager} instance |
| 4621 | * for interacting with a storage device that lives across factory resets. |
| 4622 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4623 | * @see #getSystemService(String) |
Andres Morales | 68d4acd | 2014-07-01 19:40:41 -0700 | [diff] [blame] | 4624 | * @see android.service.persistentdata.PersistentDataBlockManager |
| 4625 | * @hide |
| 4626 | */ |
Andres Morales | 33df937 | 2014-09-26 17:08:59 -0700 | [diff] [blame] | 4627 | @SystemApi |
Andres Morales | 68d4acd | 2014-07-01 19:40:41 -0700 | [diff] [blame] | 4628 | public static final String PERSISTENT_DATA_BLOCK_SERVICE = "persistent_data_block"; |
| 4629 | |
| 4630 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4631 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Andrew Scull | 3b8b46f | 2017-02-13 18:12:15 +0000 | [diff] [blame] | 4632 | * android.service.oemlock.OemLockManager} instance for managing the OEM lock. |
| 4633 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4634 | * @see #getSystemService(String) |
Andrew Scull | 3b8b46f | 2017-02-13 18:12:15 +0000 | [diff] [blame] | 4635 | * @see android.service.oemlock.OemLockManager |
| 4636 | * @hide |
| 4637 | */ |
| 4638 | @SystemApi |
| 4639 | public static final String OEM_LOCK_SERVICE = "oem_lock"; |
| 4640 | |
| 4641 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4642 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 4643 | * android.media.projection.MediaProjectionManager} instance for managing |
| 4644 | * media projection sessions. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4645 | * @see #getSystemService(String) |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 4646 | * @see android.media.projection.MediaProjectionManager |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 4647 | */ |
| 4648 | public static final String MEDIA_PROJECTION_SERVICE = "media_projection"; |
| 4649 | |
| 4650 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4651 | * Use with {@link #getSystemService(String)} to retrieve a |
Mike Lockwood | b673770 | 2015-02-20 08:28:47 -0800 | [diff] [blame] | 4652 | * {@link android.media.midi.MidiManager} for accessing the MIDI service. |
Mike Lockwood | 67f8e8b | 2014-12-01 13:54:59 -0800 | [diff] [blame] | 4653 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4654 | * @see #getSystemService(String) |
Mike Lockwood | 67f8e8b | 2014-12-01 13:54:59 -0800 | [diff] [blame] | 4655 | */ |
| 4656 | public static final String MIDI_SERVICE = "midi"; |
| 4657 | |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 4658 | |
| 4659 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4660 | * Use with {@link #getSystemService(String)} to retrieve a |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 4661 | * {@link android.hardware.radio.RadioManager} for accessing the broadcast radio service. |
| 4662 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4663 | * @see #getSystemService(String) |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 4664 | * @hide |
| 4665 | */ |
Tomasz Wasilczyk | 9110df7 | 2017-06-22 07:57:20 -0700 | [diff] [blame] | 4666 | public static final String RADIO_SERVICE = "broadcastradio"; |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 4667 | |
Paul McLean | a33be21 | 2015-02-20 07:52:45 -0800 | [diff] [blame] | 4668 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4669 | * Use with {@link #getSystemService(String)} to retrieve a |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 4670 | * {@link android.os.HardwarePropertiesManager} for accessing the hardware properties service. |
| 4671 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4672 | * @see #getSystemService(String) |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 4673 | */ |
Polina Bondarenko | 8333c73 | 2016-03-09 18:08:42 +0100 | [diff] [blame] | 4674 | public static final String HARDWARE_PROPERTIES_SERVICE = "hardware_properties"; |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 4675 | |
| 4676 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4677 | * Use with {@link #getSystemService(String)} to retrieve a |
Wei Wang | bad7c20 | 2018-11-01 11:57:39 -0700 | [diff] [blame] | 4678 | * {@link android.os.ThermalService} for accessing the thermal service. |
| 4679 | * |
| 4680 | * @see #getSystemService(String) |
| 4681 | * @hide |
| 4682 | */ |
| 4683 | public static final String THERMAL_SERVICE = "thermalservice"; |
| 4684 | |
| 4685 | /** |
| 4686 | * Use with {@link #getSystemService(String)} to retrieve a |
Makoto Onuki | b5a012f | 2016-06-21 11:13:53 -0700 | [diff] [blame] | 4687 | * {@link android.content.pm.ShortcutManager} for accessing the launcher shortcut service. |
Makoto Onuki | 6f7362d9 | 2016-03-04 13:39:41 -0800 | [diff] [blame] | 4688 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4689 | * @see #getSystemService(String) |
Makoto Onuki | 6f7362d9 | 2016-03-04 13:39:41 -0800 | [diff] [blame] | 4690 | * @see android.content.pm.ShortcutManager |
| 4691 | */ |
| 4692 | public static final String SHORTCUT_SERVICE = "shortcut"; |
| 4693 | |
| 4694 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4695 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 4696 | * android.hardware.location.ContextHubManager} for accessing context hubs. |
| 4697 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4698 | * @see #getSystemService(String) |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 4699 | * @see android.hardware.location.ContextHubManager |
| 4700 | * |
| 4701 | * @hide |
| 4702 | */ |
| 4703 | @SystemApi |
| 4704 | public static final String CONTEXTHUB_SERVICE = "contexthub"; |
| 4705 | |
| 4706 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4707 | * Use with {@link #getSystemService(String)} to retrieve a |
Joe Onorato | 713fec8 | 2016-03-04 10:34:02 -0800 | [diff] [blame] | 4708 | * {@link android.os.health.SystemHealthManager} for accessing system health (battery, power, |
| 4709 | * memory, etc) metrics. |
| 4710 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4711 | * @see #getSystemService(String) |
Joe Onorato | 713fec8 | 2016-03-04 10:34:02 -0800 | [diff] [blame] | 4712 | */ |
| 4713 | public static final String SYSTEM_HEALTH_SERVICE = "systemhealth"; |
| 4714 | |
| 4715 | /** |
Amith Yamasani | d04aaa3 | 2016-06-13 12:09:36 -0700 | [diff] [blame] | 4716 | * Gatekeeper Service. |
| 4717 | * @hide |
| 4718 | */ |
| 4719 | public static final String GATEKEEPER_SERVICE = "android.service.gatekeeper.IGateKeeperService"; |
| 4720 | |
| 4721 | /** |
Svet Ganov | 37e4327 | 2016-09-09 16:01:32 -0700 | [diff] [blame] | 4722 | * Service defining the policy for access to device identifiers. |
| 4723 | * @hide |
| 4724 | */ |
| 4725 | public static final String DEVICE_IDENTIFIERS_SERVICE = "device_identifiers"; |
| 4726 | |
| 4727 | /** |
Joe Onorato | 1754d74 | 2016-11-21 17:51:35 -0800 | [diff] [blame] | 4728 | * Service to report a system health "incident" |
| 4729 | * @hide |
| 4730 | */ |
| 4731 | public static final String INCIDENT_SERVICE = "incident"; |
| 4732 | |
| 4733 | /** |
Joe Onorato | e21ab7e | 2018-12-18 15:00:25 -0800 | [diff] [blame] | 4734 | * Service to assist incidentd and dumpstated in reporting status to the user |
| 4735 | * and in confirming authorization to take an incident report or bugreport |
| 4736 | * @hide |
| 4737 | */ |
| 4738 | public static final String INCIDENT_COMPANION_SERVICE = "incidentcompanion"; |
| 4739 | |
| 4740 | /** |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 4741 | * Service to assist statsd in obtaining general stats. |
| 4742 | * @hide |
| 4743 | */ |
| 4744 | public static final String STATS_COMPANION_SERVICE = "statscompanion"; |
| 4745 | |
| 4746 | /** |
Bookatz | c697797 | 2018-01-16 16:55:05 -0800 | [diff] [blame] | 4747 | * Use with {@link #getSystemService(String)} to retrieve an {@link android.app.StatsManager}. |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 4748 | * @hide |
| 4749 | */ |
| 4750 | @SystemApi |
| 4751 | public static final String STATS_MANAGER = "stats"; |
| 4752 | |
| 4753 | /** |
atrost | de54a8ac | 2019-08-15 16:53:01 +0100 | [diff] [blame] | 4754 | * Use with {@link android.os.ServiceManager.getService()} to retrieve a |
| 4755 | * {@link IPlatformCompat} IBinder for communicating with the platform compat service. |
| 4756 | * @hide |
| 4757 | */ |
| 4758 | public static final String PLATFORM_COMPAT_SERVICE = "platform_compat"; |
| 4759 | |
| 4760 | /** |
atrost | 8748835 | 2019-10-10 19:27:31 +0100 | [diff] [blame] | 4761 | * Use with {@link android.os.ServiceManager.getService()} to retrieve a |
| 4762 | * {@link IPlatformCompatNative} IBinder for native code communicating with the platform compat |
| 4763 | * service. |
| 4764 | * @hide |
| 4765 | */ |
| 4766 | public static final String PLATFORM_COMPAT_NATIVE_SERVICE = "platform_compat_native"; |
| 4767 | |
| 4768 | /** |
Nandana Dutt | d11850c | 2018-12-12 17:26:57 +0000 | [diff] [blame] | 4769 | * Service to capture a bugreport. |
| 4770 | * @see #getSystemService(String) |
| 4771 | * @see android.os.BugreportManager |
| 4772 | * @hide |
| 4773 | */ |
Nandana Dutt | d7e8d5a | 2019-04-11 17:27:45 +0100 | [diff] [blame] | 4774 | @SystemApi @TestApi |
Nandana Dutt | d11850c | 2018-12-12 17:26:57 +0000 | [diff] [blame] | 4775 | public static final String BUGREPORT_SERVICE = "bugreport"; |
| 4776 | |
| 4777 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4778 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
MÃ¥rten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 4779 | * android.content.om.OverlayManager} for managing overlay packages. |
| 4780 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4781 | * @see #getSystemService(String) |
MÃ¥rten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 4782 | * @see android.content.om.OverlayManager |
| 4783 | * @hide |
| 4784 | */ |
| 4785 | public static final String OVERLAY_SERVICE = "overlay"; |
| 4786 | |
| 4787 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4788 | * Use with {@link #getSystemService(String)} to retrieve a |
MÃ¥rten Kongstad | 06a1ac8 | 2018-09-20 13:09:47 +0200 | [diff] [blame] | 4789 | * {android.os.IIdmap2} for managing idmap files (used by overlay |
| 4790 | * packages). |
| 4791 | * |
| 4792 | * @see #getSystemService(String) |
| 4793 | * @hide |
| 4794 | */ |
| 4795 | public static final String IDMAP_SERVICE = "idmap"; |
| 4796 | |
| 4797 | /** |
| 4798 | * Use with {@link #getSystemService(String)} to retrieve a |
Zak Cohen | 56345f4 | 2017-01-26 13:54:28 -0800 | [diff] [blame] | 4799 | * {@link VrManager} for accessing the VR service. |
| 4800 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4801 | * @see #getSystemService(String) |
Zak Cohen | 56345f4 | 2017-01-26 13:54:28 -0800 | [diff] [blame] | 4802 | * @hide |
| 4803 | */ |
| 4804 | @SystemApi |
| 4805 | public static final String VR_SERVICE = "vrmanager"; |
| 4806 | |
| 4807 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4808 | * Use with {@link #getSystemService(String)} to retrieve an |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 4809 | * {@link android.app.timezone.ITimeZoneRulesManager}. |
| 4810 | * @hide |
| 4811 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4812 | * @see #getSystemService(String) |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 4813 | */ |
| 4814 | public static final String TIME_ZONE_RULES_MANAGER_SERVICE = "timezone"; |
| 4815 | |
| 4816 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4817 | * Use with {@link #getSystemService(String)} to retrieve a |
Tony Mak | b0d2262 | 2018-01-18 12:49:49 +0000 | [diff] [blame] | 4818 | * {@link android.content.pm.CrossProfileApps} for cross profile operations. |
Tony Mak | 1b708e6 | 2017-10-12 10:59:11 +0100 | [diff] [blame] | 4819 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4820 | * @see #getSystemService(String) |
Tony Mak | 1b708e6 | 2017-10-12 10:59:11 +0100 | [diff] [blame] | 4821 | */ |
| 4822 | public static final String CROSS_PROFILE_APPS_SERVICE = "crossprofileapps"; |
| 4823 | |
| 4824 | /** |
Ruchi Kandoi | 6149b0f | 2018-01-03 16:14:57 -0800 | [diff] [blame] | 4825 | * Use with {@link #getSystemService} to retrieve a |
| 4826 | * {@link android.se.omapi.ISecureElementService} |
| 4827 | * for accessing the SecureElementService. |
| 4828 | * |
| 4829 | * @hide |
| 4830 | */ |
| 4831 | @SystemApi |
| 4832 | public static final String SECURE_ELEMENT_SERVICE = "secure_element"; |
| 4833 | |
| 4834 | /** |
Neil Fuller | feeee68 | 2018-05-30 14:35:24 +0100 | [diff] [blame] | 4835 | * Use with {@link #getSystemService(String)} to retrieve an |
| 4836 | * {@link android.app.timedetector.ITimeDetectorService}. |
| 4837 | * @hide |
| 4838 | * |
| 4839 | * @see #getSystemService(String) |
| 4840 | */ |
| 4841 | public static final String TIME_DETECTOR_SERVICE = "time_detector"; |
| 4842 | |
| 4843 | /** |
Makoto Onuki | df7e481 | 2018-09-24 14:31:25 -0700 | [diff] [blame] | 4844 | * Binder service name for {@link AppBindingService}. |
| 4845 | * @hide |
| 4846 | */ |
| 4847 | public static final String APP_BINDING_SERVICE = "app_binding"; |
| 4848 | |
| 4849 | /** |
Sahin Caliskan | 9458ebc | 2018-10-31 13:23:29 -0700 | [diff] [blame] | 4850 | * Use with {@link #getSystemService(String)} to retrieve an |
James.cf Lin | 2bc9cd4 | 2019-11-04 20:23:36 +0800 | [diff] [blame] | 4851 | * {@link android.telephony.ims.ImsManager}. |
| 4852 | * @hide |
| 4853 | */ |
| 4854 | public static final String TELEPHONY_IMS_SERVICE = "telephony_ims"; |
| 4855 | |
| 4856 | /** |
| 4857 | * Use with {@link #getSystemService(String)} to retrieve an |
Brad Ebinger | d1cb346 | 2019-06-20 14:20:01 -0700 | [diff] [blame] | 4858 | * {@link android.telephony.ims.RcsMessageManager}. |
Sahin Caliskan | 9458ebc | 2018-10-31 13:23:29 -0700 | [diff] [blame] | 4859 | * @hide |
| 4860 | */ |
Brad Ebinger | d1cb346 | 2019-06-20 14:20:01 -0700 | [diff] [blame] | 4861 | public static final String TELEPHONY_RCS_MESSAGE_SERVICE = "ircsmessage"; |
Sahin Caliskan | 9458ebc | 2018-10-31 13:23:29 -0700 | [diff] [blame] | 4862 | |
Howard Chen | 0a94764 | 2019-01-07 14:10:44 +0800 | [diff] [blame] | 4863 | /** |
| 4864 | * Use with {@link #getSystemService(String)} to retrieve an |
Po-Chien Hsueh | 4e908c2 | 2019-03-07 11:57:17 +0800 | [diff] [blame] | 4865 | * {@link android.os.image.DynamicSystemManager}. |
Howard Chen | 0a94764 | 2019-01-07 14:10:44 +0800 | [diff] [blame] | 4866 | * @hide |
| 4867 | */ |
Po-Chien Hsueh | 4e908c2 | 2019-03-07 11:57:17 +0800 | [diff] [blame] | 4868 | public static final String DYNAMIC_SYSTEM_SERVICE = "dynamic_system"; |
Howard Chen | 0a94764 | 2019-01-07 14:10:44 +0800 | [diff] [blame] | 4869 | |
Sahin Caliskan | 9458ebc | 2018-10-31 13:23:29 -0700 | [diff] [blame] | 4870 | /** |
Sudheer Shanka | f5b3696 | 2019-10-04 16:16:13 -0700 | [diff] [blame] | 4871 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
| 4872 | * android.app.blob.BlobStoreManager} for contributing and accessing data blobs |
| 4873 | * from the blob store maintained by the system. |
| 4874 | * |
| 4875 | * @see #getSystemService(String) |
| 4876 | * @see android.app.blob.BlobStoreManager |
| 4877 | * |
| 4878 | * TODO: make this public once BlobStoreManager is ready. |
| 4879 | * @hide |
| 4880 | */ |
| 4881 | @TestApi |
| 4882 | public static final String BLOB_STORE_SERVICE = "blob_store"; |
| 4883 | |
| 4884 | /** |
Chen Xu | 288b71c | 2019-09-15 18:28:21 -0700 | [diff] [blame] | 4885 | * Use with {@link #getSystemService(String)} to retrieve an |
Chen Xu | 1f6cfa5 | 2019-10-13 17:30:32 -0700 | [diff] [blame] | 4886 | * {@link TelephonyRegistryManager}. |
Chen Xu | 288b71c | 2019-09-15 18:28:21 -0700 | [diff] [blame] | 4887 | * @hide |
| 4888 | */ |
| 4889 | @SystemApi |
| 4890 | public static final String TELEPHONY_REGISTRY_SERVICE = "telephony_registry"; |
| 4891 | |
| 4892 | /** |
Roshan Pius | 848513e | 2019-10-11 13:44:00 -0700 | [diff] [blame] | 4893 | * Use with {@link #getSystemService(String)} to retrieve an |
| 4894 | * {@link android.os.BatteryStatsManager}. |
| 4895 | * @hide |
| 4896 | */ |
| 4897 | @SystemApi |
| 4898 | public static final String BATTERY_STATS_SERVICE = "batterystats"; |
| 4899 | |
| 4900 | /** |
Terry Wang | ecc0d1b | 2019-10-17 17:05:18 -0700 | [diff] [blame] | 4901 | * Use with {@link #getSystemService(String)} to retrieve an |
| 4902 | * AppSearchManager for indexing and querying app data managed |
| 4903 | * by the system. |
| 4904 | * |
| 4905 | * @see #getSystemService(String) |
| 4906 | */ |
| 4907 | public static final String APP_SEARCH_SERVICE = "app_search"; |
| 4908 | |
| 4909 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4910 | * Determine whether the given permission is allowed for a particular |
| 4911 | * process and user ID running in the system. |
| 4912 | * |
| 4913 | * @param permission The name of the permission 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. |
| 4917 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4918 | * @return {@link PackageManager#PERMISSION_GRANTED} if the given |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4919 | * pid/uid is allowed that permission, or |
| 4920 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4921 | * |
| 4922 | * @see PackageManager#checkPermission(String, String) |
| 4923 | * @see #checkCallingPermission |
| 4924 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4925 | @CheckResult(suggest="#enforcePermission(String,int,int,String)") |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4926 | @PackageManager.PermissionResult |
| 4927 | 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] | 4928 | |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 4929 | /** @hide */ |
| 4930 | @PackageManager.PermissionResult |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 4931 | @UnsupportedAppUsage |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 4932 | public abstract int checkPermission(@NonNull String permission, int pid, int uid, |
| 4933 | IBinder callerToken); |
| 4934 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4935 | /** |
| 4936 | * Determine whether the calling process of an IPC you are handling has been |
| 4937 | * granted a particular permission. This is basically the same as calling |
| 4938 | * {@link #checkPermission(String, int, int)} with the pid and uid returned |
| 4939 | * by {@link android.os.Binder#getCallingPid} and |
| 4940 | * {@link android.os.Binder#getCallingUid}. One important difference |
| 4941 | * is that if you are not currently processing an IPC, this function |
| 4942 | * will always fail. This is done to protect against accidentally |
| 4943 | * leaking permissions; you can use {@link #checkCallingOrSelfPermission} |
| 4944 | * to avoid this protection. |
| 4945 | * |
| 4946 | * @param permission The name of the permission being checked. |
| 4947 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4948 | * @return {@link PackageManager#PERMISSION_GRANTED} if the calling |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4949 | * pid/uid is allowed that permission, or |
| 4950 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4951 | * |
| 4952 | * @see PackageManager#checkPermission(String, String) |
| 4953 | * @see #checkPermission |
| 4954 | * @see #checkCallingOrSelfPermission |
| 4955 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4956 | @CheckResult(suggest="#enforceCallingPermission(String,String)") |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4957 | @PackageManager.PermissionResult |
| 4958 | public abstract int checkCallingPermission(@NonNull String permission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4959 | |
| 4960 | /** |
| 4961 | * Determine whether the calling process of an IPC <em>or you</em> have been |
| 4962 | * granted a particular permission. This is the same as |
| 4963 | * {@link #checkCallingPermission}, except it grants your own permissions |
| 4964 | * if you are not currently processing an IPC. Use with care! |
| 4965 | * |
| 4966 | * @param permission The name of the permission being checked. |
| 4967 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4968 | * @return {@link PackageManager#PERMISSION_GRANTED} if the calling |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4969 | * pid/uid is allowed that permission, or |
| 4970 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 4971 | * |
| 4972 | * @see PackageManager#checkPermission(String, String) |
| 4973 | * @see #checkPermission |
| 4974 | * @see #checkCallingPermission |
| 4975 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 4976 | @CheckResult(suggest="#enforceCallingOrSelfPermission(String,String)") |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 4977 | @PackageManager.PermissionResult |
| 4978 | public abstract int checkCallingOrSelfPermission(@NonNull String permission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4979 | |
| 4980 | /** |
Svetoslav | c6d1c34 | 2015-02-26 14:44:43 -0800 | [diff] [blame] | 4981 | * Determine whether <em>you</em> have been granted a particular permission. |
| 4982 | * |
| 4983 | * @param permission The name of the permission being checked. |
| 4984 | * |
| 4985 | * @return {@link PackageManager#PERMISSION_GRANTED} if you have the |
| 4986 | * permission, or {@link PackageManager#PERMISSION_DENIED} if not. |
| 4987 | * |
| 4988 | * @see PackageManager#checkPermission(String, String) |
| 4989 | * @see #checkCallingPermission(String) |
| 4990 | */ |
| 4991 | @PackageManager.PermissionResult |
| 4992 | public abstract int checkSelfPermission(@NonNull String permission); |
| 4993 | |
| 4994 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4995 | * If the given permission is not allowed for a particular process |
| 4996 | * and user ID running in the system, throw a {@link SecurityException}. |
| 4997 | * |
| 4998 | * @param permission The name of the permission being checked. |
| 4999 | * @param pid The process ID being checked against. Must be > 0. |
| 5000 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 5001 | * user, which will pass every permission check. |
| 5002 | * @param message A message to include in the exception if it is thrown. |
| 5003 | * |
| 5004 | * @see #checkPermission(String, int, int) |
| 5005 | */ |
| 5006 | public abstract void enforcePermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5007 | @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] | 5008 | |
| 5009 | /** |
| 5010 | * If the calling process of an IPC you are handling has not been |
| 5011 | * granted a particular permission, throw a {@link |
| 5012 | * SecurityException}. This is basically the same as calling |
| 5013 | * {@link #enforcePermission(String, int, int, String)} with the |
| 5014 | * pid and uid returned by {@link android.os.Binder#getCallingPid} |
| 5015 | * and {@link android.os.Binder#getCallingUid}. One important |
| 5016 | * difference is that if you are not currently processing an IPC, |
| 5017 | * this function will always throw the SecurityException. This is |
| 5018 | * done to protect against accidentally leaking permissions; you |
| 5019 | * can use {@link #enforceCallingOrSelfPermission} to avoid this |
| 5020 | * protection. |
| 5021 | * |
| 5022 | * @param permission The name of the permission being checked. |
| 5023 | * @param message A message to include in the exception if it is thrown. |
| 5024 | * |
| 5025 | * @see #checkCallingPermission(String) |
| 5026 | */ |
| 5027 | public abstract void enforceCallingPermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5028 | @NonNull String permission, @Nullable String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5029 | |
| 5030 | /** |
| 5031 | * If neither you nor the calling process of an IPC you are |
| 5032 | * handling has been granted a particular permission, throw a |
| 5033 | * {@link SecurityException}. This is the same as {@link |
| 5034 | * #enforceCallingPermission}, except it grants your own |
| 5035 | * permissions if you are not currently processing an IPC. Use |
| 5036 | * with care! |
| 5037 | * |
| 5038 | * @param permission The name of the permission being checked. |
| 5039 | * @param message A message to include in the exception if it is thrown. |
| 5040 | * |
| 5041 | * @see #checkCallingOrSelfPermission(String) |
| 5042 | */ |
| 5043 | public abstract void enforceCallingOrSelfPermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5044 | @NonNull String permission, @Nullable String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5045 | |
| 5046 | /** |
| 5047 | * Grant permission to access a specific Uri to another package, regardless |
| 5048 | * of whether that package has general permission to access the Uri's |
| 5049 | * content provider. This can be used to grant specific, temporary |
| 5050 | * permissions, typically in response to user interaction (such as the |
| 5051 | * user opening an attachment that you would like someone else to |
| 5052 | * display). |
| 5053 | * |
| 5054 | * <p>Normally you should use {@link Intent#FLAG_GRANT_READ_URI_PERMISSION |
| 5055 | * Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 5056 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
| 5057 | * Intent.FLAG_GRANT_WRITE_URI_PERMISSION} with the Intent being used to |
| 5058 | * start an activity instead of this function directly. If you use this |
| 5059 | * function directly, you should be sure to call |
| 5060 | * {@link #revokeUriPermission} when the target should no longer be allowed |
| 5061 | * to access it. |
| 5062 | * |
| 5063 | * <p>To succeed, the content provider owning the Uri must have set the |
| 5064 | * {@link android.R.styleable#AndroidManifestProvider_grantUriPermissions |
| 5065 | * grantUriPermissions} attribute in its manifest or included the |
| 5066 | * {@link android.R.styleable#AndroidManifestGrantUriPermission |
| 5067 | * <grant-uri-permissions>} tag. |
| 5068 | * |
| 5069 | * @param toPackage The package you would like to allow to access the Uri. |
| 5070 | * @param uri The Uri you would like to grant access to. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5071 | * @param modeFlags The desired access modes. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5072 | * |
| 5073 | * @see #revokeUriPermission |
| 5074 | */ |
| 5075 | public abstract void grantUriPermission(String toPackage, Uri uri, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5076 | @Intent.GrantUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5077 | |
| 5078 | /** |
| 5079 | * Remove all permissions to access a particular content provider Uri |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 5080 | * that were previously added with {@link #grantUriPermission} or <em>any other</em> mechanism. |
| 5081 | * 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] | 5082 | * 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] | 5083 | * revoke both "content://foo/target" and "content://foo/target/sub", but not |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5084 | * "content://foo". It will not remove any prefix grants that exist at a |
| 5085 | * higher level. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5086 | * |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 5087 | * <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] | 5088 | * regular permission access to a Uri, but had received access to it through |
| 5089 | * a specific Uri permission grant, you could not revoke that grant with this |
| 5090 | * function and a {@link SecurityException} would be thrown. As of |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 5091 | * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this function will not throw a security |
| 5092 | * 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] | 5093 | * (or none).</p> |
| 5094 | * |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 5095 | * <p>Unlike {@link #revokeUriPermission(String, Uri, int)}, this method impacts all permission |
| 5096 | * grants matching the given Uri, for any package they had been granted to, through any |
| 5097 | * mechanism this had happened (such as indirectly through the clipboard, activity launch, |
| 5098 | * service start, etc). That means this can be potentially dangerous to use, as it can |
| 5099 | * revoke grants that another app could be strongly expecting to stick around.</p> |
| 5100 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5101 | * @param uri The Uri you would like to revoke access to. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5102 | * @param modeFlags The access modes to revoke. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5103 | * |
| 5104 | * @see #grantUriPermission |
| 5105 | */ |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5106 | 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] | 5107 | |
| 5108 | /** |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 5109 | * Remove permissions to access a particular content provider Uri |
| 5110 | * that were previously added with {@link #grantUriPermission} for a specific target |
| 5111 | * package. The given Uri will match all previously granted Uris that are the same or a |
| 5112 | * sub-path of the given Uri. That is, revoking "content://foo/target" will |
| 5113 | * revoke both "content://foo/target" and "content://foo/target/sub", but not |
| 5114 | * "content://foo". It will not remove any prefix grants that exist at a |
| 5115 | * higher level. |
| 5116 | * |
| 5117 | * <p>Unlike {@link #revokeUriPermission(Uri, int)}, this method will <em>only</em> |
| 5118 | * revoke permissions that had been explicitly granted through {@link #grantUriPermission} |
| 5119 | * and only for the package specified. Any matching grants that have happened through |
| 5120 | * other mechanisms (clipboard, activity launching, service starting, etc) will not be |
| 5121 | * removed.</p> |
| 5122 | * |
| 5123 | * @param toPackage The package you had previously granted access to. |
| 5124 | * @param uri The Uri you would like to revoke access to. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5125 | * @param modeFlags The access modes to revoke. |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 5126 | * |
| 5127 | * @see #grantUriPermission |
| 5128 | */ |
| 5129 | public abstract void revokeUriPermission(String toPackage, Uri uri, |
| 5130 | @Intent.AccessUriMode int modeFlags); |
| 5131 | |
| 5132 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5133 | * Determine whether a particular process and user ID has been granted |
| 5134 | * permission to access a specific URI. This only checks for permissions |
| 5135 | * that have been explicitly granted -- if the given process/uid has |
| 5136 | * more general access to the URI's content provider then this check will |
| 5137 | * always fail. |
| 5138 | * |
| 5139 | * @param uri The uri that is being checked. |
| 5140 | * @param pid The process ID being checked against. Must be > 0. |
| 5141 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 5142 | * user, which will pass every permission check. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5143 | * @param modeFlags The access modes to check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5144 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5145 | * @return {@link PackageManager#PERMISSION_GRANTED} if the given |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5146 | * pid/uid is allowed to access that uri, or |
| 5147 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 5148 | * |
| 5149 | * @see #checkCallingUriPermission |
| 5150 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 5151 | @CheckResult(suggest="#enforceUriPermission(Uri,int,int,String)") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5152 | @PackageManager.PermissionResult |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5153 | public abstract int checkUriPermission(Uri uri, int pid, int uid, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5154 | @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5155 | |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 5156 | /** @hide */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5157 | @PackageManager.PermissionResult |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 5158 | public abstract int checkUriPermission(Uri uri, int pid, int uid, |
| 5159 | @Intent.AccessUriMode int modeFlags, IBinder callerToken); |
| 5160 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5161 | /** |
| 5162 | * Determine whether the calling process and user ID has been |
| 5163 | * granted permission to access a specific URI. This is basically |
| 5164 | * the same as calling {@link #checkUriPermission(Uri, int, int, |
| 5165 | * int)} with the pid and uid returned by {@link |
| 5166 | * android.os.Binder#getCallingPid} and {@link |
| 5167 | * android.os.Binder#getCallingUid}. One important difference is |
| 5168 | * that if you are not currently processing an IPC, this function |
| 5169 | * will always fail. |
| 5170 | * |
| 5171 | * @param uri The uri that is being checked. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5172 | * @param modeFlags The access modes to check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5173 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5174 | * @return {@link PackageManager#PERMISSION_GRANTED} if the caller |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5175 | * is allowed to access that uri, or |
| 5176 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 5177 | * |
| 5178 | * @see #checkUriPermission(Uri, int, int, int) |
| 5179 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 5180 | @CheckResult(suggest="#enforceCallingUriPermission(Uri,int,String)") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5181 | @PackageManager.PermissionResult |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5182 | 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] | 5183 | |
| 5184 | /** |
| 5185 | * Determine whether the calling process of an IPC <em>or you</em> has been granted |
| 5186 | * permission to access a specific URI. This is the same as |
| 5187 | * {@link #checkCallingUriPermission}, except it grants your own permissions |
| 5188 | * if you are not currently processing an IPC. Use with care! |
| 5189 | * |
| 5190 | * @param uri The uri that is being checked. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5191 | * @param modeFlags The access modes to check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5192 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5193 | * @return {@link PackageManager#PERMISSION_GRANTED} if the caller |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5194 | * is allowed to access that uri, or |
| 5195 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 5196 | * |
| 5197 | * @see #checkCallingUriPermission |
| 5198 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 5199 | @CheckResult(suggest="#enforceCallingOrSelfUriPermission(Uri,int,String)") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5200 | @PackageManager.PermissionResult |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5201 | public abstract int checkCallingOrSelfUriPermission(Uri uri, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5202 | @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5203 | |
| 5204 | /** |
| 5205 | * Check both a Uri and normal permission. This allows you to perform |
| 5206 | * both {@link #checkPermission} and {@link #checkUriPermission} in one |
| 5207 | * call. |
| 5208 | * |
| 5209 | * @param uri The Uri whose permission is to be checked, or null to not |
| 5210 | * do this check. |
| 5211 | * @param readPermission The permission that provides overall read access, |
| 5212 | * or null to not do this check. |
| 5213 | * @param writePermission The permission that provides overall write |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5214 | * access, or null to not do this check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5215 | * @param pid The process ID being checked against. Must be > 0. |
| 5216 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 5217 | * user, which will pass every permission check. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5218 | * @param modeFlags The access modes to check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5219 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5220 | * @return {@link PackageManager#PERMISSION_GRANTED} if the caller |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5221 | * is allowed to access that uri or holds one of the given permissions, or |
| 5222 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 5223 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 5224 | @CheckResult(suggest="#enforceUriPermission(Uri,String,String,int,int,int,String)") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5225 | @PackageManager.PermissionResult |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5226 | public abstract int checkUriPermission(@Nullable Uri uri, @Nullable String readPermission, |
| 5227 | @Nullable String writePermission, int pid, int uid, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5228 | @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5229 | |
| 5230 | /** |
| 5231 | * If a particular process and user ID has not been granted |
| 5232 | * permission to access a specific URI, throw {@link |
| 5233 | * SecurityException}. This only checks for permissions that have |
| 5234 | * been explicitly granted -- if the given process/uid has more |
| 5235 | * general access to the URI's content provider then this check |
| 5236 | * will always fail. |
| 5237 | * |
| 5238 | * @param uri The uri that is being checked. |
| 5239 | * @param pid The process ID being checked against. Must be > 0. |
| 5240 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 5241 | * user, which will pass every permission check. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5242 | * @param modeFlags The access modes to enforce. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5243 | * @param message A message to include in the exception if it is thrown. |
| 5244 | * |
| 5245 | * @see #checkUriPermission(Uri, int, int, int) |
| 5246 | */ |
| 5247 | public abstract void enforceUriPermission( |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5248 | 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] | 5249 | |
| 5250 | /** |
| 5251 | * If the calling process and user ID has not been granted |
| 5252 | * permission to access a specific URI, throw {@link |
| 5253 | * SecurityException}. This is basically the same as calling |
| 5254 | * {@link #enforceUriPermission(Uri, int, int, int, String)} with |
| 5255 | * the pid and uid returned by {@link |
| 5256 | * android.os.Binder#getCallingPid} and {@link |
| 5257 | * android.os.Binder#getCallingUid}. One important difference is |
| 5258 | * that if you are not currently processing an IPC, this function |
| 5259 | * will always throw a SecurityException. |
| 5260 | * |
| 5261 | * @param uri The uri that is being checked. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5262 | * @param modeFlags The access modes to enforce. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5263 | * @param message A message to include in the exception if it is thrown. |
| 5264 | * |
| 5265 | * @see #checkCallingUriPermission(Uri, int) |
| 5266 | */ |
| 5267 | public abstract void enforceCallingUriPermission( |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5268 | Uri uri, @Intent.AccessUriMode int modeFlags, String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5269 | |
| 5270 | /** |
| 5271 | * If the calling process of an IPC <em>or you</em> has not been |
| 5272 | * granted permission to access a specific URI, throw {@link |
| 5273 | * SecurityException}. This is the same as {@link |
| 5274 | * #enforceCallingUriPermission}, except it grants your own |
| 5275 | * permissions if you are not currently processing an IPC. Use |
| 5276 | * with care! |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 5277 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5278 | * @param uri The uri that is being checked. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5279 | * @param modeFlags The access modes to enforce. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5280 | * @param message A message to include in the exception if it is thrown. |
| 5281 | * |
| 5282 | * @see #checkCallingOrSelfUriPermission(Uri, int) |
| 5283 | */ |
| 5284 | public abstract void enforceCallingOrSelfUriPermission( |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5285 | Uri uri, @Intent.AccessUriMode int modeFlags, String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5286 | |
| 5287 | /** |
| 5288 | * Enforce both a Uri and normal permission. This allows you to perform |
| 5289 | * both {@link #enforcePermission} and {@link #enforceUriPermission} in one |
| 5290 | * call. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 5291 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5292 | * @param uri The Uri whose permission is to be checked, or null to not |
| 5293 | * do this check. |
| 5294 | * @param readPermission The permission that provides overall read access, |
| 5295 | * or null to not do this check. |
| 5296 | * @param writePermission The permission that provides overall write |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5297 | * access, or null to not do this check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5298 | * @param pid The process ID being checked against. Must be > 0. |
| 5299 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 5300 | * user, which will pass every permission check. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5301 | * @param modeFlags The access modes to enforce. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5302 | * @param message A message to include in the exception if it is thrown. |
| 5303 | * |
| 5304 | * @see #checkUriPermission(Uri, String, String, int, int, int) |
| 5305 | */ |
| 5306 | public abstract void enforceUriPermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5307 | @Nullable Uri uri, @Nullable String readPermission, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5308 | @Nullable String writePermission, int pid, int uid, @Intent.AccessUriMode int modeFlags, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5309 | @Nullable String message); |
| 5310 | |
| 5311 | /** @hide */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5312 | @IntDef(flag = true, prefix = { "CONTEXT_" }, value = { |
| 5313 | CONTEXT_INCLUDE_CODE, |
| 5314 | CONTEXT_IGNORE_SECURITY, |
| 5315 | CONTEXT_RESTRICTED, |
| 5316 | CONTEXT_DEVICE_PROTECTED_STORAGE, |
| 5317 | CONTEXT_CREDENTIAL_PROTECTED_STORAGE, |
| 5318 | CONTEXT_REGISTER_PACKAGE, |
| 5319 | }) |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5320 | @Retention(RetentionPolicy.SOURCE) |
| 5321 | public @interface CreatePackageOptions {} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5322 | |
| 5323 | /** |
| 5324 | * Flag for use with {@link #createPackageContext}: include the application |
| 5325 | * code with the context. This means loading code into the caller's |
| 5326 | * process, so that {@link #getClassLoader()} can be used to instantiate |
| 5327 | * the application's classes. Setting this flags imposes security |
| 5328 | * restrictions on what application context you can access; if the |
| 5329 | * requested application can not be safely loaded into your process, |
| 5330 | * java.lang.SecurityException will be thrown. If this flag is not set, |
| 5331 | * there will be no restrictions on the packages that can be loaded, |
| 5332 | * but {@link #getClassLoader} will always return the default system |
| 5333 | * class loader. |
| 5334 | */ |
| 5335 | public static final int CONTEXT_INCLUDE_CODE = 0x00000001; |
| 5336 | |
| 5337 | /** |
| 5338 | * Flag for use with {@link #createPackageContext}: ignore any security |
| 5339 | * restrictions on the Context being requested, allowing it to always |
| 5340 | * be loaded. For use with {@link #CONTEXT_INCLUDE_CODE} to allow code |
| 5341 | * to be loaded into a process even when it isn't safe to do so. Use |
| 5342 | * with extreme care! |
| 5343 | */ |
| 5344 | public static final int CONTEXT_IGNORE_SECURITY = 0x00000002; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 5345 | |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 5346 | /** |
| 5347 | * Flag for use with {@link #createPackageContext}: a restricted context may |
| 5348 | * disable specific features. For instance, a View associated with a restricted |
| 5349 | * context would ignore particular XML attributes. |
| 5350 | */ |
| 5351 | public static final int CONTEXT_RESTRICTED = 0x00000004; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5352 | |
| 5353 | /** |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5354 | * Flag for use with {@link #createPackageContext}: point all file APIs at |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5355 | * device-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5356 | * |
| 5357 | * @hide |
| 5358 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5359 | public static final int CONTEXT_DEVICE_PROTECTED_STORAGE = 0x00000008; |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5360 | |
| 5361 | /** |
| 5362 | * Flag for use with {@link #createPackageContext}: point all file APIs at |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5363 | * credential-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5364 | * |
| 5365 | * @hide |
| 5366 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5367 | public static final int CONTEXT_CREDENTIAL_PROTECTED_STORAGE = 0x00000010; |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5368 | |
| 5369 | /** |
Dianne Hackborn | fee756f | 2014-07-16 17:31:10 -0700 | [diff] [blame] | 5370 | * @hide Used to indicate we should tell the activity manager about the process |
| 5371 | * loading this code. |
| 5372 | */ |
| 5373 | public static final int CONTEXT_REGISTER_PACKAGE = 0x40000000; |
| 5374 | |
| 5375 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5376 | * Return a new Context object for the given application name. This |
| 5377 | * Context is the same as what the named application gets when it is |
| 5378 | * launched, containing the same resources and class loader. Each call to |
| 5379 | * this method returns a new instance of a Context object; Context objects |
| 5380 | * are not shared, however they share common state (Resources, ClassLoader, |
| 5381 | * etc) so the Context instance itself is fairly lightweight. |
| 5382 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 5383 | * <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] | 5384 | * application with the given package name. |
| 5385 | * |
| 5386 | * <p>Throws {@link java.lang.SecurityException} if the Context requested |
| 5387 | * can not be loaded into the caller's process for security reasons (see |
| 5388 | * {@link #CONTEXT_INCLUDE_CODE} for more information}. |
| 5389 | * |
| 5390 | * @param packageName Name of the application's package. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5391 | * @param flags Option flags. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5392 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5393 | * @return A {@link Context} for the application. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5394 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5395 | * @throws SecurityException |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5396 | * @throws PackageManager.NameNotFoundException if there is no application with |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5397 | * the given package name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5398 | */ |
| 5399 | public abstract Context createPackageContext(String packageName, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5400 | @CreatePackageOptions int flags) throws PackageManager.NameNotFoundException; |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 5401 | |
| 5402 | /** |
Jeff Sharkey | 6d51571 | 2012-09-20 16:06:08 -0700 | [diff] [blame] | 5403 | * Similar to {@link #createPackageContext(String, int)}, but with a |
| 5404 | * different {@link UserHandle}. For example, {@link #getContentResolver()} |
| 5405 | * will open any {@link Uri} as the given user. |
| 5406 | * |
| 5407 | * @hide |
| 5408 | */ |
Patrick Baumann | ef4c407 | 2018-02-01 08:54:05 -0800 | [diff] [blame] | 5409 | @SystemApi |
Jeff Sharkey | ec5f7d1 | 2018-08-08 09:15:04 -0600 | [diff] [blame] | 5410 | @TestApi |
Makoto Onuki | b844001 | 2019-10-09 15:33:11 -0700 | [diff] [blame] | 5411 | @NonNull |
Patrick Baumann | ef4c407 | 2018-02-01 08:54:05 -0800 | [diff] [blame] | 5412 | public Context createPackageContextAsUser( |
Makoto Onuki | b844001 | 2019-10-09 15:33:11 -0700 | [diff] [blame] | 5413 | @NonNull String packageName, @CreatePackageOptions int flags, @NonNull UserHandle user) |
Patrick Baumann | ef4c407 | 2018-02-01 08:54:05 -0800 | [diff] [blame] | 5414 | throws PackageManager.NameNotFoundException { |
| 5415 | if (Build.IS_ENG) { |
| 5416 | throw new IllegalStateException("createPackageContextAsUser not overridden!"); |
| 5417 | } |
| 5418 | return this; |
| 5419 | } |
Jeff Sharkey | 6d51571 | 2012-09-20 16:06:08 -0700 | [diff] [blame] | 5420 | |
| 5421 | /** |
Makoto Onuki | b844001 | 2019-10-09 15:33:11 -0700 | [diff] [blame] | 5422 | * Similar to {@link #createPackageContext(String, int)}, but for the own package with a |
| 5423 | * different {@link UserHandle}. For example, {@link #getContentResolver()} |
| 5424 | * will open any {@link Uri} as the given user. |
| 5425 | * |
| 5426 | * @hide |
| 5427 | */ |
| 5428 | @SystemApi |
| 5429 | @TestApi |
| 5430 | @NonNull |
Makoto Onuki | e5449f0 | 2019-10-11 20:19:58 -0700 | [diff] [blame] | 5431 | public Context createContextAsUser(@NonNull UserHandle user, @CreatePackageOptions int flags) { |
Makoto Onuki | b844001 | 2019-10-09 15:33:11 -0700 | [diff] [blame] | 5432 | if (Build.IS_ENG) { |
| 5433 | throw new IllegalStateException("createContextAsUser not overridden!"); |
| 5434 | } |
| 5435 | return this; |
| 5436 | } |
| 5437 | |
| 5438 | /** |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5439 | * Creates a context given an {@link android.content.pm.ApplicationInfo}. |
| 5440 | * |
| 5441 | * @hide |
| 5442 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 5443 | @UnsupportedAppUsage |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5444 | public abstract Context createApplicationContext(ApplicationInfo application, |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5445 | @CreatePackageOptions int flags) throws PackageManager.NameNotFoundException; |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5446 | |
| 5447 | /** |
Adam Lesinski | 4e86281 | 2016-11-21 16:02:24 -0800 | [diff] [blame] | 5448 | * Return a new Context object for the given split name. The new Context has a ClassLoader and |
| 5449 | * Resources object that can access the split's and all of its dependencies' code/resources. |
| 5450 | * Each call to this method returns a new instance of a Context object; |
| 5451 | * Context objects are not shared, however common state (ClassLoader, other Resources for |
| 5452 | * the same split) may be so the Context itself can be fairly lightweight. |
| 5453 | * |
| 5454 | * @param splitName The name of the split to include, as declared in the split's |
| 5455 | * <code>AndroidManifest.xml</code>. |
| 5456 | * @return A {@link Context} with the given split's code and/or resources loaded. |
| 5457 | */ |
| 5458 | public abstract Context createContextForSplit(String splitName) |
| 5459 | throws PackageManager.NameNotFoundException; |
| 5460 | |
| 5461 | /** |
Jeff Sharkey | ad357d1 | 2018-02-02 13:25:31 -0700 | [diff] [blame] | 5462 | * Get the user associated with this context |
Jim Miller | a75a883 | 2013-02-07 16:53:32 -0800 | [diff] [blame] | 5463 | * @hide |
| 5464 | */ |
Jeff Sharkey | a73b8fd | 2016-01-06 17:02:08 -0700 | [diff] [blame] | 5465 | @TestApi |
Jeff Sharkey | ad357d1 | 2018-02-02 13:25:31 -0700 | [diff] [blame] | 5466 | public UserHandle getUser() { |
| 5467 | return android.os.Process.myUserHandle(); |
| 5468 | } |
| 5469 | |
| 5470 | /** |
| 5471 | * Get the user associated with this context |
| 5472 | * @hide |
| 5473 | */ |
Artur Satayev | f0b7d0b | 2019-11-04 11:16:45 +0000 | [diff] [blame] | 5474 | @UnsupportedAppUsage |
Jeff Sharkey | ad357d1 | 2018-02-02 13:25:31 -0700 | [diff] [blame] | 5475 | @TestApi |
| 5476 | public @UserIdInt int getUserId() { |
| 5477 | return android.os.UserHandle.myUserId(); |
| 5478 | } |
Jim Miller | a75a883 | 2013-02-07 16:53:32 -0800 | [diff] [blame] | 5479 | |
| 5480 | /** |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 5481 | * Return a new Context object for the current Context but whose resources |
| 5482 | * are adjusted to match the given Configuration. Each call to this method |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 5483 | * returns a new instance of a Context object; Context objects are not |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 5484 | * shared, however common state (ClassLoader, other Resources for the |
| 5485 | * same configuration) may be so the Context itself can be fairly lightweight. |
| 5486 | * |
| 5487 | * @param overrideConfiguration A {@link Configuration} specifying what |
| 5488 | * values to modify in the base Configuration of the original Context's |
| 5489 | * resources. If the base configuration changes (such as due to an |
| 5490 | * orientation change), the resources of this context will also change except |
| 5491 | * for those that have been explicitly overridden with a value here. |
| 5492 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5493 | * @return A {@link Context} with the given configuration override. |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 5494 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5495 | public abstract Context createConfigurationContext( |
| 5496 | @NonNull Configuration overrideConfiguration); |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 5497 | |
| 5498 | /** |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 5499 | * Return a new Context object for the current Context but whose resources |
| 5500 | * are adjusted to match the metrics of the given Display. Each call to this method |
| 5501 | * returns a new instance of a Context object; Context objects are not |
| 5502 | * shared, however common state (ClassLoader, other Resources for the |
| 5503 | * same configuration) may be so the Context itself can be fairly lightweight. |
| 5504 | * |
| 5505 | * The returned display Context provides a {@link WindowManager} |
| 5506 | * (see {@link #getSystemService(String)}) that is configured to show windows |
| 5507 | * on the given display. The WindowManager's {@link WindowManager#getDefaultDisplay} |
| 5508 | * method can be used to retrieve the Display from the returned Context. |
| 5509 | * |
| 5510 | * @param display A {@link Display} object specifying the display |
| 5511 | * for whose metrics the Context's resources should be tailored and upon which |
| 5512 | * new windows should be shown. |
| 5513 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5514 | * @return A {@link Context} for the display. |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 5515 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5516 | public abstract Context createDisplayContext(@NonNull Display display); |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 5517 | |
| 5518 | /** |
Philip P. Moltmann | 59076d8 | 2019-08-19 15:00:40 -0700 | [diff] [blame] | 5519 | * Return a new Context object for the current Context but for a different feature in the app. |
| 5520 | * Features can be used by complex apps to separate logical parts. |
| 5521 | * |
| 5522 | * @param featureId The feature id or {@code null} to create a context for the default feature. |
| 5523 | * |
| 5524 | * @return A {@link Context} for the feature |
| 5525 | * |
| 5526 | * @see #getFeatureId() |
| 5527 | */ |
| 5528 | public @NonNull Context createFeatureContext(@Nullable String featureId) { |
Philip P. Moltmann | f1a634c | 2019-10-18 09:10:56 -0700 | [diff] [blame] | 5529 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
Philip P. Moltmann | 59076d8 | 2019-08-19 15:00:40 -0700 | [diff] [blame] | 5530 | } |
| 5531 | |
| 5532 | /** |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5533 | * Return a new Context object for the current Context but whose storage |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5534 | * APIs are backed by device-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5535 | * <p> |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 5536 | * On devices with direct boot, data stored in this location is encrypted |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5537 | * with a key tied to the physical device, and it can be accessed |
| 5538 | * immediately after the device has booted successfully, both |
| 5539 | * <em>before and after</em> the user has authenticated with their |
| 5540 | * credentials (such as a lock pattern or PIN). |
| 5541 | * <p> |
| 5542 | * Because device-protected data is available without user authentication, |
| 5543 | * you should carefully limit the data you store using this Context. For |
| 5544 | * example, storing sensitive authentication tokens or passwords in the |
| 5545 | * device-protected area is strongly discouraged. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5546 | * <p> |
Jeff Sharkey | 3ea44a5 | 2016-01-09 15:19:56 -0700 | [diff] [blame] | 5547 | * If the underlying device does not have the ability to store |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5548 | * device-protected and credential-protected data using different keys, then |
| 5549 | * both storage areas will become available at the same time. They remain as |
| 5550 | * two distinct storage locations on disk, and only the window of |
| 5551 | * availability changes. |
Jeff Sharkey | 3ea44a5 | 2016-01-09 15:19:56 -0700 | [diff] [blame] | 5552 | * <p> |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5553 | * Each call to this method returns a new instance of a Context object; |
| 5554 | * Context objects are not shared, however common state (ClassLoader, other |
| 5555 | * Resources for the same configuration) may be so the Context itself can be |
| 5556 | * fairly lightweight. |
| 5557 | * |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5558 | * @see #isDeviceProtectedStorage() |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5559 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5560 | public abstract Context createDeviceProtectedStorageContext(); |
| 5561 | |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5562 | /** |
| 5563 | * Return a new Context object for the current Context but whose storage |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5564 | * APIs are backed by credential-protected storage. This is the default |
| 5565 | * storage area for apps unless |
| 5566 | * {@link android.R.attr#defaultToDeviceProtectedStorage} was requested. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5567 | * <p> |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 5568 | * On devices with direct boot, data stored in this location is encrypted |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5569 | * with a key tied to user credentials, which can be accessed |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5570 | * <em>only after</em> the user has entered their credentials (such as a |
| 5571 | * lock pattern or PIN). |
| 5572 | * <p> |
Jeff Sharkey | 3ea44a5 | 2016-01-09 15:19:56 -0700 | [diff] [blame] | 5573 | * If the underlying device does not have the ability to store |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5574 | * device-protected and credential-protected data using different keys, then |
| 5575 | * both storage areas will become available at the same time. They remain as |
| 5576 | * two distinct storage locations on disk, and only the window of |
| 5577 | * availability changes. |
Jeff Sharkey | 3ea44a5 | 2016-01-09 15:19:56 -0700 | [diff] [blame] | 5578 | * <p> |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5579 | * Each call to this method returns a new instance of a Context object; |
| 5580 | * Context objects are not shared, however common state (ClassLoader, other |
| 5581 | * Resources for the same configuration) may be so the Context itself can be |
| 5582 | * fairly lightweight. |
| 5583 | * |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5584 | * @see #isCredentialProtectedStorage() |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 5585 | * @hide |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5586 | */ |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 5587 | @SystemApi |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5588 | public abstract Context createCredentialProtectedStorageContext(); |
| 5589 | |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5590 | /** |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 5591 | * Gets the display adjustments holder for this context. This information |
| 5592 | * is provided on a per-application or activity basis and is used to simulate lower density |
| 5593 | * display metrics for legacy applications and restricted screen sizes. |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 5594 | * |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 5595 | * @param displayId The display id for which to get compatibility info. |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 5596 | * @return The compatibility info holder, or null if not required by the application. |
| 5597 | * @hide |
| 5598 | */ |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 5599 | public abstract DisplayAdjustments getDisplayAdjustments(int displayId); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 5600 | |
| 5601 | /** |
Wale Ogunwale | 691af68 | 2019-02-11 03:09:10 -0800 | [diff] [blame] | 5602 | * @return Returns the {@link Display} object this context is associated with. |
Adam Lesinski | 4ece3d6 | 2016-06-16 18:05:41 -0700 | [diff] [blame] | 5603 | * @hide |
| 5604 | */ |
Artur Satayev | f0b7d0b | 2019-11-04 11:16:45 +0000 | [diff] [blame] | 5605 | @UnsupportedAppUsage |
Wale Ogunwale | 691af68 | 2019-02-11 03:09:10 -0800 | [diff] [blame] | 5606 | @TestApi |
Adam Lesinski | 4ece3d6 | 2016-06-16 18:05:41 -0700 | [diff] [blame] | 5607 | public abstract Display getDisplay(); |
| 5608 | |
| 5609 | /** |
Yohei Yukawa | 5281b6b | 2018-10-15 07:38:25 +0800 | [diff] [blame] | 5610 | * Gets the display ID. |
| 5611 | * |
| 5612 | * @return display ID associated with this {@link Context}. |
| 5613 | * @hide |
| 5614 | */ |
wilsonshih | 5db7b39 | 2019-02-20 23:08:45 +0800 | [diff] [blame] | 5615 | @TestApi |
Yohei Yukawa | 5281b6b | 2018-10-15 07:38:25 +0800 | [diff] [blame] | 5616 | public abstract int getDisplayId(); |
| 5617 | |
| 5618 | /** |
Andrii Kulian | b047b8b | 2017-02-08 18:38:26 -0800 | [diff] [blame] | 5619 | * @hide |
| 5620 | */ |
| 5621 | public abstract void updateDisplay(int displayId); |
| 5622 | |
| 5623 | /** |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 5624 | * Indicates whether this Context is restricted. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 5625 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5626 | * @return {@code true} if this Context is restricted, {@code false} otherwise. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 5627 | * |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 5628 | * @see #CONTEXT_RESTRICTED |
| 5629 | */ |
| 5630 | public boolean isRestricted() { |
| 5631 | return false; |
| 5632 | } |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5633 | |
| 5634 | /** |
| 5635 | * Indicates if the storage APIs of this Context are backed by |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5636 | * device-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5637 | * |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5638 | * @see #createDeviceProtectedStorageContext() |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5639 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5640 | public abstract boolean isDeviceProtectedStorage(); |
| 5641 | |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5642 | /** |
| 5643 | * Indicates if the storage APIs of this Context are backed by |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5644 | * credential-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5645 | * |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5646 | * @see #createCredentialProtectedStorageContext() |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 5647 | * @hide |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5648 | */ |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 5649 | @SystemApi |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5650 | public abstract boolean isCredentialProtectedStorage(); |
| 5651 | |
Tony Mak | 46aabe5 | 2016-11-14 12:53:06 +0000 | [diff] [blame] | 5652 | /** |
Seigo Nonaka | 6d6cd68 | 2017-06-22 08:22:18 -0700 | [diff] [blame] | 5653 | * Returns true if the context can load unsafe resources, e.g. fonts. |
| 5654 | * @hide |
| 5655 | */ |
| 5656 | public abstract boolean canLoadUnsafeResources(); |
| 5657 | |
| 5658 | /** |
Tony Mak | 46aabe5 | 2016-11-14 12:53:06 +0000 | [diff] [blame] | 5659 | * @hide |
| 5660 | */ |
| 5661 | public IBinder getActivityToken() { |
| 5662 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 5663 | } |
| 5664 | |
| 5665 | /** |
| 5666 | * @hide |
| 5667 | */ |
| 5668 | @Nullable |
| 5669 | public IServiceConnection getServiceDispatcher(ServiceConnection conn, Handler handler, |
| 5670 | int flags) { |
| 5671 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 5672 | } |
| 5673 | |
| 5674 | /** |
| 5675 | * @hide |
| 5676 | */ |
| 5677 | public IApplicationThread getIApplicationThread() { |
| 5678 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 5679 | } |
Tony Mak | bf9928d | 2016-12-22 11:02:45 +0000 | [diff] [blame] | 5680 | |
| 5681 | /** |
| 5682 | * @hide |
| 5683 | */ |
| 5684 | public Handler getMainThreadHandler() { |
| 5685 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 5686 | } |
Adam Lesinski | a82b626 | 2017-03-21 16:56:17 -0700 | [diff] [blame] | 5687 | |
| 5688 | /** |
Felipe Leme | bb567ae | 2017-10-04 09:56:21 -0700 | [diff] [blame] | 5689 | * @hide |
| 5690 | */ |
| 5691 | public AutofillClient getAutofillClient() { |
| 5692 | return null; |
| 5693 | } |
| 5694 | |
| 5695 | /** |
| 5696 | * @hide |
| 5697 | */ |
Svet Ganov | 47b37aa | 2018-02-16 00:11:39 -0800 | [diff] [blame] | 5698 | public void setAutofillClient(@SuppressWarnings("unused") AutofillClient client) { |
Felipe Leme | bb567ae | 2017-10-04 09:56:21 -0700 | [diff] [blame] | 5699 | } |
| 5700 | |
| 5701 | /** |
Svetoslav Ganov | 24c9045 | 2017-12-27 15:17:14 -0800 | [diff] [blame] | 5702 | * @hide |
| 5703 | */ |
Felipe Leme | cbf7f26 | 2019-04-17 13:57:59 -0700 | [diff] [blame] | 5704 | @Nullable |
| 5705 | public ContentCaptureClient getContentCaptureClient() { |
| 5706 | return null; |
| 5707 | } |
| 5708 | |
| 5709 | /** |
| 5710 | * @hide |
| 5711 | */ |
Felipe Leme | a4f39cd | 2019-02-19 15:08:59 -0800 | [diff] [blame] | 5712 | public final boolean isAutofillCompatibilityEnabled() { |
| 5713 | final AutofillOptions options = getAutofillOptions(); |
| 5714 | return options != null && options.compatModeEnabled; |
| 5715 | } |
| 5716 | |
| 5717 | /** |
| 5718 | * @hide |
| 5719 | */ |
| 5720 | @Nullable |
| 5721 | public AutofillOptions getAutofillOptions() { |
| 5722 | return null; |
Svetoslav Ganov | 24c9045 | 2017-12-27 15:17:14 -0800 | [diff] [blame] | 5723 | } |
| 5724 | |
| 5725 | /** |
| 5726 | * @hide |
| 5727 | */ |
Svet Ganov | 47b37aa | 2018-02-16 00:11:39 -0800 | [diff] [blame] | 5728 | @TestApi |
Felipe Leme | a4f39cd | 2019-02-19 15:08:59 -0800 | [diff] [blame] | 5729 | public void setAutofillOptions(@SuppressWarnings("unused") @Nullable AutofillOptions options) { |
Svetoslav Ganov | 24c9045 | 2017-12-27 15:17:14 -0800 | [diff] [blame] | 5730 | } |
| 5731 | |
| 5732 | /** |
Felipe Leme | 326f15a | 2019-02-19 09:42:24 -0800 | [diff] [blame] | 5733 | * 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] | 5734 | * |
| 5735 | * @hide |
| 5736 | */ |
Felipe Leme | 326f15a | 2019-02-19 09:42:24 -0800 | [diff] [blame] | 5737 | @Nullable |
| 5738 | public ContentCaptureOptions getContentCaptureOptions() { |
| 5739 | return null; |
Felipe Leme | ecb08be | 2018-11-27 15:48:47 -0800 | [diff] [blame] | 5740 | } |
| 5741 | |
| 5742 | /** |
| 5743 | * @hide |
| 5744 | */ |
Felipe Leme | 326f15a | 2019-02-19 09:42:24 -0800 | [diff] [blame] | 5745 | @TestApi |
| 5746 | public void setContentCaptureOptions( |
| 5747 | @SuppressWarnings("unused") @Nullable ContentCaptureOptions options) { |
Felipe Leme | ecb08be | 2018-11-27 15:48:47 -0800 | [diff] [blame] | 5748 | } |
| 5749 | |
| 5750 | /** |
Adam Lesinski | a82b626 | 2017-03-21 16:56:17 -0700 | [diff] [blame] | 5751 | * Throws an exception if the Context is using system resources, |
| 5752 | * which are non-runtime-overlay-themable and may show inconsistent UI. |
| 5753 | * @hide |
| 5754 | */ |
| 5755 | public void assertRuntimeOverlayThemable() { |
| 5756 | // Resources.getSystem() is a singleton and the only Resources not managed by |
| 5757 | // ResourcesManager; therefore Resources.getSystem() is not themable. |
| 5758 | if (getResources() == Resources.getSystem()) { |
| 5759 | throw new IllegalArgumentException("Non-UI context used to display UI; " |
| 5760 | + "get a UI context from ActivityThread#getSystemUiContext()"); |
| 5761 | } |
| 5762 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5763 | } |