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; |
Adrian Roos | d38f509 | 2020-01-16 21:20:24 +0100 | [diff] [blame] | 33 | import android.annotation.SuppressLint; |
Jinsuk Kim | 66d1eb2 | 2014-06-06 16:12:18 +0900 | [diff] [blame] | 34 | import android.annotation.SystemApi; |
Jeff Sharkey | a73b8fd | 2016-01-06 17:02:08 -0700 | [diff] [blame] | 35 | import android.annotation.TestApi; |
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; |
Artur Satayev | e23a0eb | 2019-12-10 17:47:52 +0000 | [diff] [blame] | 41 | import android.compat.annotation.UnsupportedAppUsage; |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 42 | import android.content.pm.ApplicationInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 43 | import android.content.pm.PackageManager; |
| 44 | import android.content.res.AssetManager; |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 45 | import android.content.res.ColorStateList; |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 46 | import android.content.res.Configuration; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 47 | import android.content.res.Resources; |
| 48 | import android.content.res.TypedArray; |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 49 | import android.database.DatabaseErrorHandler; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 50 | import android.database.sqlite.SQLiteDatabase; |
| 51 | import android.database.sqlite.SQLiteDatabase.CursorFactory; |
| 52 | import android.graphics.Bitmap; |
| 53 | import android.graphics.drawable.Drawable; |
| 54 | import android.net.Uri; |
Patrick Baumann | ef4c407 | 2018-02-01 08:54:05 -0800 | [diff] [blame] | 55 | import android.os.Build; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 56 | import android.os.Bundle; |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 57 | import android.os.Environment; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 58 | import android.os.Handler; |
Jeff Sharkey | 8439ac0 | 2017-12-12 17:26:23 -0700 | [diff] [blame] | 59 | import android.os.HandlerExecutor; |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 60 | import android.os.IBinder; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 61 | import android.os.Looper; |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 62 | import android.os.StatFs; |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 63 | import android.os.UserHandle; |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 64 | import android.os.UserManager; |
Jeff Sharkey | 60a82cd | 2017-04-18 18:19:16 -0600 | [diff] [blame] | 65 | import android.os.storage.StorageManager; |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 66 | import android.provider.MediaStore; |
Chen Xu | 1f6cfa5 | 2019-10-13 17:30:32 -0700 | [diff] [blame] | 67 | import android.telephony.TelephonyRegistryManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 68 | import android.util.AttributeSet; |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 69 | import android.view.Display; |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 70 | import android.view.DisplayAdjustments; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 71 | import android.view.View; |
Jon Miranda | 836c0a8 | 2014-08-11 12:32:26 -0700 | [diff] [blame] | 72 | import android.view.ViewDebug; |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 73 | import android.view.WindowManager; |
Felipe Leme | bb567ae | 2017-10-04 09:56:21 -0700 | [diff] [blame] | 74 | import android.view.autofill.AutofillManager.AutofillClient; |
Felipe Leme | cbf7f26 | 2019-04-17 13:57:59 -0700 | [diff] [blame] | 75 | import android.view.contentcapture.ContentCaptureManager.ContentCaptureClient; |
Abodunrinwa Toki | f001fef | 2017-01-04 23:51:42 +0000 | [diff] [blame] | 76 | import android.view.textclassifier.TextClassificationManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 77 | |
atrost | a6a4d60 | 2019-08-21 16:48:56 +0100 | [diff] [blame] | 78 | import com.android.internal.compat.IPlatformCompat; |
atrost | 8748835 | 2019-10-10 19:27:31 +0100 | [diff] [blame] | 79 | import com.android.internal.compat.IPlatformCompatNative; |
atrost | a6a4d60 | 2019-08-21 16:48:56 +0100 | [diff] [blame] | 80 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 81 | import java.io.File; |
| 82 | import java.io.FileInputStream; |
| 83 | import java.io.FileNotFoundException; |
| 84 | import java.io.FileOutputStream; |
| 85 | import java.io.IOException; |
| 86 | import java.io.InputStream; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 87 | import java.lang.annotation.Retention; |
| 88 | import java.lang.annotation.RetentionPolicy; |
Jeff Sharkey | 8439ac0 | 2017-12-12 17:26:23 -0700 | [diff] [blame] | 89 | import java.util.concurrent.Executor; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 90 | |
| 91 | /** |
| 92 | * Interface to global information about an application environment. This is |
| 93 | * an abstract class whose implementation is provided by |
| 94 | * the Android system. It |
| 95 | * allows access to application-specific resources and classes, as well as |
| 96 | * up-calls for application-level operations such as launching activities, |
| 97 | * broadcasting and receiving intents, etc. |
| 98 | */ |
| 99 | public abstract class Context { |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 100 | /** @hide */ |
| 101 | @IntDef(flag = true, prefix = { "MODE_" }, value = { |
| 102 | MODE_PRIVATE, |
| 103 | MODE_WORLD_READABLE, |
| 104 | MODE_WORLD_WRITEABLE, |
| 105 | MODE_APPEND, |
| 106 | }) |
| 107 | @Retention(RetentionPolicy.SOURCE) |
| 108 | public @interface FileMode {} |
| 109 | |
| 110 | /** @hide */ |
| 111 | @IntDef(flag = true, prefix = { "MODE_" }, value = { |
| 112 | MODE_PRIVATE, |
| 113 | MODE_WORLD_READABLE, |
| 114 | MODE_WORLD_WRITEABLE, |
| 115 | MODE_MULTI_PROCESS, |
| 116 | }) |
| 117 | @Retention(RetentionPolicy.SOURCE) |
| 118 | public @interface PreferencesMode {} |
| 119 | |
| 120 | /** @hide */ |
| 121 | @IntDef(flag = true, prefix = { "MODE_" }, value = { |
| 122 | MODE_PRIVATE, |
| 123 | MODE_WORLD_READABLE, |
| 124 | MODE_WORLD_WRITEABLE, |
| 125 | MODE_ENABLE_WRITE_AHEAD_LOGGING, |
| 126 | MODE_NO_LOCALIZED_COLLATORS, |
| 127 | }) |
| 128 | @Retention(RetentionPolicy.SOURCE) |
| 129 | public @interface DatabaseMode {} |
| 130 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 131 | /** |
| 132 | * File creation mode: the default mode, where the created file can only |
| 133 | * be accessed by the calling application (or all applications sharing the |
| 134 | * same user ID). |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 135 | */ |
| 136 | public static final int MODE_PRIVATE = 0x0000; |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 137 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 138 | /** |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 139 | * File creation mode: allow all other applications to have read access to |
| 140 | * the created file. |
| 141 | * <p> |
Dave Friedman | cfe5088 | 2017-07-05 00:40:07 -0700 | [diff] [blame] | 142 | * Starting from {@link android.os.Build.VERSION_CODES#N}, attempting to use this |
| 143 | * mode throws a {@link SecurityException}. |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 144 | * |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 145 | * @deprecated Creating world-readable files is very dangerous, and likely |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 146 | * to cause security holes in applications. It is strongly |
| 147 | * discouraged; instead, applications should use more formal |
| 148 | * mechanism for interactions such as {@link ContentProvider}, |
| 149 | * {@link BroadcastReceiver}, and {@link android.app.Service}. |
| 150 | * There are no guarantees that this access mode will remain on |
| 151 | * a file, such as when it goes through a backup and restore. |
| 152 | * @see android.support.v4.content.FileProvider |
| 153 | * @see Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 154 | */ |
Dianne Hackborn | 556b09e | 2012-09-23 17:46:53 -0700 | [diff] [blame] | 155 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 156 | public static final int MODE_WORLD_READABLE = 0x0001; |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 157 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 158 | /** |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 159 | * File creation mode: allow all other applications to have write access to |
| 160 | * the created file. |
| 161 | * <p> |
Dave Friedman | cfe5088 | 2017-07-05 00:40:07 -0700 | [diff] [blame] | 162 | * 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] | 163 | * mode will throw a {@link SecurityException}. |
| 164 | * |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 165 | * @deprecated Creating world-writable files is very dangerous, and likely |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 166 | * to cause security holes in applications. It is strongly |
| 167 | * discouraged; instead, applications should use more formal |
| 168 | * mechanism for interactions such as {@link ContentProvider}, |
| 169 | * {@link BroadcastReceiver}, and {@link android.app.Service}. |
| 170 | * There are no guarantees that this access mode will remain on |
| 171 | * a file, such as when it goes through a backup and restore. |
| 172 | * @see android.support.v4.content.FileProvider |
| 173 | * @see Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 174 | */ |
Dianne Hackborn | 556b09e | 2012-09-23 17:46:53 -0700 | [diff] [blame] | 175 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 176 | public static final int MODE_WORLD_WRITEABLE = 0x0002; |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 177 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 178 | /** |
| 179 | * File creation mode: for use with {@link #openFileOutput}, if the file |
| 180 | * already exists then write data to the end of the existing file |
| 181 | * instead of erasing it. |
| 182 | * @see #openFileOutput |
| 183 | */ |
| 184 | public static final int MODE_APPEND = 0x8000; |
| 185 | |
| 186 | /** |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 187 | * SharedPreference loading flag: when set, the file on disk will |
| 188 | * be checked for modification even if the shared preferences |
| 189 | * instance is already loaded in this process. This behavior is |
| 190 | * sometimes desired in cases where the application has multiple |
| 191 | * processes, all writing to the same SharedPreferences file. |
| 192 | * Generally there are better forms of communication between |
| 193 | * processes, though. |
| 194 | * |
| 195 | * <p>This was the legacy (but undocumented) behavior in and |
| 196 | * before Gingerbread (Android 2.3) and this flag is implied when |
kopriva | 219f7dc | 2018-10-09 13:42:28 -0700 | [diff] [blame] | 197 | * targeting such releases. For applications targeting SDK |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 198 | * versions <em>greater than</em> Android 2.3, this flag must be |
| 199 | * explicitly set if desired. |
| 200 | * |
| 201 | * @see #getSharedPreferences |
Christopher Tate | d5748b8 | 2015-05-08 18:14:01 -0700 | [diff] [blame] | 202 | * |
| 203 | * @deprecated MODE_MULTI_PROCESS does not work reliably in |
| 204 | * some versions of Android, and furthermore does not provide any |
| 205 | * mechanism for reconciling concurrent modifications across |
| 206 | * processes. Applications should not attempt to use it. Instead, |
| 207 | * they should use an explicit cross-process data management |
| 208 | * approach such as {@link android.content.ContentProvider ContentProvider}. |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 209 | */ |
Christopher Tate | d5748b8 | 2015-05-08 18:14:01 -0700 | [diff] [blame] | 210 | @Deprecated |
Brad Fitzpatrick | 4e920f7 | 2010-12-14 11:52:13 -0800 | [diff] [blame] | 211 | public static final int MODE_MULTI_PROCESS = 0x0004; |
| 212 | |
| 213 | /** |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 214 | * Database open flag: when set, the database is opened with write-ahead |
| 215 | * logging enabled by default. |
| 216 | * |
| 217 | * @see #openOrCreateDatabase(String, int, CursorFactory) |
| 218 | * @see #openOrCreateDatabase(String, int, CursorFactory, DatabaseErrorHandler) |
| 219 | * @see SQLiteDatabase#enableWriteAheadLogging |
| 220 | */ |
| 221 | public static final int MODE_ENABLE_WRITE_AHEAD_LOGGING = 0x0008; |
| 222 | |
Sunny Goyal | a21e6b2 | 2015-12-02 09:51:02 -0800 | [diff] [blame] | 223 | /** |
| 224 | * Database open flag: when set, the database is opened without support for |
| 225 | * localized collators. |
| 226 | * |
| 227 | * @see #openOrCreateDatabase(String, int, CursorFactory) |
| 228 | * @see #openOrCreateDatabase(String, int, CursorFactory, DatabaseErrorHandler) |
| 229 | * @see SQLiteDatabase#NO_LOCALIZED_COLLATORS |
| 230 | */ |
| 231 | public static final int MODE_NO_LOCALIZED_COLLATORS = 0x0010; |
| 232 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 233 | /** @hide */ |
Jeff Sharkey | ce8db99 | 2017-12-13 20:05:05 -0700 | [diff] [blame] | 234 | @IntDef(flag = true, prefix = { "BIND_" }, value = { |
| 235 | BIND_AUTO_CREATE, |
| 236 | BIND_DEBUG_UNBIND, |
| 237 | BIND_NOT_FOREGROUND, |
| 238 | BIND_ABOVE_CLIENT, |
| 239 | BIND_ALLOW_OOM_MANAGEMENT, |
| 240 | BIND_WAIVE_PRIORITY, |
| 241 | BIND_IMPORTANT, |
Amith Yamasani | 5016a78 | 2019-06-17 16:20:24 -0700 | [diff] [blame] | 242 | BIND_ADJUST_WITH_ACTIVITY, |
| 243 | BIND_NOT_PERCEPTIBLE, |
| 244 | BIND_INCLUDE_CAPABILITIES |
Jeff Sharkey | ce8db99 | 2017-12-13 20:05:05 -0700 | [diff] [blame] | 245 | }) |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 246 | @Retention(RetentionPolicy.SOURCE) |
| 247 | public @interface BindServiceFlags {} |
| 248 | |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 249 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 250 | * Flag for {@link #bindService}: automatically create the service as long |
| 251 | * as the binding exists. Note that while this will create the service, |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 252 | * its {@link android.app.Service#onStartCommand} |
| 253 | * method will still only be called due to an |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 254 | * explicit call to {@link #startService}. Even without that, though, |
| 255 | * this still provides you with access to the service object while the |
| 256 | * service is created. |
| 257 | * |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 258 | * <p>Note that prior to {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, |
| 259 | * not supplying this flag would also impact how important the system |
| 260 | * consider's the target service's process to be. When set, the only way |
| 261 | * for it to be raised was by binding from a service in which case it will |
| 262 | * only be important when that activity is in the foreground. Now to |
| 263 | * achieve this behavior you must explicitly supply the new flag |
| 264 | * {@link #BIND_ADJUST_WITH_ACTIVITY}. For compatibility, old applications |
| 265 | * that don't specify {@link #BIND_AUTO_CREATE} will automatically have |
| 266 | * the flags {@link #BIND_WAIVE_PRIORITY} and |
| 267 | * {@link #BIND_ADJUST_WITH_ACTIVITY} set for them in order to achieve |
| 268 | * the same result. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 269 | */ |
| 270 | public static final int BIND_AUTO_CREATE = 0x0001; |
| 271 | |
| 272 | /** |
| 273 | * Flag for {@link #bindService}: include debugging help for mismatched |
| 274 | * calls to unbind. When this flag is set, the callstack of the following |
| 275 | * {@link #unbindService} call is retained, to be printed if a later |
| 276 | * incorrect unbind call is made. Note that doing this requires retaining |
| 277 | * information about the binding that was made for the lifetime of the app, |
| 278 | * resulting in a leak -- this should only be used for debugging. |
| 279 | */ |
| 280 | public static final int BIND_DEBUG_UNBIND = 0x0002; |
| 281 | |
Dianne Hackborn | 09c916b | 2009-12-08 14:50:51 -0800 | [diff] [blame] | 282 | /** |
| 283 | * Flag for {@link #bindService}: don't allow this binding to raise |
| 284 | * the target service's process to the foreground scheduling priority. |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 285 | * It will still be raised to at least the same memory priority |
Dianne Hackborn | 09c916b | 2009-12-08 14:50:51 -0800 | [diff] [blame] | 286 | * as the client (so that its process will not be killable in any |
| 287 | * situation where the client is not killable), but for CPU scheduling |
| 288 | * purposes it may be left in the background. This only has an impact |
| 289 | * in the situation where the binding client is a foreground process |
| 290 | * and the target service is in a background process. |
| 291 | */ |
| 292 | public static final int BIND_NOT_FOREGROUND = 0x0004; |
| 293 | |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 294 | /** |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 295 | * Flag for {@link #bindService}: indicates that the client application |
| 296 | * binding to this service considers the service to be more important than |
| 297 | * 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] | 298 | * 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] | 299 | * this is not guaranteed to be the case. |
| 300 | */ |
| 301 | public static final int BIND_ABOVE_CLIENT = 0x0008; |
| 302 | |
| 303 | /** |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 304 | * Flag for {@link #bindService}: allow the process hosting the bound |
| 305 | * service to go through its normal memory management. It will be |
| 306 | * treated more like a running service, allowing the system to |
| 307 | * (temporarily) expunge the process if low on memory or for some other |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 308 | * whim it may have, and being more aggressive about making it a candidate |
| 309 | * to be killed (and restarted) if running for a long time. |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 310 | */ |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 311 | public static final int BIND_ALLOW_OOM_MANAGEMENT = 0x0010; |
| 312 | |
| 313 | /** |
| 314 | * Flag for {@link #bindService}: don't impact the scheduling or |
| 315 | * memory management priority of the target service's hosting process. |
| 316 | * Allows the service's process to be managed on the background LRU list |
| 317 | * just like a regular application process in the background. |
| 318 | */ |
| 319 | public static final int BIND_WAIVE_PRIORITY = 0x0020; |
| 320 | |
| 321 | /** |
| 322 | * Flag for {@link #bindService}: this service is very important to |
| 323 | * the client, so should be brought to the foreground process level |
| 324 | * when the client is. Normally a process can only be raised to the |
| 325 | * visibility level by a client, even if that client is in the foreground. |
| 326 | */ |
| 327 | public static final int BIND_IMPORTANT = 0x0040; |
| 328 | |
| 329 | /** |
| 330 | * Flag for {@link #bindService}: If binding from an activity, allow the |
| 331 | * target service's process importance to be raised based on whether the |
| 332 | * activity is visible to the user, regardless whether another flag is |
| 333 | * used to reduce the amount that the client process's overall importance |
| 334 | * is used to impact it. |
| 335 | */ |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 336 | public static final int BIND_ADJUST_WITH_ACTIVITY = 0x0080; |
| 337 | |
| 338 | /** |
Amith Yamasani | 5016a78 | 2019-06-17 16:20:24 -0700 | [diff] [blame] | 339 | * Flag for {@link #bindService}: If binding from an app that is visible or user-perceptible, |
| 340 | * lower the target service's importance to below the perceptible level. This allows |
| 341 | * the system to (temporarily) expunge the bound process from memory to make room for more |
| 342 | * important user-perceptible processes. |
| 343 | */ |
| 344 | public static final int BIND_NOT_PERCEPTIBLE = 0x00000100; |
| 345 | |
| 346 | /** |
Amith Yamasani | f178c96 | 2019-03-21 19:40:11 -0700 | [diff] [blame] | 347 | * Flag for {@link #bindService}: If binding from an app that has specific capabilities |
| 348 | * due to its foreground state such as an activity or foreground service, then this flag will |
| 349 | * allow the bound app to get the same capabilities, as long as it has the required permissions |
| 350 | * as well. |
| 351 | */ |
Amith Yamasani | 5016a78 | 2019-06-17 16:20:24 -0700 | [diff] [blame] | 352 | public static final int BIND_INCLUDE_CAPABILITIES = 0x000001000; |
Amith Yamasani | f178c96 | 2019-03-21 19:40:11 -0700 | [diff] [blame] | 353 | |
Amith Yamasani | 0b3ae0e | 2019-05-10 10:29:47 -0700 | [diff] [blame] | 354 | /*********** Public flags above this line ***********/ |
| 355 | /*********** Hidden flags below this line ***********/ |
| 356 | |
| 357 | /** |
Yohei Yukawa | 5973096 | 2019-03-18 10:47:22 -0700 | [diff] [blame] | 358 | * Flag for {@link #bindService}: This flag is intended to be used only by the system to adjust |
| 359 | * the scheduling policy for IMEs (and any other out-of-process user-visible components that |
| 360 | * work closely with the top app) so that UI hosted in such services can have the same |
| 361 | * scheduling policy (e.g. SCHED_FIFO when it is enabled and TOP_APP_PRIORITY_BOOST otherwise) |
| 362 | * as the actual top-app. |
| 363 | * @hide |
| 364 | */ |
| 365 | public static final int BIND_SCHEDULE_LIKE_TOP_APP = 0x00080000; |
| 366 | |
| 367 | /** |
Michal Karpinski | e069b00 | 2019-03-07 16:15:14 +0000 | [diff] [blame] | 368 | * Flag for {@link #bindService}: allow background activity starts from the bound service's |
| 369 | * process. |
| 370 | * This flag is only respected if the caller is holding |
| 371 | * {@link android.Manifest.permission#START_ACTIVITIES_FROM_BACKGROUND}. |
| 372 | * @hide |
| 373 | */ |
| 374 | public static final int BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS = 0x00100000; |
| 375 | |
| 376 | /** |
Dianne Hackborn | c390aa8 | 2019-01-09 16:38:22 -0800 | [diff] [blame] | 377 | * @hide Flag for {@link #bindService}: the service being bound to represents a |
| 378 | * protected system component, so must have association restrictions applied to it. |
| 379 | * That is, a system config must have one or more allow-association tags limiting |
| 380 | * which packages it can interact with. If it does not have any such association |
| 381 | * restrictions, a default empty set will be created. |
| 382 | */ |
| 383 | public static final int BIND_RESTRICT_ASSOCIATIONS = 0x00200000; |
| 384 | |
| 385 | /** |
Svet Ganov | d223db3 | 2017-12-22 09:43:48 -0800 | [diff] [blame] | 386 | * @hide Flag for {@link #bindService}: allows binding to a service provided |
| 387 | * by an instant app. Note that the caller may not have access to the instant |
| 388 | * app providing the service which is a violation of the instant app sandbox. |
| 389 | * This flag is intended ONLY for development/testing and should be used with |
| 390 | * great care. Only the system is allowed to use this flag. |
| 391 | */ |
| 392 | public static final int BIND_ALLOW_INSTANT = 0x00400000; |
| 393 | |
| 394 | /** |
Dianne Hackborn | 83b40f6 | 2017-04-26 13:59:47 -0700 | [diff] [blame] | 395 | * @hide Flag for {@link #bindService}: like {@link #BIND_NOT_FOREGROUND}, but puts it |
| 396 | * up in to the important background state (instead of transient). |
| 397 | */ |
| 398 | public static final int BIND_IMPORTANT_BACKGROUND = 0x00800000; |
| 399 | |
| 400 | /** |
Felipe Leme | a1b79bf | 2016-05-24 13:06:54 -0700 | [diff] [blame] | 401 | * @hide Flag for {@link #bindService}: allows application hosting service to manage whitelists |
| 402 | * such as temporary allowing a {@code PendingIntent} to bypass Power Save mode. |
| 403 | */ |
| 404 | public static final int BIND_ALLOW_WHITELIST_MANAGEMENT = 0x01000000; |
| 405 | |
| 406 | /** |
Dianne Hackborn | d69e4c1 | 2015-04-24 09:54:54 -0700 | [diff] [blame] | 407 | * @hide Flag for {@link #bindService}: Like {@link #BIND_FOREGROUND_SERVICE}, |
| 408 | * but only applies while the device is awake. |
| 409 | */ |
| 410 | public static final int BIND_FOREGROUND_SERVICE_WHILE_AWAKE = 0x02000000; |
| 411 | |
| 412 | /** |
| 413 | * @hide Flag for {@link #bindService}: For only the case where the binding |
| 414 | * is coming from the system, set the process state to FOREGROUND_SERVICE |
| 415 | * instead of the normal maximum of IMPORTANT_FOREGROUND. That is, this is |
| 416 | * saying that the process shouldn't participate in the normal power reduction |
| 417 | * modes (removing network access etc). |
| 418 | */ |
| 419 | public static final int BIND_FOREGROUND_SERVICE = 0x04000000; |
| 420 | |
| 421 | /** |
Dianne Hackborn | f0f94d1 | 2014-03-17 16:04:21 -0700 | [diff] [blame] | 422 | * @hide Flag for {@link #bindService}: Treat the binding as hosting |
| 423 | * an activity, an unbinding as the activity going in the background. |
| 424 | * That is, when unbinding, the process when empty will go on the activity |
| 425 | * LRU list instead of the regular one, keeping it around more aggressively |
| 426 | * than it otherwise would be. This is intended for use with IMEs to try |
| 427 | * to keep IME processes around for faster keyboard switching. |
| 428 | */ |
| 429 | public static final int BIND_TREAT_LIKE_ACTIVITY = 0x08000000; |
| 430 | |
| 431 | /** |
Dianne Hackborn | b12e135 | 2012-09-26 11:39:20 -0700 | [diff] [blame] | 432 | * @hide An idea that is not yet implemented. |
| 433 | * Flag for {@link #bindService}: If binding from an activity, consider |
| 434 | * this service to be visible like the binding activity is. That is, |
| 435 | * it will be treated as something more important to keep around than |
| 436 | * invisible background activities. This will impact the number of |
| 437 | * recent activities the user can switch between without having them |
| 438 | * restart. There is no guarantee this will be respected, as the system |
Amith Yamasani | f235d0b | 2019-03-20 22:49:43 -0700 | [diff] [blame] | 439 | * tries to balance such requests from one app vs. the importance of |
Dianne Hackborn | b12e135 | 2012-09-26 11:39:20 -0700 | [diff] [blame] | 440 | * keeping other apps around. |
| 441 | */ |
Dianne Hackborn | c823051 | 2013-07-13 21:32:12 -0700 | [diff] [blame] | 442 | public static final int BIND_VISIBLE = 0x10000000; |
| 443 | |
| 444 | /** |
| 445 | * @hide |
| 446 | * Flag for {@link #bindService}: Consider this binding to be causing the target |
| 447 | * process to be showing UI, so it will be do a UI_HIDDEN memory trim when it goes |
| 448 | * away. |
| 449 | */ |
| 450 | public static final int BIND_SHOWING_UI = 0x20000000; |
Dianne Hackborn | b12e135 | 2012-09-26 11:39:20 -0700 | [diff] [blame] | 451 | |
| 452 | /** |
Dianne Hackborn | 2c84cfc | 2011-10-31 15:39:59 -0700 | [diff] [blame] | 453 | * Flag for {@link #bindService}: Don't consider the bound service to be |
| 454 | * visible, even if the caller is visible. |
| 455 | * @hide |
| 456 | */ |
| 457 | public static final int BIND_NOT_VISIBLE = 0x40000000; |
Dianne Hackborn | 130b0d2 | 2011-07-26 22:07:48 -0700 | [diff] [blame] | 458 | |
Alan Viverette | 713a5cd | 2015-12-16 15:46:32 -0500 | [diff] [blame] | 459 | /** |
Robert Sesek | b9a8666 | 2015-12-09 16:22:45 -0500 | [diff] [blame] | 460 | * Flag for {@link #bindService}: The service being bound is an |
| 461 | * {@link android.R.attr#isolatedProcess isolated}, |
| 462 | * {@link android.R.attr#externalService external} service. This binds the service into the |
| 463 | * 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] | 464 | * <p> |
| 465 | * When using this flag, the code for the service being bound will execute under the calling |
| 466 | * application's package name and user ID. Because the service must be an isolated process, |
| 467 | * it will not have direct access to the application's data, though. |
| 468 | * |
| 469 | * The purpose of this flag is to allow applications to provide services that are attributed |
| 470 | * to the app using the service, rather than the application providing the service. |
| 471 | * </p> |
Robert Sesek | b9a8666 | 2015-12-09 16:22:45 -0500 | [diff] [blame] | 472 | */ |
| 473 | public static final int BIND_EXTERNAL_SERVICE = 0x80000000; |
| 474 | |
Dianne Hackborn | a631d56 | 2018-11-20 15:58:15 -0800 | [diff] [blame] | 475 | /** |
| 476 | * These bind flags reduce the strength of the binding such that we shouldn't |
| 477 | * consider it as pulling the process up to the level of the one that is bound to it. |
| 478 | * @hide |
| 479 | */ |
| 480 | public static final int BIND_REDUCTION_FLAGS = |
| 481 | Context.BIND_ALLOW_OOM_MANAGEMENT | Context.BIND_WAIVE_PRIORITY |
Amith Yamasani | 5016a78 | 2019-06-17 16:20:24 -0700 | [diff] [blame] | 482 | | Context.BIND_NOT_PERCEPTIBLE | Context.BIND_NOT_VISIBLE; |
Dianne Hackborn | a631d56 | 2018-11-20 15:58:15 -0800 | [diff] [blame] | 483 | |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 484 | /** @hide */ |
Jeff Sharkey | ce8db99 | 2017-12-13 20:05:05 -0700 | [diff] [blame] | 485 | @IntDef(flag = true, prefix = { "RECEIVER_VISIBLE_" }, value = { |
| 486 | RECEIVER_VISIBLE_TO_INSTANT_APPS |
| 487 | }) |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 488 | @Retention(RetentionPolicy.SOURCE) |
| 489 | public @interface RegisterReceiverFlags {} |
| 490 | |
| 491 | /** |
| 492 | * Flag for {@link #registerReceiver}: The receiver can receive broadcasts from Instant Apps. |
| 493 | */ |
| 494 | public static final int RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x1; |
| 495 | |
Robert Sesek | b9a8666 | 2015-12-09 16:22:45 -0500 | [diff] [blame] | 496 | /** |
Alan Viverette | 713a5cd | 2015-12-16 15:46:32 -0500 | [diff] [blame] | 497 | * Returns an AssetManager instance for the application's package. |
| 498 | * <p> |
| 499 | * <strong>Note:</strong> Implementations of this method should return |
| 500 | * an AssetManager instance that is consistent with the Resources instance |
| 501 | * returned by {@link #getResources()}. For example, they should share the |
| 502 | * same {@link Configuration} object. |
| 503 | * |
| 504 | * @return an AssetManager instance for the application's package |
| 505 | * @see #getResources() |
| 506 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 507 | public abstract AssetManager getAssets(); |
| 508 | |
Alan Viverette | 713a5cd | 2015-12-16 15:46:32 -0500 | [diff] [blame] | 509 | /** |
| 510 | * Returns a Resources instance for the application's package. |
| 511 | * <p> |
| 512 | * <strong>Note:</strong> Implementations of this method should return |
| 513 | * a Resources instance that is consistent with the AssetManager instance |
| 514 | * returned by {@link #getAssets()}. For example, they should share the |
| 515 | * same {@link Configuration} object. |
| 516 | * |
| 517 | * @return a Resources instance for the application's package |
| 518 | * @see #getAssets() |
| 519 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 520 | public abstract Resources getResources(); |
| 521 | |
| 522 | /** Return PackageManager instance to find global package information. */ |
| 523 | public abstract PackageManager getPackageManager(); |
| 524 | |
| 525 | /** Return a ContentResolver instance for your application's package. */ |
| 526 | public abstract ContentResolver getContentResolver(); |
| 527 | |
| 528 | /** |
| 529 | * Return the Looper for the main thread of the current process. This is |
| 530 | * the thread used to dispatch calls to application components (activities, |
| 531 | * services, etc). |
Jeff Brown | f9e989d | 2013-04-04 23:04:03 -0700 | [diff] [blame] | 532 | * <p> |
| 533 | * By definition, this method returns the same result as would be obtained |
| 534 | * by calling {@link Looper#getMainLooper() Looper.getMainLooper()}. |
| 535 | * </p> |
| 536 | * |
| 537 | * @return The main looper. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 538 | */ |
| 539 | public abstract Looper getMainLooper(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 540 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 541 | /** |
Jeff Sharkey | 8439ac0 | 2017-12-12 17:26:23 -0700 | [diff] [blame] | 542 | * Return an {@link Executor} that will run enqueued tasks on the main |
| 543 | * thread associated with this context. This is the thread used to dispatch |
| 544 | * calls to application components (activities, services, etc). |
| 545 | */ |
| 546 | public Executor getMainExecutor() { |
| 547 | // This is pretty inefficient, which is why ContextImpl overrides it |
| 548 | return new HandlerExecutor(new Handler(getMainLooper())); |
| 549 | } |
| 550 | |
| 551 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 552 | * Return the context of the single, global Application object of the |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 553 | * current process. This generally should only be used if you need a |
| 554 | * Context whose lifecycle is separate from the current context, that is |
| 555 | * tied to the lifetime of the process rather than the current component. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 556 | * |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 557 | * <p>Consider for example how this interacts with |
Brad Fitzpatrick | 36af794 | 2010-12-08 11:31:07 -0800 | [diff] [blame] | 558 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter)}: |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 559 | * <ul> |
| 560 | * <li> <p>If used from an Activity context, the receiver is being registered |
| 561 | * within that activity. This means that you are expected to unregister |
| 562 | * before the activity is done being destroyed; in fact if you do not do |
| 563 | * so, the framework will clean up your leaked registration as it removes |
| 564 | * the activity and log an error. Thus, if you use the Activity context |
| 565 | * to register a receiver that is static (global to the process, not |
| 566 | * associated with an Activity instance) then that registration will be |
| 567 | * removed on you at whatever point the activity you used is destroyed. |
| 568 | * <li> <p>If used from the Context returned here, the receiver is being |
| 569 | * registered with the global state associated with your application. Thus |
| 570 | * it will never be unregistered for you. This is necessary if the receiver |
| 571 | * is associated with static data, not a particular component. However |
| 572 | * using the ApplicationContext elsewhere can easily lead to serious leaks |
| 573 | * if you forget to unregister, unbind, etc. |
| 574 | * </ul> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 575 | */ |
| 576 | public abstract Context getApplicationContext(); |
| 577 | |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 578 | /** Non-activity related autofill ids are unique in the app */ |
| 579 | private static int sLastAutofillId = View.NO_ID; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 580 | |
| 581 | /** |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 582 | * Gets the next autofill ID. |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 583 | * |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 584 | * <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] | 585 | * returned will be unique. |
| 586 | * |
| 587 | * @return A ID that is unique in the process |
| 588 | * |
| 589 | * {@hide} |
| 590 | */ |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 591 | public int getNextAutofillId() { |
| 592 | if (sLastAutofillId == View.LAST_APP_AUTOFILL_ID - 1) { |
| 593 | sLastAutofillId = View.NO_ID; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 594 | } |
| 595 | |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 596 | sLastAutofillId++; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 597 | |
Phil Weaver | 846cda93 | 2017-06-15 10:10:06 -0700 | [diff] [blame] | 598 | return sLastAutofillId; |
Philip P. Moltmann | eab62ba | 2017-03-20 10:55:43 -0700 | [diff] [blame] | 599 | } |
| 600 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 601 | /** |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 602 | * Add a new {@link ComponentCallbacks} to the base application of the |
| 603 | * Context, which will be called at the same times as the ComponentCallbacks |
| 604 | * methods of activities and other components are called. Note that you |
| 605 | * <em>must</em> be sure to use {@link #unregisterComponentCallbacks} when |
| 606 | * appropriate in the future; this will not be removed for you. |
Dianne Hackborn | 905577f | 2011-09-07 18:31:28 -0700 | [diff] [blame] | 607 | * |
| 608 | * @param callback The interface to call. This can be either a |
| 609 | * {@link ComponentCallbacks} or {@link ComponentCallbacks2} interface. |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 610 | */ |
| 611 | public void registerComponentCallbacks(ComponentCallbacks callback) { |
| 612 | getApplicationContext().registerComponentCallbacks(callback); |
| 613 | } |
| 614 | |
| 615 | /** |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 616 | * Remove a {@link ComponentCallbacks} object that was previously registered |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 617 | * with {@link #registerComponentCallbacks(ComponentCallbacks)}. |
| 618 | */ |
| 619 | public void unregisterComponentCallbacks(ComponentCallbacks callback) { |
| 620 | getApplicationContext().unregisterComponentCallbacks(callback); |
| 621 | } |
| 622 | |
| 623 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 624 | * Return a localized, styled CharSequence from the application's package's |
| 625 | * default string table. |
| 626 | * |
| 627 | * @param resId Resource id for the CharSequence text |
| 628 | */ |
Chris Craik | ceb2693 | 2018-02-01 15:51:34 -0800 | [diff] [blame] | 629 | @NonNull |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 630 | public final CharSequence getText(@StringRes int resId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 631 | return getResources().getText(resId); |
| 632 | } |
| 633 | |
| 634 | /** |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 635 | * 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] | 636 | * default string table. |
| 637 | * |
| 638 | * @param resId Resource id for the string |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 639 | * @return The string data associated with the resource, stripped of styled |
| 640 | * text information. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 641 | */ |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 642 | @NonNull |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 643 | public final String getString(@StringRes int resId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 644 | return getResources().getString(resId); |
| 645 | } |
| 646 | |
| 647 | /** |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 648 | * 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] | 649 | * default string table, substituting the format arguments as defined in |
| 650 | * {@link java.util.Formatter} and {@link java.lang.String#format}. |
| 651 | * |
| 652 | * @param resId Resource id for the format string |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 653 | * @param formatArgs The format arguments that will be used for |
| 654 | * substitution. |
| 655 | * @return The string data associated with the resource, formatted and |
| 656 | * stripped of styled text information. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 657 | */ |
Alan Viverette | b4004df | 2015-04-29 16:55:42 -0700 | [diff] [blame] | 658 | @NonNull |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 659 | public final String getString(@StringRes int resId, Object... formatArgs) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 660 | return getResources().getString(resId, formatArgs); |
| 661 | } |
| 662 | |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 663 | /** |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 664 | * Returns a color associated with a particular resource ID and styled for |
| 665 | * the current theme. |
| 666 | * |
| 667 | * @param id The desired resource identifier, as generated by the aapt |
| 668 | * tool. This integer encodes the package, type, and resource |
| 669 | * entry. The value 0 is an invalid identifier. |
| 670 | * @return A single color value in the form 0xAARRGGBB. |
| 671 | * @throws android.content.res.Resources.NotFoundException if the given ID |
| 672 | * does not exist. |
| 673 | */ |
Tor Norbye | 3e4cda7 | 2015-06-10 08:14:31 -0700 | [diff] [blame] | 674 | @ColorInt |
| 675 | public final int getColor(@ColorRes int id) { |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 676 | return getResources().getColor(id, getTheme()); |
| 677 | } |
| 678 | |
| 679 | /** |
| 680 | * Returns a drawable object associated with a particular resource ID and |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 681 | * styled for the current theme. |
| 682 | * |
| 683 | * @param id The desired resource identifier, as generated by the aapt |
| 684 | * tool. This integer encodes the package, type, and resource |
| 685 | * entry. The value 0 is an invalid identifier. |
Chris Craik | ceb2693 | 2018-02-01 15:51:34 -0800 | [diff] [blame] | 686 | * @return An object that can be used to draw this resource. |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 687 | * @throws android.content.res.Resources.NotFoundException if the given ID |
| 688 | * does not exist. |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 689 | */ |
Chris Craik | 1194b0b | 2018-03-23 13:36:24 -0700 | [diff] [blame] | 690 | @Nullable |
Tor Norbye | 3e4cda7 | 2015-06-10 08:14:31 -0700 | [diff] [blame] | 691 | public final Drawable getDrawable(@DrawableRes int id) { |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 692 | return getResources().getDrawable(id, getTheme()); |
| 693 | } |
| 694 | |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 695 | /** |
| 696 | * Returns a color state list associated with a particular resource ID and |
| 697 | * styled for the current theme. |
| 698 | * |
| 699 | * @param id The desired resource identifier, as generated by the aapt |
| 700 | * tool. This integer encodes the package, type, and resource |
| 701 | * entry. The value 0 is an invalid identifier. |
Chris Craik | ceb2693 | 2018-02-01 15:51:34 -0800 | [diff] [blame] | 702 | * @return A color state list. |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 703 | * @throws android.content.res.Resources.NotFoundException if the given ID |
| 704 | * does not exist. |
| 705 | */ |
Chris Craik | ceb2693 | 2018-02-01 15:51:34 -0800 | [diff] [blame] | 706 | @NonNull |
Tor Norbye | 3e4cda7 | 2015-06-10 08:14:31 -0700 | [diff] [blame] | 707 | public final ColorStateList getColorStateList(@ColorRes int id) { |
Alan Viverette | 45c4bbb | 2015-01-05 14:59:19 -0800 | [diff] [blame] | 708 | return getResources().getColorStateList(id, getTheme()); |
| 709 | } |
| 710 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 711 | /** |
| 712 | * Set the base theme for this context. Note that this should be called |
| 713 | * before any views are instantiated in the Context (for example before |
| 714 | * calling {@link android.app.Activity#setContentView} or |
| 715 | * {@link android.view.LayoutInflater#inflate}). |
| 716 | * |
| 717 | * @param resid The style resource describing the theme. |
| 718 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 719 | public abstract void setTheme(@StyleRes int resid); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 720 | |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 721 | /** @hide Needed for some internal implementation... not public because |
| 722 | * you can't assume this actually means anything. */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 723 | @UnsupportedAppUsage |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 724 | public int getThemeResId() { |
| 725 | return 0; |
| 726 | } |
| 727 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 728 | /** |
| 729 | * Return the Theme object associated with this Context. |
| 730 | */ |
Jon Miranda | 836c0a8 | 2014-08-11 12:32:26 -0700 | [diff] [blame] | 731 | @ViewDebug.ExportedProperty(deepExport = true) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 732 | public abstract Resources.Theme getTheme(); |
| 733 | |
| 734 | /** |
| 735 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 736 | * {@link android.content.res.Resources.Theme#obtainStyledAttributes(int[])} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 737 | * for more information. |
| 738 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 739 | * @see android.content.res.Resources.Theme#obtainStyledAttributes(int[]) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 740 | */ |
Aurimas Liutikas | 77acf4b | 2018-12-19 17:31:03 -0800 | [diff] [blame] | 741 | @NonNull |
| 742 | public final TypedArray obtainStyledAttributes(@NonNull @StyleableRes int[] attrs) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 743 | return getTheme().obtainStyledAttributes(attrs); |
| 744 | } |
| 745 | |
| 746 | /** |
| 747 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 748 | * {@link android.content.res.Resources.Theme#obtainStyledAttributes(int, int[])} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 749 | * for more information. |
| 750 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 751 | * @see android.content.res.Resources.Theme#obtainStyledAttributes(int, int[]) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 752 | */ |
Aurimas Liutikas | 77acf4b | 2018-12-19 17:31:03 -0800 | [diff] [blame] | 753 | @NonNull |
| 754 | public final TypedArray obtainStyledAttributes(@StyleRes int resid, |
| 755 | @NonNull @StyleableRes int[] attrs) throws Resources.NotFoundException { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 756 | return getTheme().obtainStyledAttributes(resid, attrs); |
| 757 | } |
| 758 | |
| 759 | /** |
| 760 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 761 | * {@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] | 762 | * for more information. |
| 763 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 764 | * @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] | 765 | */ |
Aurimas Liutikas | 77acf4b | 2018-12-19 17:31:03 -0800 | [diff] [blame] | 766 | @NonNull |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 767 | public final TypedArray obtainStyledAttributes( |
Aurimas Liutikas | 77acf4b | 2018-12-19 17:31:03 -0800 | [diff] [blame] | 768 | @Nullable AttributeSet set, @NonNull @StyleableRes int[] attrs) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 769 | return getTheme().obtainStyledAttributes(set, attrs, 0, 0); |
| 770 | } |
| 771 | |
| 772 | /** |
| 773 | * Retrieve styled attribute information in this Context's theme. See |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 774 | * {@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] | 775 | * for more information. |
| 776 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 777 | * @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] | 778 | */ |
Aurimas Liutikas | 77acf4b | 2018-12-19 17:31:03 -0800 | [diff] [blame] | 779 | @NonNull |
| 780 | public final TypedArray obtainStyledAttributes(@Nullable AttributeSet set, |
| 781 | @NonNull @StyleableRes int[] attrs, @AttrRes int defStyleAttr, |
Tor Norbye | c91531a | 2015-04-01 17:41:55 -0700 | [diff] [blame] | 782 | @StyleRes int defStyleRes) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 783 | return getTheme().obtainStyledAttributes( |
| 784 | set, attrs, defStyleAttr, defStyleRes); |
| 785 | } |
| 786 | |
| 787 | /** |
| 788 | * Return a class loader you can use to retrieve classes in this package. |
| 789 | */ |
| 790 | public abstract ClassLoader getClassLoader(); |
| 791 | |
| 792 | /** Return the name of this application's package. */ |
| 793 | public abstract String getPackageName(); |
| 794 | |
Jaewan Kim | 0980c7f | 2018-11-28 23:55:15 +0900 | [diff] [blame] | 795 | /** |
| 796 | * @hide Return the name of the base context this context is derived from. |
| 797 | * This is the same as {@link #getOpPackageName()} except in |
| 798 | * cases where system components are loaded into other app processes, in which |
| 799 | * case {@link #getOpPackageName()} will be the name of the primary package in |
| 800 | * that process (so that app ops uid verification will work with the name). |
| 801 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 802 | @UnsupportedAppUsage |
Dianne Hackborn | d8e1dbb | 2013-01-17 17:47:37 -0800 | [diff] [blame] | 803 | public abstract String getBasePackageName(); |
| 804 | |
Jaewan Kim | 0980c7f | 2018-11-28 23:55:15 +0900 | [diff] [blame] | 805 | /** |
| 806 | * Return the package name that should be used for {@link android.app.AppOpsManager} calls from |
| 807 | * this context, so that app ops manager's uid verification will work with the name. |
| 808 | * <p> |
| 809 | * This is not generally intended for third party application developers. |
| 810 | */ |
Adrian Roos | ebc927c | 2019-02-28 16:21:18 +0100 | [diff] [blame] | 811 | @NonNull |
Adrian Roos | fe6aeaf | 2019-01-22 16:58:56 +0100 | [diff] [blame] | 812 | public String getOpPackageName() { |
| 813 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 814 | } |
Dianne Hackborn | 95d7853 | 2013-09-11 09:51:14 -0700 | [diff] [blame] | 815 | |
Philip P. Moltmann | 59076d8 | 2019-08-19 15:00:40 -0700 | [diff] [blame] | 816 | /** |
| 817 | * <p>Features are used in complex apps to logically separate parts of the app. E.g. a |
| 818 | * blogging app might also have a instant messaging app built in. |
| 819 | * |
| 820 | * @return the feature id this context is for or {@code null} if this is the default |
| 821 | * feature. |
| 822 | */ |
| 823 | public @Nullable String getFeatureId() { |
| 824 | return null; |
| 825 | } |
| 826 | |
Dianne Hackborn | 5c1e00b | 2009-06-18 17:10:57 -0700 | [diff] [blame] | 827 | /** Return the full application info for this context's package. */ |
| 828 | public abstract ApplicationInfo getApplicationInfo(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 829 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 830 | /** |
Kenny Root | 3214839 | 2010-01-21 15:40:47 -0800 | [diff] [blame] | 831 | * Return the full path to this context's primary Android package. |
| 832 | * The Android package is a ZIP file which contains the application's |
| 833 | * primary resources. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 834 | * |
| 835 | * <p>Note: this is not generally useful for applications, since they should |
| 836 | * not be directly accessing the file system. |
| 837 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 838 | * @return String Path to the resources. |
| 839 | */ |
| 840 | public abstract String getPackageResourcePath(); |
| 841 | |
| 842 | /** |
Kenny Root | 3214839 | 2010-01-21 15:40:47 -0800 | [diff] [blame] | 843 | * Return the full path to this context's primary Android package. |
| 844 | * The Android package is a ZIP file which contains application's |
| 845 | * primary code and assets. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 846 | * |
| 847 | * <p>Note: this is not generally useful for applications, since they should |
| 848 | * not be directly accessing the file system. |
| 849 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 850 | * @return String Path to the code and assets. |
| 851 | */ |
| 852 | public abstract String getPackageCodePath(); |
| 853 | |
| 854 | /** |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 855 | * @hide |
| 856 | * @deprecated use {@link #getSharedPreferencesPath(String)} |
Joe Onorato | 23ecae3 | 2009-06-10 17:07:15 -0700 | [diff] [blame] | 857 | */ |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 858 | @Deprecated |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 859 | @UnsupportedAppUsage |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 860 | public File getSharedPrefsFile(String name) { |
| 861 | return getSharedPreferencesPath(name); |
| 862 | } |
Joe Onorato | 23ecae3 | 2009-06-10 17:07:15 -0700 | [diff] [blame] | 863 | |
| 864 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 865 | * Retrieve and hold the contents of the preferences file 'name', returning |
| 866 | * a SharedPreferences through which you can retrieve and modify its |
| 867 | * values. Only one instance of the SharedPreferences object is returned |
| 868 | * to any callers for the same name, meaning they will see each other's |
| 869 | * edits as soon as they are made. |
| 870 | * |
Nate Fischer | 5272c37 | 2019-08-27 16:37:00 -0700 | [diff] [blame] | 871 | * <p>This method is thread-safe. |
Jonathan Dormody | 1bca5db | 2017-11-16 11:25:20 -0700 | [diff] [blame] | 872 | * |
Nate Fischer | 5272c37 | 2019-08-27 16:37:00 -0700 | [diff] [blame] | 873 | * <p>If the preferences directory does not already exist, it will be created when this method |
| 874 | * is called. |
| 875 | * |
| 876 | * <p>If a preferences file by this name does not exist, it will be created when you retrieve an |
| 877 | * editor ({@link SharedPreferences#edit()}) and then commit changes ({@link |
| 878 | * SharedPreferences.Editor#commit()} or {@link SharedPreferences.Editor#apply()}). |
| 879 | * |
| 880 | * @param name Desired preferences file. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 881 | * @param mode Operating mode. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 882 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 883 | * @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] | 884 | * to retrieve and modify the preference values. |
| 885 | * |
| 886 | * @see #MODE_PRIVATE |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 887 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 888 | public abstract SharedPreferences getSharedPreferences(String name, @PreferencesMode int mode); |
Jeff Sharkey | 8fc29cf | 2015-11-30 17:51:00 -0700 | [diff] [blame] | 889 | |
| 890 | /** |
| 891 | * Retrieve and hold the contents of the preferences file, returning |
| 892 | * a SharedPreferences through which you can retrieve and modify its |
| 893 | * values. Only one instance of the SharedPreferences object is returned |
| 894 | * to any callers for the same name, meaning they will see each other's |
| 895 | * edits as soon as they are made. |
| 896 | * |
| 897 | * @param file Desired preferences file. If a preferences file by this name |
| 898 | * does not exist, it will be created when you retrieve an |
| 899 | * editor (SharedPreferences.edit()) and then commit changes (Editor.commit()). |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 900 | * @param mode Operating mode. |
Jeff Sharkey | 8fc29cf | 2015-11-30 17:51:00 -0700 | [diff] [blame] | 901 | * |
| 902 | * @return The single {@link SharedPreferences} instance that can be used |
| 903 | * to retrieve and modify the preference values. |
| 904 | * |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 905 | * @see #getSharedPreferencesPath(String) |
Jeff Sharkey | 8fc29cf | 2015-11-30 17:51:00 -0700 | [diff] [blame] | 906 | * @see #MODE_PRIVATE |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 907 | * @removed |
Jeff Sharkey | 8fc29cf | 2015-11-30 17:51:00 -0700 | [diff] [blame] | 908 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 909 | public abstract SharedPreferences getSharedPreferences(File file, @PreferencesMode int mode); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 910 | |
| 911 | /** |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 912 | * Move an existing shared preferences file from the given source storage |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 913 | * context to this context. This is typically used to migrate data between |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 914 | * storage locations after an upgrade, such as moving to device protected |
| 915 | * storage. |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 916 | * |
| 917 | * @param sourceContext The source context which contains the existing |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 918 | * shared preferences to move. |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 919 | * @param name The name of the shared preferences file. |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 920 | * @return {@code true} if the move was successful or if the shared |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 921 | * preferences didn't exist in the source context, otherwise |
| 922 | * {@code false}. |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 923 | * @see #createDeviceProtectedStorageContext() |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 924 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 925 | public abstract boolean moveSharedPreferencesFrom(Context sourceContext, String name); |
| 926 | |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 927 | /** |
| 928 | * Delete an existing shared preferences file. |
| 929 | * |
| 930 | * @param name The name (unique in the application package) of the shared |
| 931 | * preferences file. |
| 932 | * @return {@code true} if the shared preferences file was successfully |
| 933 | * deleted; else {@code false}. |
| 934 | * @see #getSharedPreferences(String, int) |
| 935 | */ |
| 936 | public abstract boolean deleteSharedPreferences(String name); |
| 937 | |
Christopher Tate | fe2368c | 2017-05-17 15:42:35 -0700 | [diff] [blame] | 938 | /** @hide */ |
| 939 | public abstract void reloadSharedPreferences(); |
| 940 | |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 941 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 942 | * Open a private file associated with this Context's application package |
| 943 | * for reading. |
| 944 | * |
| 945 | * @param name The name of the file to open; can not contain path |
| 946 | * separators. |
| 947 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 948 | * @return The resulting {@link FileInputStream}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 949 | * |
| 950 | * @see #openFileOutput |
| 951 | * @see #fileList |
| 952 | * @see #deleteFile |
| 953 | * @see java.io.FileInputStream#FileInputStream(String) |
| 954 | */ |
| 955 | public abstract FileInputStream openFileInput(String name) |
| 956 | throws FileNotFoundException; |
| 957 | |
| 958 | /** |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 959 | * Open a private file associated with this Context's application package |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 960 | * for writing. Creates the file if it doesn't already exist. |
| 961 | * <p> |
| 962 | * No additional permissions are required for the calling app to read or |
| 963 | * write the returned file. |
Ricardo Cervera | 90a5f98 | 2014-04-04 10:26:05 -0700 | [diff] [blame] | 964 | * |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 965 | * @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] | 966 | * separators. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 967 | * @param mode Operating mode. |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 968 | * @return The resulting {@link FileOutputStream}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 969 | * @see #MODE_APPEND |
| 970 | * @see #MODE_PRIVATE |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 971 | * @see #openFileInput |
| 972 | * @see #fileList |
| 973 | * @see #deleteFile |
| 974 | * @see java.io.FileOutputStream#FileOutputStream(String) |
| 975 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 976 | public abstract FileOutputStream openFileOutput(String name, @FileMode int mode) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 977 | throws FileNotFoundException; |
| 978 | |
| 979 | /** |
| 980 | * Delete the given private file associated with this Context's |
| 981 | * application package. |
| 982 | * |
| 983 | * @param name The name of the file to delete; can not contain path |
| 984 | * separators. |
| 985 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 986 | * @return {@code true} if the file was successfully deleted; else |
| 987 | * {@code false}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 988 | * |
| 989 | * @see #openFileInput |
| 990 | * @see #openFileOutput |
| 991 | * @see #fileList |
| 992 | * @see java.io.File#delete() |
| 993 | */ |
| 994 | public abstract boolean deleteFile(String name); |
| 995 | |
| 996 | /** |
| 997 | * Returns the absolute path on the filesystem where a file created with |
| 998 | * {@link #openFileOutput} is stored. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 999 | * <p> |
| 1000 | * The returned path may change over time if the calling app is moved to an |
| 1001 | * 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] | 1002 | * |
| 1003 | * @param name The name of the file for which you would like to get |
| 1004 | * its path. |
| 1005 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1006 | * @return An absolute path to the given file. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1007 | * |
| 1008 | * @see #openFileOutput |
| 1009 | * @see #getFilesDir |
| 1010 | * @see #getDir |
| 1011 | */ |
| 1012 | public abstract File getFileStreamPath(String name); |
| 1013 | |
| 1014 | /** |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 1015 | * Returns the absolute path on the filesystem where a file created with |
| 1016 | * {@link #getSharedPreferences(String, int)} is stored. |
| 1017 | * <p> |
| 1018 | * The returned path may change over time if the calling app is moved to an |
| 1019 | * adopted storage device, so only relative paths should be persisted. |
| 1020 | * |
| 1021 | * @param name The name of the shared preferences for which you would like |
| 1022 | * to get a path. |
| 1023 | * @return An absolute path to the given file. |
| 1024 | * @see #getSharedPreferences(String, int) |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 1025 | * @removed |
Jeff Sharkey | 6a6cdaf | 2015-12-07 19:25:19 -0700 | [diff] [blame] | 1026 | */ |
| 1027 | public abstract File getSharedPreferencesPath(String name); |
| 1028 | |
| 1029 | /** |
Jeff Sharkey | 2c1ba9a | 2016-02-17 15:29:38 -0700 | [diff] [blame] | 1030 | * Returns the absolute path to the directory on the filesystem where all |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 1031 | * private files belonging to this app are stored. Apps should not use this |
| 1032 | * path directly; they should instead use {@link #getFilesDir()}, |
| 1033 | * {@link #getCacheDir()}, {@link #getDir(String, int)}, or other storage |
| 1034 | * APIs on this class. |
Jeff Sharkey | 2c1ba9a | 2016-02-17 15:29:38 -0700 | [diff] [blame] | 1035 | * <p> |
| 1036 | * The returned path may change over time if the calling app is moved to an |
| 1037 | * adopted storage device, so only relative paths should be persisted. |
| 1038 | * <p> |
| 1039 | * No additional permissions are required for the calling app to read or |
| 1040 | * write files under the returned path. |
| 1041 | * |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 1042 | * @see ApplicationInfo#dataDir |
Jeff Sharkey | 2c1ba9a | 2016-02-17 15:29:38 -0700 | [diff] [blame] | 1043 | */ |
| 1044 | public abstract File getDataDir(); |
| 1045 | |
| 1046 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1047 | * Returns the absolute path to the directory on the filesystem where files |
| 1048 | * created with {@link #openFileOutput} are stored. |
| 1049 | * <p> |
| 1050 | * The returned path may change over time if the calling app is moved to an |
| 1051 | * adopted storage device, so only relative paths should be persisted. |
| 1052 | * <p> |
| 1053 | * No additional permissions are required for the calling app to read or |
| 1054 | * write files under the returned path. |
Ricardo Cervera | 90a5f98 | 2014-04-04 10:26:05 -0700 | [diff] [blame] | 1055 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1056 | * @return The path of the directory holding application files. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1057 | * @see #openFileOutput |
| 1058 | * @see #getFileStreamPath |
| 1059 | * @see #getDir |
| 1060 | */ |
| 1061 | public abstract File getFilesDir(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1062 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1063 | /** |
Felka Chang | 0d824d4 | 2019-11-19 15:06:52 +0800 | [diff] [blame] | 1064 | * Returns the absolute path to the directory that is related to the crate on the filesystem. |
| 1065 | * <p> |
| 1066 | * The crateId require a validated file name. It can't contain any "..", ".", |
| 1067 | * {@link File#separatorChar} etc.. |
| 1068 | * </p> |
| 1069 | * <p> |
| 1070 | * The returned path may change over time if the calling app is moved to an |
| 1071 | * adopted storage device, so only relative paths should be persisted. |
| 1072 | * </p> |
| 1073 | * <p> |
| 1074 | * No additional permissions are required for the calling app to read or |
| 1075 | * write files under the returned path. |
| 1076 | *</p> |
| 1077 | * |
| 1078 | * @param crateId the relative validated file name under {@link Context#getDataDir()}/crates |
| 1079 | * @return the crate directory file. |
| 1080 | * @hide |
| 1081 | */ |
| 1082 | @NonNull |
| 1083 | @TestApi |
| 1084 | public File getCrateDir(@NonNull String crateId) { |
| 1085 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 1086 | } |
| 1087 | |
| 1088 | /** |
Christopher Tate | a7835b6 | 2014-07-11 17:25:57 -0700 | [diff] [blame] | 1089 | * Returns the absolute path to the directory on the filesystem similar to |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1090 | * {@link #getFilesDir()}. The difference is that files placed under this |
| 1091 | * directory will be excluded from automatic backup to remote storage. See |
Christopher Tate | a7835b6 | 2014-07-11 17:25:57 -0700 | [diff] [blame] | 1092 | * {@link android.app.backup.BackupAgent BackupAgent} for a full discussion |
| 1093 | * of the automatic backup mechanism in Android. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1094 | * <p> |
| 1095 | * The returned path may change over time if the calling app is moved to an |
| 1096 | * adopted storage device, so only relative paths should be persisted. |
| 1097 | * <p> |
| 1098 | * No additional permissions are required for the calling app to read or |
| 1099 | * write files under the returned path. |
Christopher Tate | a7835b6 | 2014-07-11 17:25:57 -0700 | [diff] [blame] | 1100 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1101 | * @return The path of the directory holding application files that will not |
| 1102 | * be automatically backed up to remote storage. |
Christopher Tate | a7835b6 | 2014-07-11 17:25:57 -0700 | [diff] [blame] | 1103 | * @see #openFileOutput |
| 1104 | * @see #getFileStreamPath |
| 1105 | * @see #getDir |
| 1106 | * @see android.app.backup.BackupAgent |
| 1107 | */ |
| 1108 | public abstract File getNoBackupFilesDir(); |
| 1109 | |
| 1110 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1111 | * Returns the absolute path to the directory on the primary shared/external |
| 1112 | * storage device where the application can place persistent files it owns. |
| 1113 | * These files are internal to the applications, and not typically visible |
| 1114 | * to the user as media. |
| 1115 | * <p> |
| 1116 | * This is like {@link #getFilesDir()} in that these files will be deleted |
| 1117 | * when the application is uninstalled, however there are some important |
| 1118 | * differences: |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1119 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1120 | * <li>Shared storage may not always be available, since removable media can |
| 1121 | * be ejected by the user. Media state can be checked using |
| 1122 | * {@link Environment#getExternalStorageState(File)}. |
| 1123 | * <li>There is no security enforced with these files. For example, any |
| 1124 | * application holding |
| 1125 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1126 | * these files. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1127 | * </ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1128 | * <p> |
| 1129 | * If a shared storage device is emulated (as determined by |
| 1130 | * {@link Environment#isExternalStorageEmulated(File)}), it's contents are |
| 1131 | * backed by a private user data partition, which means there is little |
| 1132 | * benefit to storing data here instead of the private directories returned |
| 1133 | * by {@link #getFilesDir()}, etc. |
| 1134 | * <p> |
| 1135 | * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1136 | * 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] | 1137 | * accessible to the calling app. This only applies to paths generated for |
| 1138 | * package name of the calling application. To access paths belonging to |
| 1139 | * other packages, |
| 1140 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} and/or |
| 1141 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} are required. |
| 1142 | * <p> |
| 1143 | * On devices with multiple users (as described by {@link UserManager}), |
| 1144 | * each user has their own isolated shared storage. Applications only have |
| 1145 | * access to the shared storage for the user they're running as. |
| 1146 | * <p> |
| 1147 | * The returned path may change over time if different shared storage media |
| 1148 | * is inserted, so only relative paths should be persisted. |
| 1149 | * <p> |
| 1150 | * Here is an example of typical code to manipulate a file in an |
| 1151 | * application's shared storage: |
| 1152 | * </p> |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1153 | * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java |
| 1154 | * private_file} |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1155 | * <p> |
| 1156 | * If you supply a non-null <var>type</var> to this function, the returned |
| 1157 | * file will be a path to a sub-directory of the given type. Though these |
| 1158 | * files are not automatically scanned by the media scanner, you can |
| 1159 | * explicitly add them to the media database with |
| 1160 | * {@link android.media.MediaScannerConnection#scanFile(Context, String[], String[], android.media.MediaScannerConnection.OnScanCompletedListener) |
| 1161 | * MediaScannerConnection.scanFile}. Note that this is not the same as |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1162 | * {@link android.os.Environment#getExternalStoragePublicDirectory |
| 1163 | * Environment.getExternalStoragePublicDirectory()}, which provides |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1164 | * directories of media shared by all applications. The directories returned |
| 1165 | * here are owned by the application, and their contents will be removed |
| 1166 | * when the application is uninstalled. Unlike |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1167 | * {@link android.os.Environment#getExternalStoragePublicDirectory |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1168 | * Environment.getExternalStoragePublicDirectory()}, the directory returned |
| 1169 | * here will be automatically created for you. |
| 1170 | * <p> |
| 1171 | * Here is an example of typical code to manipulate a picture in an |
| 1172 | * application's shared storage and add it to the media database: |
| 1173 | * </p> |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1174 | * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java |
| 1175 | * private_picture} |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 1176 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1177 | * @param type The type of files directory to return. May be {@code null} |
| 1178 | * for the root of the files directory or one of the following |
| 1179 | * constants for a subdirectory: |
| 1180 | * {@link android.os.Environment#DIRECTORY_MUSIC}, |
| 1181 | * {@link android.os.Environment#DIRECTORY_PODCASTS}, |
| 1182 | * {@link android.os.Environment#DIRECTORY_RINGTONES}, |
| 1183 | * {@link android.os.Environment#DIRECTORY_ALARMS}, |
| 1184 | * {@link android.os.Environment#DIRECTORY_NOTIFICATIONS}, |
| 1185 | * {@link android.os.Environment#DIRECTORY_PICTURES}, or |
| 1186 | * {@link android.os.Environment#DIRECTORY_MOVIES}. |
| 1187 | * @return the absolute path to application-specific directory. May return |
| 1188 | * {@code null} if shared storage is not currently available. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1189 | * @see #getFilesDir |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1190 | * @see #getExternalFilesDirs(String) |
| 1191 | * @see Environment#getExternalStorageState(File) |
| 1192 | * @see Environment#isExternalStorageEmulated(File) |
| 1193 | * @see Environment#isExternalStorageRemovable(File) |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1194 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1195 | @Nullable |
| 1196 | public abstract File getExternalFilesDir(@Nullable String type); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1197 | |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1198 | /** |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1199 | * Returns absolute paths to application-specific directories on all |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1200 | * shared/external storage devices where the application can place |
| 1201 | * persistent files it owns. These files are internal to the application, |
| 1202 | * and not typically visible to the user as media. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1203 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1204 | * This is like {@link #getFilesDir()} in that these files will be deleted |
| 1205 | * when the application is uninstalled, however there are some important |
| 1206 | * differences: |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1207 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1208 | * <li>Shared storage may not always be available, since removable media can |
| 1209 | * be ejected by the user. Media state can be checked using |
| 1210 | * {@link Environment#getExternalStorageState(File)}. |
| 1211 | * <li>There is no security enforced with these files. For example, any |
| 1212 | * application holding |
| 1213 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 1214 | * these files. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1215 | * </ul> |
| 1216 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1217 | * If a shared storage device is emulated (as determined by |
| 1218 | * {@link Environment#isExternalStorageEmulated(File)}), it's contents are |
| 1219 | * backed by a private user data partition, which means there is little |
| 1220 | * benefit to storing data here instead of the private directories returned |
| 1221 | * by {@link #getFilesDir()}, etc. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1222 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1223 | * Shared storage devices returned here are considered a stable part of the |
| 1224 | * device, including physical media slots under a protective cover. The |
| 1225 | * returned paths do not include transient devices, such as USB flash drives |
| 1226 | * connected to handheld devices. |
| 1227 | * <p> |
| 1228 | * 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] | 1229 | * example, an app may choose to store large files on the device with the |
| 1230 | * most available space, as measured by {@link StatFs}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1231 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1232 | * No additional permissions are required for the calling app to read or |
| 1233 | * write files under the returned path. Write access outside of these paths |
| 1234 | * on secondary external storage devices is not available. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1235 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1236 | * The returned path may change over time if different shared storage media |
| 1237 | * is inserted, so only relative paths should be persisted. |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 1238 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1239 | * @param type The type of files directory to return. May be {@code null} |
| 1240 | * for the root of the files directory or one of the following |
| 1241 | * constants for a subdirectory: |
| 1242 | * {@link android.os.Environment#DIRECTORY_MUSIC}, |
| 1243 | * {@link android.os.Environment#DIRECTORY_PODCASTS}, |
| 1244 | * {@link android.os.Environment#DIRECTORY_RINGTONES}, |
| 1245 | * {@link android.os.Environment#DIRECTORY_ALARMS}, |
| 1246 | * {@link android.os.Environment#DIRECTORY_NOTIFICATIONS}, |
| 1247 | * {@link android.os.Environment#DIRECTORY_PICTURES}, or |
| 1248 | * {@link android.os.Environment#DIRECTORY_MOVIES}. |
| 1249 | * @return the absolute paths to application-specific directories. Some |
| 1250 | * individual paths may be {@code null} if that shared storage is |
| 1251 | * not currently available. The first path returned is the same as |
| 1252 | * {@link #getExternalFilesDir(String)}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1253 | * @see #getExternalFilesDir(String) |
Jeff Sharkey | 4ca728c | 2014-01-10 16:27:19 -0800 | [diff] [blame] | 1254 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1255 | * @see Environment#isExternalStorageEmulated(File) |
| 1256 | * @see Environment#isExternalStorageRemovable(File) |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1257 | */ |
| 1258 | public abstract File[] getExternalFilesDirs(String type); |
| 1259 | |
| 1260 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1261 | * Return the primary shared/external storage directory where this |
| 1262 | * application's OBB files (if there are any) can be found. Note if the |
| 1263 | * application does not have any OBB files, this directory may not exist. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1264 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1265 | * This is like {@link #getFilesDir()} in that these files will be deleted |
| 1266 | * when the application is uninstalled, however there are some important |
| 1267 | * differences: |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1268 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1269 | * <li>Shared storage may not always be available, since removable media can |
| 1270 | * be ejected by the user. Media state can be checked using |
| 1271 | * {@link Environment#getExternalStorageState(File)}. |
| 1272 | * <li>There is no security enforced with these files. For example, any |
| 1273 | * application holding |
| 1274 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1275 | * these files. |
| 1276 | * </ul> |
| 1277 | * <p> |
| 1278 | * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions |
Dave Friedman | cfe5088 | 2017-07-05 00:40:07 -0700 | [diff] [blame] | 1279 | * are required to read or write to the path that this method returns. |
| 1280 | * However, starting from {@link android.os.Build.VERSION_CODES#M}, |
| 1281 | * to read the OBB expansion files, you must declare the |
| 1282 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} permission in the app manifest and ask for |
| 1283 | * permission at runtime as follows: |
| 1284 | * </p> |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1285 | * <p> |
Dave Friedman | cfe5088 | 2017-07-05 00:40:07 -0700 | [diff] [blame] | 1286 | * {@code <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" |
| 1287 | * android:maxSdkVersion="23" />} |
| 1288 | * </p> |
| 1289 | * <p> |
| 1290 | * Starting from {@link android.os.Build.VERSION_CODES#N}, |
| 1291 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} |
| 1292 | * permission is not required, so don’t ask for this |
| 1293 | * permission at runtime. To handle both cases, your app must first try to read the OBB file, |
| 1294 | * and if it fails, you must request |
| 1295 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} permission at runtime. |
| 1296 | * </p> |
| 1297 | * |
| 1298 | * <p> |
| 1299 | * The following code snippet shows how to do this: |
| 1300 | * </p> |
| 1301 | * |
| 1302 | * <pre> |
| 1303 | * File obb = new File(obb_filename); |
| 1304 | * boolean open_failed = false; |
| 1305 | * |
| 1306 | * try { |
| 1307 | * BufferedReader br = new BufferedReader(new FileReader(obb)); |
| 1308 | * open_failed = false; |
| 1309 | * ReadObbFile(br); |
| 1310 | * } catch (IOException e) { |
| 1311 | * open_failed = true; |
| 1312 | * } |
| 1313 | * |
| 1314 | * if (open_failed) { |
| 1315 | * // request READ_EXTERNAL_STORAGE permission before reading OBB file |
| 1316 | * ReadObbFileWithPermission(); |
| 1317 | * } |
| 1318 | * </pre> |
| 1319 | * |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1320 | * On devices with multiple users (as described by {@link UserManager}), |
Jeff Sharkey | 8c16579 | 2012-10-22 14:08:29 -0700 | [diff] [blame] | 1321 | * multiple users may share the same OBB storage location. Applications |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1322 | * should ensure that multiple instances running under different users don't |
| 1323 | * interfere with each other. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1324 | * |
| 1325 | * @return the absolute path to application-specific directory. May return |
| 1326 | * {@code null} if shared storage is not currently available. |
| 1327 | * @see #getObbDirs() |
| 1328 | * @see Environment#getExternalStorageState(File) |
| 1329 | * @see Environment#isExternalStorageEmulated(File) |
| 1330 | * @see Environment#isExternalStorageRemovable(File) |
Dianne Hackborn | 805fd7e | 2011-01-16 18:30:29 -0800 | [diff] [blame] | 1331 | */ |
| 1332 | public abstract File getObbDir(); |
| 1333 | |
| 1334 | /** |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1335 | * Returns absolute paths to application-specific directories on all |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1336 | * shared/external storage devices where the application's OBB files (if |
| 1337 | * there are any) can be found. Note if the application does not have any |
| 1338 | * OBB files, these directories may not exist. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1339 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1340 | * This is like {@link #getFilesDir()} in that these files will be deleted |
| 1341 | * when the application is uninstalled, however there are some important |
| 1342 | * differences: |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1343 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1344 | * <li>Shared storage may not always be available, since removable media can |
| 1345 | * be ejected by the user. Media state can be checked using |
| 1346 | * {@link Environment#getExternalStorageState(File)}. |
| 1347 | * <li>There is no security enforced with these files. For example, any |
| 1348 | * application holding |
| 1349 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 1350 | * these files. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1351 | * </ul> |
| 1352 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1353 | * Shared storage devices returned here are considered a stable part of the |
| 1354 | * device, including physical media slots under a protective cover. The |
| 1355 | * returned paths do not include transient devices, such as USB flash drives |
| 1356 | * connected to handheld devices. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1357 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1358 | * 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] | 1359 | * example, an app may choose to store large files on the device with the |
| 1360 | * most available space, as measured by {@link StatFs}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1361 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1362 | * No additional permissions are required for the calling app to read or |
| 1363 | * write files under the returned path. Write access outside of these paths |
| 1364 | * on secondary external storage devices is not available. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1365 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1366 | * @return the absolute paths to application-specific directories. Some |
| 1367 | * individual paths may be {@code null} if that shared storage is |
| 1368 | * not currently available. The first path returned is the same as |
| 1369 | * {@link #getObbDir()} |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1370 | * @see #getObbDir() |
Jeff Sharkey | 4ca728c | 2014-01-10 16:27:19 -0800 | [diff] [blame] | 1371 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1372 | * @see Environment#isExternalStorageEmulated(File) |
| 1373 | * @see Environment#isExternalStorageRemovable(File) |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1374 | */ |
| 1375 | public abstract File[] getObbDirs(); |
| 1376 | |
| 1377 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1378 | * Returns the absolute path to the application specific cache directory on |
Jeff Sharkey | 60a82cd | 2017-04-18 18:19:16 -0600 | [diff] [blame] | 1379 | * the filesystem. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1380 | * <p> |
Jeff Sharkey | 60a82cd | 2017-04-18 18:19:16 -0600 | [diff] [blame] | 1381 | * The system will automatically delete files in this directory as disk |
| 1382 | * space is needed elsewhere on the device. The system will always delete |
| 1383 | * older files first, as reported by {@link File#lastModified()}. If |
| 1384 | * desired, you can exert more control over how files are deleted using |
| 1385 | * {@link StorageManager#setCacheBehaviorGroup(File, boolean)} and |
| 1386 | * {@link StorageManager#setCacheBehaviorTombstone(File, boolean)}. |
| 1387 | * <p> |
| 1388 | * Apps are strongly encouraged to keep their usage of cache space below the |
| 1389 | * quota returned by |
| 1390 | * {@link StorageManager#getCacheQuotaBytes(java.util.UUID)}. If your app |
| 1391 | * goes above this quota, your cached files will be some of the first to be |
| 1392 | * deleted when additional disk space is needed. Conversely, if your app |
| 1393 | * stays under this quota, your cached files will be some of the last to be |
| 1394 | * deleted when additional disk space is needed. |
| 1395 | * <p> |
| 1396 | * Note that your cache quota will change over time depending on how |
| 1397 | * frequently the user interacts with your app, and depending on how much |
| 1398 | * system-wide disk space is used. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1399 | * <p> |
| 1400 | * The returned path may change over time if the calling app is moved to an |
| 1401 | * adopted storage device, so only relative paths should be persisted. |
| 1402 | * <p> |
| 1403 | * Apps require no extra permissions to read or write to the returned path, |
| 1404 | * since this path lives in their private storage. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1405 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1406 | * @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] | 1407 | * @see #openFileOutput |
| 1408 | * @see #getFileStreamPath |
| 1409 | * @see #getDir |
Kevin Hufnagle | e9681e1 | 2016-09-23 16:44:03 -0700 | [diff] [blame] | 1410 | * @see #getExternalCacheDir |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1411 | */ |
| 1412 | public abstract File getCacheDir(); |
| 1413 | |
| 1414 | /** |
Jeff Sharkey | 4ed745d | 2014-07-15 20:39:15 -0700 | [diff] [blame] | 1415 | * Returns the absolute path to the application specific cache directory on |
Jeff Sharkey | 60a82cd | 2017-04-18 18:19:16 -0600 | [diff] [blame] | 1416 | * the filesystem designed for storing cached code. |
| 1417 | * <p> |
| 1418 | * The system will delete any files stored in this location both when your |
| 1419 | * specific application is upgraded, and when the entire platform is |
| 1420 | * upgraded. |
Jeff Sharkey | 4ed745d | 2014-07-15 20:39:15 -0700 | [diff] [blame] | 1421 | * <p> |
| 1422 | * This location is optimal for storing compiled or optimized code generated |
| 1423 | * by your application at runtime. |
| 1424 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1425 | * The returned path may change over time if the calling app is moved to an |
| 1426 | * adopted storage device, so only relative paths should be persisted. |
| 1427 | * <p> |
Jeff Sharkey | 4ed745d | 2014-07-15 20:39:15 -0700 | [diff] [blame] | 1428 | * Apps require no extra permissions to read or write to the returned path, |
| 1429 | * since this path lives in their private storage. |
| 1430 | * |
| 1431 | * @return The path of the directory holding application code cache files. |
| 1432 | */ |
| 1433 | public abstract File getCodeCacheDir(); |
| 1434 | |
| 1435 | /** |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1436 | * Returns absolute path to application-specific directory on the primary |
| 1437 | * shared/external storage device where the application can place cache |
| 1438 | * files it owns. These files are internal to the application, and not |
| 1439 | * typically visible to the user as media. |
| 1440 | * <p> |
| 1441 | * This is like {@link #getCacheDir()} in that these files will be deleted |
| 1442 | * when the application is uninstalled, however there are some important |
| 1443 | * differences: |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1444 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1445 | * <li>The platform does not always monitor the space available in shared |
| 1446 | * storage, and thus may not automatically delete these files. Apps should |
| 1447 | * always manage the maximum space used in this location. Currently the only |
| 1448 | * time files here will be deleted by the platform is when running on |
| 1449 | * {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} or later and |
| 1450 | * {@link Environment#isExternalStorageEmulated(File)} returns true. |
| 1451 | * <li>Shared storage may not always be available, since removable media can |
| 1452 | * be ejected by the user. Media state can be checked using |
| 1453 | * {@link Environment#getExternalStorageState(File)}. |
| 1454 | * <li>There is no security enforced with these files. For example, any |
| 1455 | * application holding |
| 1456 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1457 | * these files. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1458 | * </ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1459 | * <p> |
| 1460 | * If a shared storage device is emulated (as determined by |
Kevin Hufnagle | e9681e1 | 2016-09-23 16:44:03 -0700 | [diff] [blame] | 1461 | * {@link Environment#isExternalStorageEmulated(File)}), its contents are |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1462 | * backed by a private user data partition, which means there is little |
| 1463 | * benefit to storing data here instead of the private directory returned by |
| 1464 | * {@link #getCacheDir()}. |
| 1465 | * <p> |
| 1466 | * Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1467 | * 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] | 1468 | * accessible to the calling app. This only applies to paths generated for |
| 1469 | * package name of the calling application. To access paths belonging to |
| 1470 | * other packages, |
| 1471 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} and/or |
| 1472 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} are required. |
| 1473 | * <p> |
| 1474 | * On devices with multiple users (as described by {@link UserManager}), |
| 1475 | * each user has their own isolated shared storage. Applications only have |
| 1476 | * access to the shared storage for the user they're running as. |
| 1477 | * <p> |
| 1478 | * The returned path may change over time if different shared storage media |
| 1479 | * is inserted, so only relative paths should be persisted. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1480 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1481 | * @return the absolute path to application-specific directory. May return |
| 1482 | * {@code null} if shared storage is not currently available. |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1483 | * @see #getCacheDir |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1484 | * @see #getExternalCacheDirs() |
| 1485 | * @see Environment#getExternalStorageState(File) |
| 1486 | * @see Environment#isExternalStorageEmulated(File) |
| 1487 | * @see Environment#isExternalStorageRemovable(File) |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1488 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1489 | @Nullable |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1490 | public abstract File getExternalCacheDir(); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 1491 | |
Dianne Hackborn | e83cefce | 2010-02-04 17:38:14 -0800 | [diff] [blame] | 1492 | /** |
Fyodor Kupolov | 6122129 | 2016-09-02 15:21:03 -0700 | [diff] [blame] | 1493 | * Returns absolute path to application-specific directory in the preloaded cache. |
| 1494 | * <p>Files stored in the cache directory can be deleted when the device runs low on storage. |
| 1495 | * There is no guarantee when these files will be deleted. |
| 1496 | * @hide |
| 1497 | */ |
| 1498 | @Nullable |
| 1499 | @SystemApi |
| 1500 | public abstract File getPreloadsFileCache(); |
| 1501 | |
| 1502 | /** |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1503 | * Returns absolute paths to application-specific directories on all |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1504 | * shared/external storage devices where the application can place cache |
| 1505 | * files it owns. These files are internal to the application, and not |
| 1506 | * typically visible to the user as media. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1507 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1508 | * This is like {@link #getCacheDir()} in that these files will be deleted |
| 1509 | * when the application is uninstalled, however there are some important |
| 1510 | * differences: |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1511 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1512 | * <li>The platform does not always monitor the space available in shared |
| 1513 | * storage, and thus may not automatically delete these files. Apps should |
| 1514 | * always manage the maximum space used in this location. Currently the only |
| 1515 | * time files here will be deleted by the platform is when running on |
| 1516 | * {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} or later and |
| 1517 | * {@link Environment#isExternalStorageEmulated(File)} returns true. |
| 1518 | * <li>Shared storage may not always be available, since removable media can |
| 1519 | * be ejected by the user. Media state can be checked using |
| 1520 | * {@link Environment#getExternalStorageState(File)}. |
| 1521 | * <li>There is no security enforced with these files. For example, any |
| 1522 | * application holding |
| 1523 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 1524 | * these files. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1525 | * </ul> |
| 1526 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1527 | * If a shared storage device is emulated (as determined by |
| 1528 | * {@link Environment#isExternalStorageEmulated(File)}), it's contents are |
| 1529 | * backed by a private user data partition, which means there is little |
| 1530 | * benefit to storing data here instead of the private directory returned by |
| 1531 | * {@link #getCacheDir()}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1532 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1533 | * Shared storage devices returned here are considered a stable part of the |
| 1534 | * device, including physical media slots under a protective cover. The |
| 1535 | * returned paths do not include transient devices, such as USB flash drives |
| 1536 | * connected to handheld devices. |
| 1537 | * <p> |
| 1538 | * 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] | 1539 | * example, an app may choose to store large files on the device with the |
| 1540 | * most available space, as measured by {@link StatFs}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1541 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1542 | * No additional permissions are required for the calling app to read or |
| 1543 | * write files under the returned path. Write access outside of these paths |
| 1544 | * on secondary external storage devices is not available. |
Jeff Sharkey | 6feb50b | 2013-10-15 12:38:15 -0700 | [diff] [blame] | 1545 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1546 | * The returned paths may change over time if different shared storage media |
| 1547 | * is inserted, so only relative paths should be persisted. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1548 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1549 | * @return the absolute paths to application-specific directories. Some |
| 1550 | * individual paths may be {@code null} if that shared storage is |
| 1551 | * not currently available. The first path returned is the same as |
| 1552 | * {@link #getExternalCacheDir()}. |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1553 | * @see #getExternalCacheDir() |
Jeff Sharkey | 4ca728c | 2014-01-10 16:27:19 -0800 | [diff] [blame] | 1554 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1555 | * @see Environment#isExternalStorageEmulated(File) |
| 1556 | * @see Environment#isExternalStorageRemovable(File) |
Jeff Sharkey | 1abdb71 | 2013-08-11 16:28:14 -0700 | [diff] [blame] | 1557 | */ |
| 1558 | public abstract File[] getExternalCacheDirs(); |
| 1559 | |
| 1560 | /** |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1561 | * Returns absolute paths to application-specific directories on all |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1562 | * shared/external storage devices where the application can place media |
| 1563 | * files. These files are scanned and made available to other apps through |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1564 | * {@link MediaStore}. |
| 1565 | * <p> |
| 1566 | * This is like {@link #getExternalFilesDirs} in that these files will be |
| 1567 | * deleted when the application is uninstalled, however there are some |
| 1568 | * important differences: |
| 1569 | * <ul> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1570 | * <li>Shared storage may not always be available, since removable media can |
| 1571 | * be ejected by the user. Media state can be checked using |
| 1572 | * {@link Environment#getExternalStorageState(File)}. |
| 1573 | * <li>There is no security enforced with these files. For example, any |
| 1574 | * application holding |
| 1575 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} can write to |
| 1576 | * these files. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1577 | * </ul> |
| 1578 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1579 | * Shared storage devices returned here are considered a stable part of the |
| 1580 | * device, including physical media slots under a protective cover. The |
| 1581 | * returned paths do not include transient devices, such as USB flash drives |
| 1582 | * connected to handheld devices. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1583 | * <p> |
| 1584 | * An application may store data on any or all of the returned devices. For |
| 1585 | * example, an app may choose to store large files on the device with the |
| 1586 | * most available space, as measured by {@link StatFs}. |
| 1587 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1588 | * No additional permissions are required for the calling app to read or |
| 1589 | * write files under the returned path. Write access outside of these paths |
| 1590 | * on secondary external storage devices is not available. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1591 | * <p> |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1592 | * The returned paths may change over time if different shared storage media |
| 1593 | * is inserted, so only relative paths should be persisted. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1594 | * |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1595 | * @return the absolute paths to application-specific directories. Some |
| 1596 | * individual paths may be {@code null} if that shared storage is |
| 1597 | * not currently available. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1598 | * @see Environment#getExternalStorageState(File) |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1599 | * @see Environment#isExternalStorageEmulated(File) |
| 1600 | * @see Environment#isExternalStorageRemovable(File) |
Jeff Sharkey | 588c15e | 2019-10-10 17:29:58 -0600 | [diff] [blame] | 1601 | * @deprecated These directories still exist and are scanned, but developers |
| 1602 | * are encouraged to migrate to inserting content into a |
| 1603 | * {@link MediaStore} collection directly, as any app can |
| 1604 | * contribute new media to {@link MediaStore} with no |
| 1605 | * permissions required, starting in |
| 1606 | * {@link android.os.Build.VERSION_CODES#Q}. |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1607 | */ |
Jeff Sharkey | 588c15e | 2019-10-10 17:29:58 -0600 | [diff] [blame] | 1608 | @Deprecated |
Jeff Sharkey | 2ee3c1e | 2014-05-30 15:38:35 -0700 | [diff] [blame] | 1609 | public abstract File[] getExternalMediaDirs(); |
| 1610 | |
| 1611 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1612 | * Returns an array of strings naming the private files associated with |
| 1613 | * this Context's application package. |
| 1614 | * |
| 1615 | * @return Array of strings naming the private files. |
| 1616 | * |
| 1617 | * @see #openFileInput |
| 1618 | * @see #openFileOutput |
| 1619 | * @see #deleteFile |
| 1620 | */ |
| 1621 | public abstract String[] fileList(); |
| 1622 | |
| 1623 | /** |
| 1624 | * Retrieve, creating if needed, a new directory in which the application |
| 1625 | * can place its own custom data files. You can use the returned File |
| 1626 | * object to create and access files in this directory. Note that files |
| 1627 | * created through a File object will only be accessible by your own |
| 1628 | * application; you can only set the mode of the entire directory, not |
| 1629 | * of individual files. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1630 | * <p> |
| 1631 | * The returned path may change over time if the calling app is moved to an |
| 1632 | * adopted storage device, so only relative paths should be persisted. |
| 1633 | * <p> |
| 1634 | * Apps require no extra permissions to read or write to the returned path, |
| 1635 | * since this path lives in their private storage. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1636 | * |
Nick Kralevich | 92091fa | 2012-12-12 16:24:31 -0800 | [diff] [blame] | 1637 | * @param name Name of the directory to retrieve. This is a directory |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1638 | * that is created as part of your application data. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1639 | * @param mode Operating mode. |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1640 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1641 | * @return A {@link File} object for the requested directory. The directory |
Nick Kralevich | 1506921 | 2013-01-09 15:54:56 -0800 | [diff] [blame] | 1642 | * 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] | 1643 | * |
| 1644 | * @see #openFileOutput(String, int) |
| 1645 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1646 | public abstract File getDir(String name, @FileMode int mode); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1647 | |
| 1648 | /** |
| 1649 | * Open a new private SQLiteDatabase associated with this Context's |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1650 | * 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] | 1651 | * |
| 1652 | * @param name The name (unique in the application package) of the database. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1653 | * @param mode Operating mode. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1654 | * @param factory An optional factory class that is called to instantiate a |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1655 | * cursor when query is called. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1656 | * @return The contents of a newly created database with the given name. |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1657 | * @throws android.database.sqlite.SQLiteException if the database file |
| 1658 | * could not be opened. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1659 | * @see #MODE_PRIVATE |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 1660 | * @see #MODE_ENABLE_WRITE_AHEAD_LOGGING |
Sunny Goyal | a21e6b2 | 2015-12-02 09:51:02 -0800 | [diff] [blame] | 1661 | * @see #MODE_NO_LOCALIZED_COLLATORS |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1662 | * @see #deleteDatabase |
| 1663 | */ |
| 1664 | public abstract SQLiteDatabase openOrCreateDatabase(String name, |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1665 | @DatabaseMode int mode, CursorFactory factory); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1666 | |
| 1667 | /** |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1668 | * Open a new private SQLiteDatabase associated with this Context's |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1669 | * application package. Creates the database file if it doesn't exist. |
| 1670 | * <p> |
| 1671 | * Accepts input param: a concrete instance of {@link DatabaseErrorHandler} |
| 1672 | * to be used to handle corruption when sqlite reports database corruption. |
| 1673 | * </p> |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1674 | * |
| 1675 | * @param name The name (unique in the application package) of the database. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1676 | * @param mode Operating mode. |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1677 | * @param factory An optional factory class that is called to instantiate a |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1678 | * cursor when query is called. |
| 1679 | * @param errorHandler the {@link DatabaseErrorHandler} to be used when |
| 1680 | * sqlite reports database corruption. if null, |
| 1681 | * {@link android.database.DefaultDatabaseErrorHandler} is |
| 1682 | * assumed. |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1683 | * @return The contents of a newly created database with the given name. |
Jeff Sharkey | 634dc42 | 2016-01-30 17:44:15 -0700 | [diff] [blame] | 1684 | * @throws android.database.sqlite.SQLiteException if the database file |
| 1685 | * could not be opened. |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1686 | * @see #MODE_PRIVATE |
Jeff Brown | 47847f3 | 2012-03-22 19:13:11 -0700 | [diff] [blame] | 1687 | * @see #MODE_ENABLE_WRITE_AHEAD_LOGGING |
Sunny Goyal | a21e6b2 | 2015-12-02 09:51:02 -0800 | [diff] [blame] | 1688 | * @see #MODE_NO_LOCALIZED_COLLATORS |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1689 | * @see #deleteDatabase |
| 1690 | */ |
| 1691 | public abstract SQLiteDatabase openOrCreateDatabase(String name, |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 1692 | @DatabaseMode int mode, CursorFactory factory, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1693 | @Nullable DatabaseErrorHandler errorHandler); |
Vasu Nori | 74f170f | 2010-06-01 18:06:18 -0700 | [diff] [blame] | 1694 | |
| 1695 | /** |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 1696 | * Move an existing database file from the given source storage context to |
| 1697 | * this context. This is typically used to migrate data between storage |
| 1698 | * locations after an upgrade, such as migrating to device protected |
| 1699 | * storage. |
Jeff Sharkey | d21cad1 | 2016-05-20 11:30:07 -0600 | [diff] [blame] | 1700 | * <p> |
| 1701 | * The database must be closed before being moved. |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 1702 | * |
| 1703 | * @param sourceContext The source context which contains the existing |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 1704 | * database to move. |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 1705 | * @param name The name of the database file. |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 1706 | * @return {@code true} if the move was successful or if the database didn't |
| 1707 | * exist in the source context, otherwise {@code false}. |
| 1708 | * @see #createDeviceProtectedStorageContext() |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 1709 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 1710 | public abstract boolean moveDatabaseFrom(Context sourceContext, String name); |
| 1711 | |
Jeff Sharkey | 35871f2 | 2016-01-29 17:13:29 -0700 | [diff] [blame] | 1712 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1713 | * Delete an existing private SQLiteDatabase associated with this Context's |
| 1714 | * application package. |
| 1715 | * |
| 1716 | * @param name The name (unique in the application package) of the |
| 1717 | * database. |
| 1718 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1719 | * @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] | 1720 | * |
| 1721 | * @see #openOrCreateDatabase |
| 1722 | */ |
| 1723 | public abstract boolean deleteDatabase(String name); |
| 1724 | |
| 1725 | /** |
| 1726 | * Returns the absolute path on the filesystem where a database created with |
| 1727 | * {@link #openOrCreateDatabase} is stored. |
Jeff Sharkey | 59d28dc8 | 2015-10-14 13:56:23 -0700 | [diff] [blame] | 1728 | * <p> |
| 1729 | * The returned path may change over time if the calling app is moved to an |
| 1730 | * 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] | 1731 | * |
| 1732 | * @param name The name of the database for which you would like to get |
| 1733 | * its path. |
| 1734 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1735 | * @return An absolute path to the given database. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1736 | * |
| 1737 | * @see #openOrCreateDatabase |
| 1738 | */ |
| 1739 | public abstract File getDatabasePath(String name); |
| 1740 | |
| 1741 | /** |
| 1742 | * Returns an array of strings naming the private databases associated with |
| 1743 | * this Context's application package. |
| 1744 | * |
| 1745 | * @return Array of strings naming the private databases. |
| 1746 | * |
| 1747 | * @see #openOrCreateDatabase |
| 1748 | * @see #deleteDatabase |
| 1749 | */ |
| 1750 | public abstract String[] databaseList(); |
| 1751 | |
| 1752 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1753 | * @deprecated Use {@link android.app.WallpaperManager#getDrawable |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1754 | * WallpaperManager.get()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1755 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1756 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1757 | public abstract Drawable getWallpaper(); |
| 1758 | |
| 1759 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1760 | * @deprecated Use {@link android.app.WallpaperManager#peekDrawable |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1761 | * WallpaperManager.peek()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1762 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1763 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1764 | public abstract Drawable peekWallpaper(); |
| 1765 | |
| 1766 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1767 | * @deprecated Use {@link android.app.WallpaperManager#getDesiredMinimumWidth() |
| 1768 | * WallpaperManager.getDesiredMinimumWidth()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1769 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1770 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1771 | public abstract int getWallpaperDesiredMinimumWidth(); |
| 1772 | |
| 1773 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1774 | * @deprecated Use {@link android.app.WallpaperManager#getDesiredMinimumHeight() |
| 1775 | * WallpaperManager.getDesiredMinimumHeight()} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1776 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1777 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1778 | public abstract int getWallpaperDesiredMinimumHeight(); |
| 1779 | |
| 1780 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1781 | * @deprecated Use {@link android.app.WallpaperManager#setBitmap(Bitmap) |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1782 | * WallpaperManager.set()} instead. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 1783 | * <p>This method requires the caller to hold the permission |
| 1784 | * {@link android.Manifest.permission#SET_WALLPAPER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1785 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1786 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1787 | public abstract void setWallpaper(Bitmap bitmap) throws IOException; |
| 1788 | |
| 1789 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 1790 | * @deprecated Use {@link android.app.WallpaperManager#setStream(InputStream) |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1791 | * WallpaperManager.set()} instead. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 1792 | * <p>This method requires the caller to hold the permission |
| 1793 | * {@link android.Manifest.permission#SET_WALLPAPER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1794 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1795 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1796 | public abstract void setWallpaper(InputStream data) throws IOException; |
| 1797 | |
| 1798 | /** |
Dianne Hackborn | 8cc6a50 | 2009-08-05 21:29:42 -0700 | [diff] [blame] | 1799 | * @deprecated Use {@link android.app.WallpaperManager#clear |
| 1800 | * WallpaperManager.clear()} instead. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 1801 | * <p>This method requires the caller to hold the permission |
| 1802 | * {@link android.Manifest.permission#SET_WALLPAPER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1803 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 1804 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1805 | public abstract void clearWallpaper() throws IOException; |
| 1806 | |
| 1807 | /** |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1808 | * Same as {@link #startActivity(Intent, Bundle)} with no options |
| 1809 | * specified. |
| 1810 | * |
| 1811 | * @param intent The description of the activity to start. |
| 1812 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1813 | * @throws ActivityNotFoundException |
Svet Ganov | 1ed0e55 | 2015-06-11 01:15:43 -0700 | [diff] [blame] | 1814 | *` |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1815 | * @see #startActivity(Intent, Bundle) |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1816 | * @see PackageManager#resolveActivity |
| 1817 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1818 | public abstract void startActivity(@RequiresPermission Intent intent); |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1819 | |
| 1820 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1821 | * Version of {@link #startActivity(Intent)} that allows you to specify the |
| 1822 | * 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] | 1823 | * that are not pre-installed on the system image. |
Amith Yamasani | 8264408 | 2012-08-03 13:09:11 -0700 | [diff] [blame] | 1824 | * @param intent The description of the activity to start. |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 1825 | * @param user The UserHandle of the user to start this activity for. |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1826 | * @throws ActivityNotFoundException |
Amith Yamasani | 8264408 | 2012-08-03 13:09:11 -0700 | [diff] [blame] | 1827 | * @hide |
| 1828 | */ |
Jonathan Scott | 9233534 | 2019-12-17 14:46:26 +0000 | [diff] [blame] | 1829 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Philip P. Moltmann | 4e615e6 | 2018-08-28 14:57:49 -0700 | [diff] [blame] | 1830 | @SystemApi |
Nate Myren | 3f26271 | 2019-05-31 09:36:08 -0700 | [diff] [blame] | 1831 | @TestApi |
Adrian Roos | ebc927c | 2019-02-28 16:21:18 +0100 | [diff] [blame] | 1832 | public void startActivityAsUser(@RequiresPermission @NonNull Intent intent, |
| 1833 | @NonNull UserHandle user) { |
Amith Yamasani | 8264408 | 2012-08-03 13:09:11 -0700 | [diff] [blame] | 1834 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 1835 | } |
| 1836 | |
| 1837 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1838 | * Launch a new activity. You will not receive any information about when |
| 1839 | * the activity exits. |
| 1840 | * |
| 1841 | * <p>Note that if this method is being called from outside of an |
| 1842 | * {@link android.app.Activity} Context, then the Intent must include |
| 1843 | * the {@link Intent#FLAG_ACTIVITY_NEW_TASK} launch flag. This is because, |
| 1844 | * without being started from an existing Activity, there is no existing |
| 1845 | * task in which to place the new activity and thus it needs to be placed |
| 1846 | * in its own separate task. |
| 1847 | * |
| 1848 | * <p>This method throws {@link ActivityNotFoundException} |
| 1849 | * if there was no Activity found to run the given Intent. |
| 1850 | * |
| 1851 | * @param intent The description of the activity to start. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1852 | * @param options Additional options for how the Activity should be started. |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 1853 | * May be null if there are no options. See {@link android.app.ActivityOptions} |
| 1854 | * for how to build the Bundle supplied here; there are no supported definitions |
| 1855 | * for building it manually. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1856 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1857 | * @throws ActivityNotFoundException |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1858 | * |
Scott Main | 60dd520 | 2012-06-23 00:01:22 -0700 | [diff] [blame] | 1859 | * @see #startActivity(Intent) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1860 | * @see PackageManager#resolveActivity |
| 1861 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1862 | public abstract void startActivity(@RequiresPermission Intent intent, |
| 1863 | @Nullable Bundle options); |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1864 | |
| 1865 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 1866 | * Version of {@link #startActivity(Intent, Bundle)} that allows you to specify the |
| 1867 | * 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] | 1868 | * that are not pre-installed on the system image. |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 1869 | * @param intent The description of the activity to start. |
| 1870 | * @param options Additional options for how the Activity should be started. |
| 1871 | * May be null if there are no options. See {@link android.app.ActivityOptions} |
| 1872 | * for how to build the Bundle supplied here; there are no supported definitions |
| 1873 | * for building it manually. |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 1874 | * @param userId The UserHandle of the user to start this activity for. |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1875 | * @throws ActivityNotFoundException |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 1876 | * @hide |
| 1877 | */ |
Jonathan Scott | 9233534 | 2019-12-17 14:46:26 +0000 | [diff] [blame] | 1878 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 1879 | @UnsupportedAppUsage |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1880 | public void startActivityAsUser(@RequiresPermission Intent intent, @Nullable Bundle options, |
| 1881 | UserHandle userId) { |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 1882 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 1883 | } |
| 1884 | |
| 1885 | /** |
Clara Bayarri | d5bf3ed | 2015-03-27 17:32:45 +0000 | [diff] [blame] | 1886 | * Version of {@link #startActivity(Intent, Bundle)} that returns a result to the caller. This |
| 1887 | * is only supported for Views and Fragments. |
| 1888 | * @param who The identifier for the calling element that will receive the result. |
| 1889 | * @param intent The intent to start. |
| 1890 | * @param requestCode The code that will be returned with onActivityResult() identifying this |
| 1891 | * request. |
| 1892 | * @param options Additional options for how the Activity should be started. |
| 1893 | * May be null if there are no options. See {@link android.app.ActivityOptions} |
| 1894 | * for how to build the Bundle supplied here; there are no supported definitions |
| 1895 | * for building it manually. |
| 1896 | * @hide |
| 1897 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 1898 | @UnsupportedAppUsage |
Clara Bayarri | d5bf3ed | 2015-03-27 17:32:45 +0000 | [diff] [blame] | 1899 | public void startActivityForResult( |
| 1900 | @NonNull String who, Intent intent, int requestCode, @Nullable Bundle options) { |
| 1901 | throw new RuntimeException("This method is only implemented for Activity-based Contexts. " |
| 1902 | + "Check canStartActivityForResult() before calling."); |
| 1903 | } |
| 1904 | |
| 1905 | /** |
| 1906 | * Identifies whether this Context instance will be able to process calls to |
| 1907 | * {@link #startActivityForResult(String, Intent, int, Bundle)}. |
| 1908 | * @hide |
| 1909 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 1910 | @UnsupportedAppUsage |
Clara Bayarri | d5bf3ed | 2015-03-27 17:32:45 +0000 | [diff] [blame] | 1911 | public boolean canStartActivityForResult() { |
| 1912 | return false; |
| 1913 | } |
| 1914 | |
| 1915 | /** |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1916 | * Same as {@link #startActivities(Intent[], Bundle)} with no options |
| 1917 | * specified. |
| 1918 | * |
| 1919 | * @param intents An array of Intents to be started. |
| 1920 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1921 | * @throws ActivityNotFoundException |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1922 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1923 | * @see #startActivities(Intent[], Bundle) |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1924 | * @see PackageManager#resolveActivity |
| 1925 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1926 | public abstract void startActivities(@RequiresPermission Intent[] intents); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1927 | |
| 1928 | /** |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 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. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1943 | * @param options Additional options for how the Activity should be started. |
Elliot Waite | 54de774 | 2017-01-11 15:30:35 -0800 | [diff] [blame] | 1944 | * See {@link android.content.Context#startActivity(Intent, Bundle)} |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 1945 | * Context.startActivity(Intent, Bundle)} for more details. |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1946 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1947 | * @throws ActivityNotFoundException |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1948 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1949 | * @see #startActivities(Intent[]) |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1950 | * @see PackageManager#resolveActivity |
| 1951 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 1952 | public abstract void startActivities(@RequiresPermission Intent[] intents, Bundle options); |
Dianne Hackborn | 621e17d | 2010-11-22 15:59:56 -0800 | [diff] [blame] | 1953 | |
| 1954 | /** |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1955 | * @hide |
| 1956 | * Launch multiple new activities. This is generally the same as calling |
| 1957 | * {@link #startActivity(Intent)} for the first Intent in the array, |
| 1958 | * that activity during its creation calling {@link #startActivity(Intent)} |
| 1959 | * for the second entry, etc. Note that unlike that approach, generally |
| 1960 | * none of the activities except the last in the array will be created |
| 1961 | * at this point, but rather will be created when the user first visits |
| 1962 | * them (due to pressing back from the activity on top). |
| 1963 | * |
| 1964 | * <p>This method throws {@link ActivityNotFoundException} |
| 1965 | * if there was no Activity found for <em>any</em> given Intent. In this |
| 1966 | * case the state of the activity stack is undefined (some Intents in the |
| 1967 | * list may be on it, some not), so you probably want to avoid such situations. |
| 1968 | * |
| 1969 | * @param intents An array of Intents to be started. |
| 1970 | * @param options Additional options for how the Activity should be started. |
| 1971 | * @param userHandle The user for whom to launch the activities |
Elliot Waite | 54de774 | 2017-01-11 15:30:35 -0800 | [diff] [blame] | 1972 | * See {@link android.content.Context#startActivity(Intent, Bundle)} |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1973 | * Context.startActivity(Intent, Bundle)} for more details. |
| 1974 | * |
Selim Cinek | 7fa385a | 2018-01-24 08:35:28 -0800 | [diff] [blame] | 1975 | * @return The corresponding flag {@link ActivityManager#START_CANCELED}, |
| 1976 | * {@link ActivityManager#START_SUCCESS} etc. indicating whether the launch was |
| 1977 | * successful. |
| 1978 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1979 | * @throws ActivityNotFoundException |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1980 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 1981 | * @see #startActivities(Intent[]) |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1982 | * @see PackageManager#resolveActivity |
| 1983 | */ |
Jonathan Scott | 9233534 | 2019-12-17 14:46:26 +0000 | [diff] [blame] | 1984 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Selim Cinek | 7fa385a | 2018-01-24 08:35:28 -0800 | [diff] [blame] | 1985 | public int startActivitiesAsUser(Intent[] intents, Bundle options, UserHandle userHandle) { |
Amith Yamasani | ea7e915 | 2012-09-24 16:11:18 -0700 | [diff] [blame] | 1986 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 1987 | } |
| 1988 | |
| 1989 | /** |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 1990 | * Same as {@link #startIntentSender(IntentSender, Intent, int, int, int, Bundle)} |
| 1991 | * with no options specified. |
| 1992 | * |
| 1993 | * @param intent The IntentSender to launch. |
| 1994 | * @param fillInIntent If non-null, this will be provided as the |
| 1995 | * intent parameter to {@link IntentSender#sendIntent}. |
| 1996 | * @param flagsMask Intent flags in the original IntentSender that you |
| 1997 | * would like to change. |
| 1998 | * @param flagsValues Desired values for any bits set in |
| 1999 | * <var>flagsMask</var> |
| 2000 | * @param extraFlags Always set to 0. |
| 2001 | * |
| 2002 | * @see #startActivity(Intent) |
| 2003 | * @see #startIntentSender(IntentSender, Intent, int, int, int, Bundle) |
| 2004 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 2005 | public abstract void startIntentSender(IntentSender intent, @Nullable Intent fillInIntent, |
| 2006 | @Intent.MutableFlags int flagsMask, @Intent.MutableFlags int flagsValues, |
| 2007 | int extraFlags) throws IntentSender.SendIntentException; |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 2008 | |
| 2009 | /** |
| 2010 | * Like {@link #startActivity(Intent, Bundle)}, but taking a IntentSender |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 2011 | * 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] | 2012 | * as if you had called the regular {@link #startActivity(Intent)} |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 2013 | * here; otherwise, its associated action will be executed (such as |
| 2014 | * sending a broadcast) as if you had called |
| 2015 | * {@link IntentSender#sendIntent IntentSender.sendIntent} on it. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2016 | * |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 2017 | * @param intent The IntentSender to launch. |
| 2018 | * @param fillInIntent If non-null, this will be provided as the |
| 2019 | * intent parameter to {@link IntentSender#sendIntent}. |
| 2020 | * @param flagsMask Intent flags in the original IntentSender that you |
| 2021 | * would like to change. |
| 2022 | * @param flagsValues Desired values for any bits set in |
| 2023 | * <var>flagsMask</var> |
| 2024 | * @param extraFlags Always set to 0. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 2025 | * @param options Additional options for how the Activity should be started. |
Elliot Waite | 54de774 | 2017-01-11 15:30:35 -0800 | [diff] [blame] | 2026 | * See {@link android.content.Context#startActivity(Intent, Bundle)} |
Dianne Hackborn | 7a2195c | 2012-03-19 17:38:00 -0700 | [diff] [blame] | 2027 | * Context.startActivity(Intent, Bundle)} for more details. If options |
| 2028 | * have also been supplied by the IntentSender, options given here will |
| 2029 | * override any that conflict with those given by the IntentSender. |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 2030 | * |
| 2031 | * @see #startActivity(Intent, Bundle) |
| 2032 | * @see #startIntentSender(IntentSender, Intent, int, int, int) |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 2033 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 2034 | public abstract void startIntentSender(IntentSender intent, @Nullable Intent fillInIntent, |
| 2035 | @Intent.MutableFlags int flagsMask, @Intent.MutableFlags int flagsValues, |
| 2036 | int extraFlags, @Nullable Bundle options) throws IntentSender.SendIntentException; |
Dianne Hackborn | fa82f22 | 2009-09-17 15:14:12 -0700 | [diff] [blame] | 2037 | |
| 2038 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2039 | * Broadcast the given intent to all interested BroadcastReceivers. This |
| 2040 | * call is asynchronous; it returns immediately, and you will continue |
| 2041 | * executing while the receivers are run. No results are propagated from |
| 2042 | * receivers and receivers can not abort the broadcast. If you want |
| 2043 | * to allow receivers to propagate results or abort the broadcast, you must |
| 2044 | * send an ordered broadcast using |
| 2045 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2046 | * |
| 2047 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2048 | * |
| 2049 | * @param intent The Intent to broadcast; all receivers matching this |
| 2050 | * Intent will receive the broadcast. |
| 2051 | * |
| 2052 | * @see android.content.BroadcastReceiver |
| 2053 | * @see #registerReceiver |
| 2054 | * @see #sendBroadcast(Intent, String) |
| 2055 | * @see #sendOrderedBroadcast(Intent, String) |
| 2056 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2057 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2058 | public abstract void sendBroadcast(@RequiresPermission Intent intent); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2059 | |
| 2060 | /** |
| 2061 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
| 2062 | * an optional required permission to be enforced. This |
| 2063 | * call is asynchronous; it returns immediately, and you will continue |
| 2064 | * executing while the receivers are run. No results are propagated from |
| 2065 | * receivers and receivers can not abort the broadcast. If you want |
| 2066 | * to allow receivers to propagate results or abort the broadcast, you must |
| 2067 | * send an ordered broadcast using |
| 2068 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2069 | * |
| 2070 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2071 | * |
| 2072 | * @param intent The Intent to broadcast; all receivers matching this |
| 2073 | * Intent will receive the broadcast. |
Brad Fitzpatrick | 26b71be | 2010-12-07 14:52:58 -0800 | [diff] [blame] | 2074 | * @param receiverPermission (optional) String naming a permission that |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2075 | * a receiver must hold in order to receive your broadcast. |
| 2076 | * If null, no permission is required. |
| 2077 | * |
| 2078 | * @see android.content.BroadcastReceiver |
| 2079 | * @see #registerReceiver |
| 2080 | * @see #sendBroadcast(Intent) |
| 2081 | * @see #sendOrderedBroadcast(Intent, String) |
| 2082 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2083 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2084 | public abstract void sendBroadcast(@RequiresPermission Intent intent, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2085 | @Nullable String receiverPermission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2086 | |
Fyodor Kupolov | d4fd8c7 | 2015-07-13 19:19:25 -0700 | [diff] [blame] | 2087 | |
| 2088 | /** |
| 2089 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
| 2090 | * an array of required permissions to be enforced. This call is asynchronous; it returns |
| 2091 | * immediately, and you will continue executing while the receivers are run. No results are |
| 2092 | * propagated from receivers and receivers can not abort the broadcast. If you want to allow |
| 2093 | * receivers to propagate results or abort the broadcast, you must send an ordered broadcast |
| 2094 | * using {@link #sendOrderedBroadcast(Intent, String)}. |
| 2095 | * |
| 2096 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2097 | * |
| 2098 | * @param intent The Intent to broadcast; all receivers matching this |
| 2099 | * Intent will receive the broadcast. |
| 2100 | * @param receiverPermissions Array of names of permissions that a receiver must hold |
| 2101 | * in order to receive your broadcast. |
Roshan Pius | 3fe42f0 | 2019-11-12 09:56:48 -0800 | [diff] [blame] | 2102 | * If empty, no permissions are required. |
Fyodor Kupolov | d4fd8c7 | 2015-07-13 19:19:25 -0700 | [diff] [blame] | 2103 | * |
| 2104 | * @see android.content.BroadcastReceiver |
| 2105 | * @see #registerReceiver |
| 2106 | * @see #sendBroadcast(Intent) |
| 2107 | * @see #sendOrderedBroadcast(Intent, String) |
| 2108 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2109 | * @hide |
| 2110 | */ |
Roshan Pius | 3fe42f0 | 2019-11-12 09:56:48 -0800 | [diff] [blame] | 2111 | public void sendBroadcastMultiplePermissions(@NonNull Intent intent, |
| 2112 | @NonNull String[] receiverPermissions) { |
| 2113 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 2114 | } |
Fyodor Kupolov | d4fd8c7 | 2015-07-13 19:19:25 -0700 | [diff] [blame] | 2115 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2116 | /** |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 2117 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
Tyler Gunn | f955e56 | 2018-04-26 14:43:31 -0700 | [diff] [blame] | 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. |
Roshan Pius | a2baf58e | 2019-11-20 14:40:30 -0800 | [diff] [blame] | 2128 | * @param receiverPermissions Array of names of permissions that a receiver must hold |
| 2129 | * in order to receive your broadcast. |
| 2130 | * If empty, no permissions are required. |
| 2131 | * |
| 2132 | * @see android.content.BroadcastReceiver |
| 2133 | * @see #registerReceiver |
| 2134 | * @see #sendBroadcast(Intent) |
| 2135 | * @see #sendOrderedBroadcast(Intent, String) |
| 2136 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2137 | */ |
| 2138 | public void sendBroadcastWithMultiplePermissions(@NonNull Intent intent, |
| 2139 | @NonNull String[] receiverPermissions) { |
| 2140 | sendBroadcastMultiplePermissions(intent, receiverPermissions); |
| 2141 | } |
| 2142 | |
| 2143 | /** |
| 2144 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
| 2145 | * an array of required permissions to be enforced. This call is asynchronous; it returns |
| 2146 | * immediately, and you will continue executing while the receivers are run. No results are |
| 2147 | * propagated from receivers and receivers can not abort the broadcast. If you want to allow |
| 2148 | * receivers to propagate results or abort the broadcast, you must send an ordered broadcast |
| 2149 | * using {@link #sendOrderedBroadcast(Intent, String)}. |
| 2150 | * |
| 2151 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2152 | * |
| 2153 | * @param intent The Intent to broadcast; all receivers matching this |
| 2154 | * Intent will receive the broadcast. |
Tyler Gunn | f955e56 | 2018-04-26 14:43:31 -0700 | [diff] [blame] | 2155 | * @param user The user to send the broadcast to. |
| 2156 | * @param receiverPermissions Array of names of permissions that a receiver must hold |
| 2157 | * in order to receive your broadcast. |
| 2158 | * If null or empty, no permissions are required. |
| 2159 | * |
| 2160 | * @see android.content.BroadcastReceiver |
| 2161 | * @see #registerReceiver |
| 2162 | * @see #sendBroadcast(Intent) |
| 2163 | * @see #sendOrderedBroadcast(Intent, String) |
| 2164 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2165 | * @hide |
| 2166 | */ |
| 2167 | public abstract void sendBroadcastAsUserMultiplePermissions(Intent intent, UserHandle user, |
| 2168 | String[] receiverPermissions); |
| 2169 | |
| 2170 | /** |
| 2171 | * Broadcast the given intent to all interested BroadcastReceivers, allowing |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 2172 | * an optional required permission to be enforced. This |
| 2173 | * call is asynchronous; it returns immediately, and you will continue |
| 2174 | * executing while the receivers are run. No results are propagated from |
| 2175 | * receivers and receivers can not abort the broadcast. If you want |
| 2176 | * to allow receivers to propagate results or abort the broadcast, you must |
| 2177 | * send an ordered broadcast using |
| 2178 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2179 | * |
| 2180 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2181 | * |
| 2182 | * @param intent The Intent to broadcast; all receivers matching this |
| 2183 | * Intent will receive the broadcast. |
| 2184 | * @param receiverPermission (optional) String naming a permission that |
| 2185 | * a receiver must hold in order to receive your broadcast. |
| 2186 | * If null, no permission is required. |
| 2187 | * @param options (optional) Additional sending options, generated from a |
| 2188 | * {@link android.app.BroadcastOptions}. |
| 2189 | * |
| 2190 | * @see android.content.BroadcastReceiver |
| 2191 | * @see #registerReceiver |
| 2192 | * @see #sendBroadcast(Intent) |
| 2193 | * @see #sendOrderedBroadcast(Intent, String) |
| 2194 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2195 | * @hide |
| 2196 | */ |
| 2197 | @SystemApi |
| 2198 | public abstract void sendBroadcast(Intent intent, |
| 2199 | @Nullable String receiverPermission, |
| 2200 | @Nullable Bundle options); |
| 2201 | |
| 2202 | /** |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2203 | * Like {@link #sendBroadcast(Intent, String)}, but also allows specification |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2204 | * of an associated app op as per {@link android.app.AppOpsManager}. |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2205 | * @hide |
| 2206 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 2207 | @UnsupportedAppUsage |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2208 | public abstract void sendBroadcast(Intent intent, |
| 2209 | String receiverPermission, int appOp); |
| 2210 | |
| 2211 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2212 | * Broadcast the given intent to all interested BroadcastReceivers, delivering |
| 2213 | * them one at a time to allow more preferred receivers to consume the |
| 2214 | * broadcast before it is delivered to less preferred receivers. This |
| 2215 | * call is asynchronous; it returns immediately, and you will continue |
| 2216 | * executing while the receivers are run. |
| 2217 | * |
| 2218 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2219 | * |
| 2220 | * @param intent The Intent to broadcast; all receivers matching this |
| 2221 | * Intent will receive the broadcast. |
| 2222 | * @param receiverPermission (optional) String naming a permissions that |
| 2223 | * a receiver must hold in order to receive your broadcast. |
| 2224 | * If null, no permission is required. |
| 2225 | * |
| 2226 | * @see android.content.BroadcastReceiver |
| 2227 | * @see #registerReceiver |
| 2228 | * @see #sendBroadcast(Intent) |
| 2229 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2230 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2231 | public abstract void sendOrderedBroadcast(@RequiresPermission Intent intent, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2232 | @Nullable String receiverPermission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2233 | |
| 2234 | /** |
| 2235 | * Version of {@link #sendBroadcast(Intent)} that allows you to |
| 2236 | * receive data back from the broadcast. This is accomplished by |
| 2237 | * supplying your own BroadcastReceiver when calling, which will be |
| 2238 | * treated as a final receiver at the end of the broadcast -- its |
| 2239 | * {@link BroadcastReceiver#onReceive} method will be called with |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2240 | * 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] | 2241 | * be serialized in the same way as calling |
| 2242 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2243 | * |
| 2244 | * <p>Like {@link #sendBroadcast(Intent)}, this method is |
| 2245 | * asynchronous; it will return before |
| 2246 | * resultReceiver.onReceive() is called. |
| 2247 | * |
| 2248 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2249 | * |
| 2250 | * @param intent The Intent to broadcast; all receivers matching this |
| 2251 | * Intent will receive the broadcast. |
| 2252 | * @param receiverPermission String naming a permissions that |
| 2253 | * a receiver must hold in order to receive your broadcast. |
| 2254 | * If null, no permission is required. |
| 2255 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2256 | * receiver of the broadcast. |
| 2257 | * @param scheduler A custom Handler with which to schedule the |
| 2258 | * resultReceiver callback; if null it will be |
| 2259 | * scheduled in the Context's main thread. |
| 2260 | * @param initialCode An initial value for the result code. Often |
| 2261 | * Activity.RESULT_OK. |
| 2262 | * @param initialData An initial value for the result data. Often |
| 2263 | * null. |
| 2264 | * @param initialExtras An initial value for the result extras. Often |
| 2265 | * null. |
| 2266 | * |
| 2267 | * @see #sendBroadcast(Intent) |
| 2268 | * @see #sendBroadcast(Intent, String) |
| 2269 | * @see #sendOrderedBroadcast(Intent, String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2270 | * @see android.content.BroadcastReceiver |
| 2271 | * @see #registerReceiver |
| 2272 | * @see android.app.Activity#RESULT_OK |
| 2273 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2274 | public abstract void sendOrderedBroadcast(@RequiresPermission @NonNull Intent intent, |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 2275 | @Nullable String receiverPermission, @Nullable BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2276 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2277 | @Nullable Bundle initialExtras); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2278 | |
| 2279 | /** |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 2280 | * Version of {@link #sendBroadcast(Intent)} that allows you to |
| 2281 | * receive data back from the broadcast. This is accomplished by |
| 2282 | * supplying your own BroadcastReceiver when calling, which will be |
| 2283 | * treated as a final receiver at the end of the broadcast -- its |
| 2284 | * {@link BroadcastReceiver#onReceive} method will be called with |
| 2285 | * the result values collected from the other receivers. The broadcast will |
| 2286 | * be serialized in the same way as calling |
| 2287 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2288 | * |
| 2289 | * <p>Like {@link #sendBroadcast(Intent)}, this method is |
| 2290 | * asynchronous; it will return before |
| 2291 | * resultReceiver.onReceive() is called. |
| 2292 | * |
| 2293 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2294 | * |
| 2295 | * |
| 2296 | * @param intent The Intent to broadcast; all receivers matching this |
| 2297 | * Intent will receive the broadcast. |
| 2298 | * @param receiverPermission String naming a permissions that |
| 2299 | * a receiver must hold in order to receive your broadcast. |
| 2300 | * If null, no permission is required. |
| 2301 | * @param options (optional) Additional sending options, generated from a |
| 2302 | * {@link android.app.BroadcastOptions}. |
| 2303 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2304 | * receiver of the broadcast. |
| 2305 | * @param scheduler A custom Handler with which to schedule the |
| 2306 | * resultReceiver callback; if null it will be |
| 2307 | * scheduled in the Context's main thread. |
| 2308 | * @param initialCode An initial value for the result code. Often |
| 2309 | * Activity.RESULT_OK. |
| 2310 | * @param initialData An initial value for the result data. Often |
| 2311 | * null. |
| 2312 | * @param initialExtras An initial value for the result extras. Often |
| 2313 | * null. |
| 2314 | * @see #sendBroadcast(Intent) |
| 2315 | * @see #sendBroadcast(Intent, String) |
| 2316 | * @see #sendOrderedBroadcast(Intent, String) |
| 2317 | * @see android.content.BroadcastReceiver |
| 2318 | * @see #registerReceiver |
| 2319 | * @see android.app.Activity#RESULT_OK |
| 2320 | * @hide |
| 2321 | */ |
| 2322 | @SystemApi |
| 2323 | public abstract void sendOrderedBroadcast(@NonNull Intent intent, |
| 2324 | @Nullable String receiverPermission, @Nullable Bundle options, |
| 2325 | @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, |
| 2326 | int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras); |
| 2327 | |
| 2328 | /** |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2329 | * Like {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, android.os.Handler, |
| 2330 | * int, String, android.os.Bundle)}, but also allows specification |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2331 | * of an associated app op as per {@link android.app.AppOpsManager}. |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2332 | * @hide |
| 2333 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 2334 | @UnsupportedAppUsage |
Dianne Hackborn | f51f612 | 2013-02-04 18:23:34 -0800 | [diff] [blame] | 2335 | public abstract void sendOrderedBroadcast(Intent intent, |
| 2336 | String receiverPermission, int appOp, BroadcastReceiver resultReceiver, |
| 2337 | Handler scheduler, int initialCode, String initialData, |
| 2338 | Bundle initialExtras); |
| 2339 | |
| 2340 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2341 | * Version of {@link #sendBroadcast(Intent)} that allows you to specify the |
| 2342 | * 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] | 2343 | * that are not pre-installed on the system image. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2344 | * @param intent The intent to broadcast |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 2345 | * @param user UserHandle to send the intent to. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2346 | * @see #sendBroadcast(Intent) |
| 2347 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2348 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2349 | public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent, |
| 2350 | UserHandle user); |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2351 | |
| 2352 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2353 | * Version of {@link #sendBroadcast(Intent, String)} that allows you to specify the |
| 2354 | * 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] | 2355 | * that are not pre-installed on the system image. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2356 | * |
| 2357 | * @param intent The Intent to broadcast; all receivers matching this |
| 2358 | * Intent will receive the broadcast. |
| 2359 | * @param user UserHandle to send the intent to. |
| 2360 | * @param receiverPermission (optional) String naming a permission that |
| 2361 | * a receiver must hold in order to receive your broadcast. |
| 2362 | * If null, no permission is required. |
| 2363 | * |
| 2364 | * @see #sendBroadcast(Intent, String) |
| 2365 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2366 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2367 | public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent, |
| 2368 | UserHandle user, @Nullable String receiverPermission); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2369 | |
Chad Brubaker | 52c8edc | 2016-07-25 14:30:26 -0700 | [diff] [blame] | 2370 | /** |
| 2371 | * Version of {@link #sendBroadcast(Intent, String, Bundle)} that allows you to specify the |
| 2372 | * 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] | 2373 | * that are not pre-installed on the system image. |
Chad Brubaker | 52c8edc | 2016-07-25 14:30:26 -0700 | [diff] [blame] | 2374 | * |
| 2375 | * @param intent The Intent to broadcast; all receivers matching this |
| 2376 | * Intent will receive the broadcast. |
| 2377 | * @param user UserHandle to send the intent to. |
| 2378 | * @param receiverPermission (optional) String naming a permission that |
| 2379 | * a receiver must hold in order to receive your broadcast. |
| 2380 | * If null, no permission is required. |
| 2381 | * @param options (optional) Additional sending options, generated from a |
| 2382 | * {@link android.app.BroadcastOptions}. |
| 2383 | * |
| 2384 | * @see #sendBroadcast(Intent, String, Bundle) |
| 2385 | * @hide |
| 2386 | */ |
| 2387 | @SystemApi |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2388 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Chad Brubaker | 52c8edc | 2016-07-25 14:30:26 -0700 | [diff] [blame] | 2389 | public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent, |
| 2390 | UserHandle user, @Nullable String receiverPermission, @Nullable Bundle options); |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 2391 | |
| 2392 | /** |
| 2393 | * Version of {@link #sendBroadcast(Intent, String)} that allows you to specify the |
| 2394 | * 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] | 2395 | * that are not pre-installed on the system image. |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 2396 | * |
| 2397 | * @param intent The Intent to broadcast; all receivers matching this |
| 2398 | * Intent will receive the broadcast. |
| 2399 | * @param user UserHandle to send the intent to. |
| 2400 | * @param receiverPermission (optional) String naming a permission that |
| 2401 | * a receiver must hold in order to receive your broadcast. |
| 2402 | * If null, no permission is required. |
| 2403 | * @param appOp The app op associated with the broadcast. |
| 2404 | * |
| 2405 | * @see #sendBroadcast(Intent, String) |
| 2406 | * |
| 2407 | * @hide |
| 2408 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2409 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 2410 | @UnsupportedAppUsage |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2411 | public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent, |
| 2412 | UserHandle user, @Nullable String receiverPermission, int appOp); |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 2413 | |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2414 | /** |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2415 | * Version of |
| 2416 | * {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)} |
| 2417 | * that allows you to specify the |
| 2418 | * 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] | 2419 | * that are not pre-installed on the system image. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2420 | * |
| 2421 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2422 | * |
| 2423 | * @param intent The Intent to broadcast; all receivers matching this |
| 2424 | * Intent will receive the broadcast. |
Dianne Hackborn | 79af1dd | 2012-08-16 16:42:52 -0700 | [diff] [blame] | 2425 | * @param user UserHandle to send the intent to. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2426 | * @param receiverPermission String naming a permissions that |
| 2427 | * a receiver must hold in order to receive your broadcast. |
| 2428 | * If null, no permission is required. |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2429 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2430 | * receiver of the broadcast. |
| 2431 | * @param scheduler A custom Handler with which to schedule the |
| 2432 | * resultReceiver callback; if null it will be |
| 2433 | * scheduled in the Context's main thread. |
| 2434 | * @param initialCode An initial value for the result code. Often |
| 2435 | * Activity.RESULT_OK. |
| 2436 | * @param initialData An initial value for the result data. Often |
| 2437 | * null. |
| 2438 | * @param initialExtras An initial value for the result extras. Often |
| 2439 | * null. |
| 2440 | * |
| 2441 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2442 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2443 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2444 | public abstract void sendOrderedBroadcastAsUser(@RequiresPermission Intent intent, |
| 2445 | UserHandle user, @Nullable String receiverPermission, BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2446 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2447 | @Nullable Bundle initialExtras); |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 2448 | |
| 2449 | /** |
Amith Yamasani | 3cf7572 | 2014-05-16 12:37:29 -0700 | [diff] [blame] | 2450 | * Similar to above but takes an appOp as well, to enforce restrictions. |
| 2451 | * @see #sendOrderedBroadcastAsUser(Intent, UserHandle, String, |
| 2452 | * BroadcastReceiver, Handler, int, String, Bundle) |
| 2453 | * @hide |
| 2454 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2455 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 2456 | @UnsupportedAppUsage |
Amith Yamasani | 3cf7572 | 2014-05-16 12:37:29 -0700 | [diff] [blame] | 2457 | public abstract void sendOrderedBroadcastAsUser(Intent intent, UserHandle user, |
| 2458 | @Nullable String receiverPermission, int appOp, BroadcastReceiver resultReceiver, |
| 2459 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2460 | @Nullable Bundle initialExtras); |
| 2461 | |
| 2462 | /** |
Dianne Hackborn | fd854ee | 2015-07-13 18:00:37 -0700 | [diff] [blame] | 2463 | * Similar to above but takes an appOp as well, to enforce restrictions, and an options Bundle. |
| 2464 | * @see #sendOrderedBroadcastAsUser(Intent, UserHandle, String, |
| 2465 | * BroadcastReceiver, Handler, int, String, Bundle) |
| 2466 | * @hide |
| 2467 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2468 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 2469 | @UnsupportedAppUsage |
Dianne Hackborn | fd854ee | 2015-07-13 18:00:37 -0700 | [diff] [blame] | 2470 | public abstract void sendOrderedBroadcastAsUser(Intent intent, UserHandle user, |
| 2471 | @Nullable String receiverPermission, int appOp, @Nullable Bundle options, |
| 2472 | BroadcastReceiver resultReceiver, @Nullable Handler scheduler, int initialCode, |
| 2473 | @Nullable String initialData, @Nullable Bundle initialExtras); |
| 2474 | |
| 2475 | /** |
Jordan Liu | 5473553 | 2019-10-29 10:33:55 -0700 | [diff] [blame] | 2476 | * Version of |
| 2477 | * {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, |
| 2478 | * Bundle)} that allows you to specify the App Op to enforce restrictions on which receivers |
| 2479 | * the broadcast will be sent to. |
| 2480 | * |
| 2481 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2482 | * |
| 2483 | * @param intent The Intent to broadcast; all receivers matching this |
| 2484 | * Intent will receive the broadcast. |
| 2485 | * @param receiverPermission String naming a permissions that |
| 2486 | * a receiver must hold in order to receive your broadcast. |
| 2487 | * If null, no permission is required. |
| 2488 | * @param receiverAppOp The app op associated with the broadcast. If null, no appOp is |
| 2489 | * required. If both receiverAppOp and receiverPermission are non-null, |
| 2490 | * a receiver must have both of them to |
| 2491 | * receive the broadcast |
| 2492 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2493 | * receiver of the broadcast. |
| 2494 | * @param scheduler A custom Handler with which to schedule the |
| 2495 | * resultReceiver callback; if null it will be |
| 2496 | * scheduled in the Context's main thread. |
| 2497 | * @param initialCode An initial value for the result code. Often |
| 2498 | * Activity.RESULT_OK. |
| 2499 | * @param initialData An initial value for the result data. Often |
| 2500 | * null. |
| 2501 | * @param initialExtras An initial value for the result extras. Often |
| 2502 | * null. |
| 2503 | * |
| 2504 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2505 | */ |
Jordan Liu | 31a4da6 | 2019-11-19 11:36:34 -0800 | [diff] [blame] | 2506 | public void sendOrderedBroadcast(@NonNull Intent intent, @Nullable String receiverPermission, |
| 2507 | @Nullable String receiverAppOp, @Nullable BroadcastReceiver resultReceiver, |
| 2508 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2509 | @Nullable Bundle initialExtras) { |
Jordan Liu | 5473553 | 2019-10-29 10:33:55 -0700 | [diff] [blame] | 2510 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 2511 | } |
| 2512 | |
| 2513 | /** |
Peter Wang | 7701f57 | 2019-11-07 16:57:23 -0800 | [diff] [blame] | 2514 | * Version of |
| 2515 | * {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, |
| 2516 | * Bundle)} that allows you to specify the App Op to enforce restrictions on which receivers |
| 2517 | * the broadcast will be sent to as well as supply an optional sending options |
| 2518 | * |
| 2519 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2520 | * |
| 2521 | * @param intent The Intent to broadcast; all receivers matching this |
| 2522 | * Intent will receive the broadcast. |
| 2523 | * @param receiverPermission String naming a permissions that |
| 2524 | * a receiver must hold in order to receive your broadcast. |
| 2525 | * If null, no permission is required. |
| 2526 | * @param receiverAppOp The app op associated with the broadcast. If null, no appOp is |
| 2527 | * required. If both receiverAppOp and receiverPermission are non-null, |
| 2528 | * a receiver must have both of them to |
| 2529 | * receive the broadcast |
| 2530 | * @param options (optional) Additional sending options, generated from a |
| 2531 | * {@link android.app.BroadcastOptions}. |
| 2532 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2533 | * receiver of the broadcast. |
| 2534 | * @param scheduler A custom Handler with which to schedule the |
| 2535 | * resultReceiver callback; if null it will be |
| 2536 | * scheduled in the Context's main thread. |
| 2537 | * @param initialCode An initial value for the result code. Often |
| 2538 | * Activity.RESULT_OK. |
| 2539 | * @param initialData An initial value for the result data. Often |
| 2540 | * null. |
| 2541 | * @param initialExtras An initial value for the result extras. Often |
| 2542 | * null. |
| 2543 | * |
| 2544 | * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle) |
| 2545 | * @see android.app.BroadcastOptions |
| 2546 | */ |
| 2547 | public void sendOrderedBroadcast(@RequiresPermission @NonNull Intent intent, |
| 2548 | @Nullable String receiverPermission, @Nullable String receiverAppOp, |
| 2549 | @Nullable Bundle options, @Nullable BroadcastReceiver resultReceiver, |
| 2550 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2551 | @Nullable Bundle initialExtras) { |
| 2552 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 2553 | } |
| 2554 | |
| 2555 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2556 | * <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] | 2557 | * Intent you are sending stays around after the broadcast is complete, |
| 2558 | * so that others can quickly retrieve that data through the return |
| 2559 | * value of {@link #registerReceiver(BroadcastReceiver, IntentFilter)}. In |
| 2560 | * all other ways, this behaves the same as |
| 2561 | * {@link #sendBroadcast(Intent)}. |
| 2562 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2563 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2564 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2565 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2566 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2567 | * desired. |
| 2568 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2569 | * @param intent The Intent to broadcast; all receivers matching this |
| 2570 | * Intent will receive the broadcast, and the Intent will be held to |
| 2571 | * be re-broadcast to future receivers. |
| 2572 | * |
| 2573 | * @see #sendBroadcast(Intent) |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2574 | * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2575 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2576 | @Deprecated |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 2577 | @RequiresPermission(android.Manifest.permission.BROADCAST_STICKY) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2578 | public abstract void sendStickyBroadcast(@RequiresPermission Intent intent); |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 2579 | |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2580 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2581 | * <p>Version of {@link #sendStickyBroadcast} that allows you to |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2582 | * receive data back from the broadcast. This is accomplished by |
| 2583 | * supplying your own BroadcastReceiver when calling, which will be |
| 2584 | * treated as a final receiver at the end of the broadcast -- its |
| 2585 | * {@link BroadcastReceiver#onReceive} method will be called with |
| 2586 | * the result values collected from the other receivers. The broadcast will |
| 2587 | * be serialized in the same way as calling |
| 2588 | * {@link #sendOrderedBroadcast(Intent, String)}. |
| 2589 | * |
| 2590 | * <p>Like {@link #sendBroadcast(Intent)}, this method is |
| 2591 | * asynchronous; it will return before |
| 2592 | * resultReceiver.onReceive() is called. Note that the sticky data |
| 2593 | * stored is only the data you initially supply to the broadcast, not |
| 2594 | * the result of any changes made by the receivers. |
| 2595 | * |
| 2596 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2597 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2598 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2599 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2600 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2601 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2602 | * desired. |
| 2603 | * |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2604 | * @param intent The Intent to broadcast; all receivers matching this |
| 2605 | * Intent will receive the broadcast. |
| 2606 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2607 | * receiver of the broadcast. |
| 2608 | * @param scheduler A custom Handler with which to schedule the |
| 2609 | * resultReceiver callback; if null it will be |
| 2610 | * scheduled in the Context's main thread. |
| 2611 | * @param initialCode An initial value for the result code. Often |
| 2612 | * Activity.RESULT_OK. |
| 2613 | * @param initialData An initial value for the result data. Often |
| 2614 | * null. |
| 2615 | * @param initialExtras An initial value for the result extras. Often |
| 2616 | * null. |
| 2617 | * |
| 2618 | * @see #sendBroadcast(Intent) |
| 2619 | * @see #sendBroadcast(Intent, String) |
| 2620 | * @see #sendOrderedBroadcast(Intent, String) |
| 2621 | * @see #sendStickyBroadcast(Intent) |
| 2622 | * @see android.content.BroadcastReceiver |
| 2623 | * @see #registerReceiver |
| 2624 | * @see android.app.Activity#RESULT_OK |
| 2625 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2626 | @Deprecated |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 2627 | @RequiresPermission(android.Manifest.permission.BROADCAST_STICKY) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2628 | public abstract void sendStickyOrderedBroadcast(@RequiresPermission Intent intent, |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2629 | BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2630 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2631 | @Nullable Bundle initialExtras); |
Dianne Hackborn | efa199f | 2009-09-19 12:03:15 -0700 | [diff] [blame] | 2632 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2633 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2634 | * <p>Remove the data previously sent with {@link #sendStickyBroadcast}, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2635 | * so that it is as if the sticky broadcast had never happened. |
| 2636 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2637 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2638 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2639 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2640 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2641 | * desired. |
| 2642 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2643 | * @param intent The Intent that was previously broadcast. |
| 2644 | * |
| 2645 | * @see #sendStickyBroadcast |
| 2646 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2647 | @Deprecated |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 2648 | @RequiresPermission(android.Manifest.permission.BROADCAST_STICKY) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2649 | public abstract void removeStickyBroadcast(@RequiresPermission Intent intent); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2650 | |
| 2651 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2652 | * <p>Version of {@link #sendStickyBroadcast(Intent)} that allows you to specify the |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2653 | * 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] | 2654 | * that are not pre-installed on the system image. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2655 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2656 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2657 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2658 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2659 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2660 | * desired. |
| 2661 | * |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2662 | * @param intent The Intent to broadcast; all receivers matching this |
| 2663 | * Intent will receive the broadcast, and the Intent will be held to |
| 2664 | * be re-broadcast to future receivers. |
| 2665 | * @param user UserHandle to send the intent to. |
| 2666 | * |
| 2667 | * @see #sendBroadcast(Intent) |
| 2668 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2669 | @Deprecated |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2670 | @RequiresPermission(allOf = { |
| 2671 | android.Manifest.permission.INTERACT_ACROSS_USERS, |
| 2672 | android.Manifest.permission.BROADCAST_STICKY |
| 2673 | }) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2674 | public abstract void sendStickyBroadcastAsUser(@RequiresPermission Intent intent, |
| 2675 | UserHandle user); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2676 | |
| 2677 | /** |
Dianne Hackborn | e0e413e | 2015-12-09 17:22:26 -0800 | [diff] [blame] | 2678 | * @hide |
| 2679 | * This is just here for sending CONNECTIVITY_ACTION. |
| 2680 | */ |
| 2681 | @Deprecated |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2682 | @RequiresPermission(allOf = { |
| 2683 | android.Manifest.permission.INTERACT_ACROSS_USERS, |
| 2684 | android.Manifest.permission.BROADCAST_STICKY |
| 2685 | }) |
Dianne Hackborn | e0e413e | 2015-12-09 17:22:26 -0800 | [diff] [blame] | 2686 | public abstract void sendStickyBroadcastAsUser(@RequiresPermission Intent intent, |
| 2687 | UserHandle user, Bundle options); |
| 2688 | |
| 2689 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2690 | * <p>Version of |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2691 | * {@link #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)} |
| 2692 | * that allows you to specify the |
| 2693 | * 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] | 2694 | * that are not pre-installed on the system image. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2695 | * |
| 2696 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2697 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2698 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2699 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2700 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2701 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2702 | * desired. |
| 2703 | * |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2704 | * @param intent The Intent to broadcast; all receivers matching this |
| 2705 | * Intent will receive the broadcast. |
| 2706 | * @param user UserHandle to send the intent to. |
| 2707 | * @param resultReceiver Your own BroadcastReceiver to treat as the final |
| 2708 | * receiver of the broadcast. |
| 2709 | * @param scheduler A custom Handler with which to schedule the |
| 2710 | * resultReceiver callback; if null it will be |
| 2711 | * scheduled in the Context's main thread. |
| 2712 | * @param initialCode An initial value for the result code. Often |
| 2713 | * Activity.RESULT_OK. |
| 2714 | * @param initialData An initial value for the result data. Often |
| 2715 | * null. |
| 2716 | * @param initialExtras An initial value for the result extras. Often |
| 2717 | * null. |
| 2718 | * |
| 2719 | * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle) |
| 2720 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2721 | @Deprecated |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2722 | @RequiresPermission(allOf = { |
| 2723 | android.Manifest.permission.INTERACT_ACROSS_USERS, |
| 2724 | android.Manifest.permission.BROADCAST_STICKY |
| 2725 | }) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2726 | public abstract void sendStickyOrderedBroadcastAsUser(@RequiresPermission Intent intent, |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2727 | UserHandle user, BroadcastReceiver resultReceiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2728 | @Nullable Handler scheduler, int initialCode, @Nullable String initialData, |
| 2729 | @Nullable Bundle initialExtras); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2730 | |
| 2731 | /** |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2732 | * <p>Version of {@link #removeStickyBroadcast(Intent)} that allows you to specify the |
Dianne Hackborn | 8832c18 | 2012-09-17 17:20:24 -0700 | [diff] [blame] | 2733 | * 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] | 2734 | * that are not pre-installed on the system image. |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2735 | * |
| 2736 | * <p>You must hold the {@link android.Manifest.permission#BROADCAST_STICKY} |
| 2737 | * permission in order to use this API. If you do not hold that |
| 2738 | * permission, {@link SecurityException} will be thrown. |
| 2739 | * |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2740 | * @deprecated Sticky broadcasts should not be used. They provide no security (anyone |
| 2741 | * can access them), no protection (anyone can modify them), and many other problems. |
| 2742 | * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> |
| 2743 | * has changed, with another mechanism for apps to retrieve the current value whenever |
| 2744 | * desired. |
| 2745 | * |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2746 | * @param intent The Intent that was previously broadcast. |
| 2747 | * @param user UserHandle to remove the sticky broadcast from. |
| 2748 | * |
| 2749 | * @see #sendStickyBroadcastAsUser |
| 2750 | */ |
Dianne Hackborn | 2c35300 | 2014-08-29 15:13:30 -0700 | [diff] [blame] | 2751 | @Deprecated |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2752 | @RequiresPermission(allOf = { |
| 2753 | android.Manifest.permission.INTERACT_ACROSS_USERS, |
| 2754 | android.Manifest.permission.BROADCAST_STICKY |
| 2755 | }) |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 2756 | public abstract void removeStickyBroadcastAsUser(@RequiresPermission Intent intent, |
| 2757 | UserHandle user); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2758 | |
| 2759 | /** |
Chris Tate | a34df8a2 | 2009-04-02 23:15:58 -0700 | [diff] [blame] | 2760 | * 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] | 2761 | * <var>receiver</var> will be called with any broadcast Intent that |
| 2762 | * matches <var>filter</var>, in the main application thread. |
| 2763 | * |
| 2764 | * <p>The system may broadcast Intents that are "sticky" -- these stay |
Kweku Adams | 86f39a4 | 2016-11-16 12:50:38 -0800 | [diff] [blame] | 2765 | * 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] | 2766 | * registrations. If your IntentFilter matches one of these sticky |
| 2767 | * Intents, that Intent will be returned by this function |
| 2768 | * <strong>and</strong> sent to your <var>receiver</var> as if it had just |
| 2769 | * been broadcast. |
| 2770 | * |
| 2771 | * <p>There may be multiple sticky Intents that match <var>filter</var>, |
| 2772 | * in which case each of these will be sent to <var>receiver</var>. In |
| 2773 | * this case, only one of these can be returned directly by the function; |
| 2774 | * which of these that is returned is arbitrarily decided by the system. |
| 2775 | * |
| 2776 | * <p>If you know the Intent your are registering for is sticky, you can |
| 2777 | * supply null for your <var>receiver</var>. In this case, no receiver is |
| 2778 | * registered -- the function simply returns the sticky Intent that |
| 2779 | * matches <var>filter</var>. In the case of multiple matches, the same |
| 2780 | * rules as described above apply. |
| 2781 | * |
| 2782 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2783 | * |
Dianne Hackborn | 6c418d5 | 2011-06-29 14:05:33 -0700 | [diff] [blame] | 2784 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 2785 | * registered with this method will correctly respect the |
| 2786 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 2787 | * Prior to that, it would be ignored and delivered to all matching registered |
| 2788 | * receivers. Be careful if using this for security.</p> |
| 2789 | * |
Chris Tate | a34df8a2 | 2009-04-02 23:15:58 -0700 | [diff] [blame] | 2790 | * <p class="note">Note: this method <em>cannot be called from a |
| 2791 | * {@link BroadcastReceiver} component;</em> that is, from a BroadcastReceiver |
| 2792 | * that is declared in an application's manifest. It is okay, however, to call |
| 2793 | * this method from another BroadcastReceiver that has itself been registered |
| 2794 | * at run time with {@link #registerReceiver}, since the lifetime of such a |
| 2795 | * 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] | 2796 | * |
| 2797 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2798 | * @param filter Selects the Intent broadcasts to be received. |
| 2799 | * |
| 2800 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2801 | * or null if there are none. |
| 2802 | * |
| 2803 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
| 2804 | * @see #sendBroadcast |
| 2805 | * @see #unregisterReceiver |
| 2806 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2807 | @Nullable |
| 2808 | public abstract Intent registerReceiver(@Nullable BroadcastReceiver receiver, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2809 | IntentFilter filter); |
| 2810 | |
| 2811 | /** |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2812 | * Register to receive intent broadcasts, with the receiver optionally being |
| 2813 | * exposed to Instant Apps. See |
| 2814 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter)} for more |
| 2815 | * information. By default Instant Apps cannot interact with receivers in other |
| 2816 | * applications, this allows you to expose a receiver that Instant Apps can |
| 2817 | * interact with. |
| 2818 | * |
| 2819 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2820 | * |
| 2821 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 2822 | * registered with this method will correctly respect the |
| 2823 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 2824 | * Prior to that, it would be ignored and delivered to all matching registered |
| 2825 | * receivers. Be careful if using this for security.</p> |
| 2826 | * |
| 2827 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2828 | * @param filter Selects the Intent broadcasts to be received. |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2829 | * @param flags Additional options for the receiver. May be 0 or |
| 2830 | * {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2831 | * |
| 2832 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2833 | * or null if there are none. |
| 2834 | * |
| 2835 | * @see #registerReceiver(BroadcastReceiver, IntentFilter) |
| 2836 | * @see #sendBroadcast |
| 2837 | * @see #unregisterReceiver |
| 2838 | */ |
| 2839 | @Nullable |
| 2840 | public abstract Intent registerReceiver(@Nullable BroadcastReceiver receiver, |
| 2841 | IntentFilter filter, |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2842 | @RegisterReceiverFlags int flags); |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2843 | |
| 2844 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2845 | * Register to receive intent broadcasts, to run in the context of |
| 2846 | * <var>scheduler</var>. See |
| 2847 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter)} for more |
| 2848 | * information. This allows you to enforce permissions on who can |
| 2849 | * broadcast intents to your receiver, or have the receiver run in |
| 2850 | * a different thread than the main application thread. |
| 2851 | * |
| 2852 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2853 | * |
Dianne Hackborn | 6c418d5 | 2011-06-29 14:05:33 -0700 | [diff] [blame] | 2854 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 2855 | * registered with this method will correctly respect the |
| 2856 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 2857 | * Prior to that, it would be ignored and delivered to all matching registered |
| 2858 | * receivers. Be careful if using this for security.</p> |
| 2859 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2860 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2861 | * @param filter Selects the Intent broadcasts to be received. |
| 2862 | * @param broadcastPermission String naming a permissions that a |
| 2863 | * broadcaster must hold in order to send an Intent to you. If null, |
| 2864 | * no permission is required. |
| 2865 | * @param scheduler Handler identifying the thread that will receive |
| 2866 | * the Intent. If null, the main thread of the process will be used. |
| 2867 | * |
| 2868 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2869 | * or null if there are none. |
| 2870 | * |
| 2871 | * @see #registerReceiver(BroadcastReceiver, IntentFilter) |
| 2872 | * @see #sendBroadcast |
| 2873 | * @see #unregisterReceiver |
| 2874 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2875 | @Nullable |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2876 | public abstract Intent registerReceiver(BroadcastReceiver receiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2877 | IntentFilter filter, @Nullable String broadcastPermission, |
| 2878 | @Nullable Handler scheduler); |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2879 | |
| 2880 | /** |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2881 | * Register to receive intent broadcasts, to run in the context of |
| 2882 | * <var>scheduler</var>. See |
| 2883 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter, int)} and |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2884 | * {@link #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler)} |
| 2885 | * for more information. |
| 2886 | * |
| 2887 | * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts. |
| 2888 | * |
| 2889 | * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers |
| 2890 | * registered with this method will correctly respect the |
| 2891 | * {@link Intent#setPackage(String)} specified for an Intent being broadcast. |
| 2892 | * Prior to that, it would be ignored and delivered to all matching registered |
| 2893 | * receivers. Be careful if using this for security.</p> |
| 2894 | * |
| 2895 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2896 | * @param filter Selects the Intent broadcasts to be received. |
| 2897 | * @param broadcastPermission String naming a permissions that a |
| 2898 | * broadcaster must hold in order to send an Intent to you. If null, |
| 2899 | * no permission is required. |
| 2900 | * @param scheduler Handler identifying the thread that will receive |
| 2901 | * 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] | 2902 | * @param flags Additional options for the receiver. May be 0 or |
| 2903 | * {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2904 | * |
| 2905 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2906 | * or null if there are none. |
| 2907 | * |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2908 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, int) |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2909 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
| 2910 | * @see #sendBroadcast |
| 2911 | * @see #unregisterReceiver |
| 2912 | */ |
| 2913 | @Nullable |
| 2914 | public abstract Intent registerReceiver(BroadcastReceiver receiver, |
| 2915 | IntentFilter filter, @Nullable String broadcastPermission, |
Chad Brubaker | 6d6015f | 2017-04-18 11:25:16 -0700 | [diff] [blame] | 2916 | @Nullable Handler scheduler, @RegisterReceiverFlags int flags); |
Chad Brubaker | 816c83b | 2017-03-02 10:27:59 -0800 | [diff] [blame] | 2917 | |
| 2918 | /** |
Meng Wang | 3f9e036 | 2019-11-05 10:43:45 -0800 | [diff] [blame] | 2919 | * Same as {@link #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler)} |
| 2920 | * but this receiver will receive broadcasts that are sent to all users. The receiver can |
| 2921 | * use {@link BroadcastReceiver#getSendingUser} to determine on which user the broadcast |
| 2922 | * was sent. |
| 2923 | * |
| 2924 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2925 | * @param filter Selects the Intent broadcasts to be received. |
| 2926 | * @param broadcastPermission String naming a permissions that a |
| 2927 | * broadcaster must hold in order to send an Intent to you. If {@code null}, |
| 2928 | * no permission is required. |
| 2929 | * @param scheduler Handler identifying the thread that will receive |
| 2930 | * the Intent. If {@code null}, the main thread of the process will be used. |
| 2931 | * |
| 2932 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2933 | * or {@code null} if there are none. |
| 2934 | * |
| 2935 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
| 2936 | * @see #sendBroadcast |
| 2937 | * @see #unregisterReceiver |
| 2938 | * @hide |
| 2939 | */ |
| 2940 | @Nullable |
| 2941 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) |
| 2942 | @SystemApi |
| 2943 | public Intent registerReceiverForAllUsers(@Nullable BroadcastReceiver receiver, |
| 2944 | @NonNull IntentFilter filter, @Nullable String broadcastPermission, |
| 2945 | @Nullable Handler scheduler) { |
| 2946 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 2947 | } |
| 2948 | |
| 2949 | /** |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2950 | * @hide |
| 2951 | * Same as {@link #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
| 2952 | * but for a specific user. This receiver will receiver broadcasts that |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2953 | * are sent to the requested user. |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2954 | * |
| 2955 | * @param receiver The BroadcastReceiver to handle the broadcast. |
| 2956 | * @param user UserHandle to send the intent to. |
| 2957 | * @param filter Selects the Intent broadcasts to be received. |
| 2958 | * @param broadcastPermission String naming a permissions that a |
| 2959 | * broadcaster must hold in order to send an Intent to you. If null, |
| 2960 | * no permission is required. |
| 2961 | * @param scheduler Handler identifying the thread that will receive |
| 2962 | * the Intent. If null, the main thread of the process will be used. |
| 2963 | * |
| 2964 | * @return The first sticky intent found that matches <var>filter</var>, |
| 2965 | * or null if there are none. |
| 2966 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 2967 | * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2968 | * @see #sendBroadcast |
| 2969 | * @see #unregisterReceiver |
| 2970 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2971 | @Nullable |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 2972 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 2973 | @UnsupportedAppUsage |
Dianne Hackborn | 20e8098 | 2012-08-31 19:00:44 -0700 | [diff] [blame] | 2974 | public abstract Intent registerReceiverAsUser(BroadcastReceiver receiver, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 2975 | UserHandle user, IntentFilter filter, @Nullable String broadcastPermission, |
| 2976 | @Nullable Handler scheduler); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2977 | |
| 2978 | /** |
| 2979 | * Unregister a previously registered BroadcastReceiver. <em>All</em> |
| 2980 | * filters that have been registered for this BroadcastReceiver will be |
| 2981 | * removed. |
| 2982 | * |
| 2983 | * @param receiver The BroadcastReceiver to unregister. |
| 2984 | * |
| 2985 | * @see #registerReceiver |
| 2986 | */ |
| 2987 | public abstract void unregisterReceiver(BroadcastReceiver receiver); |
| 2988 | |
| 2989 | /** |
| 2990 | * Request that a given application service be started. The Intent |
Hans Boehm | fb9f6ac | 2016-05-05 13:09:28 -0700 | [diff] [blame] | 2991 | * should either contain the complete class name of a specific service |
| 2992 | * implementation to start, or a specific package name to target. If the |
| 2993 | * Intent is less specified, it logs a warning about this. In this case any of the |
| 2994 | * multiple matching services may be used. If this service |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2995 | * is not already running, it will be instantiated and started (creating a |
| 2996 | * process for it if needed); if it is running then it remains running. |
| 2997 | * |
| 2998 | * <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] | 2999 | * 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] | 3000 | * with the <var>intent</var> given here. This provides a convenient way |
| 3001 | * to submit jobs to a service without having to bind and call on to its |
| 3002 | * interface. |
| 3003 | * |
| 3004 | * <p>Using startService() overrides the default service lifetime that is |
| 3005 | * managed by {@link #bindService}: it requires the service to remain |
| 3006 | * running until {@link #stopService} is called, regardless of whether |
| 3007 | * any clients are connected to it. Note that calls to startService() |
Hans Boehm | fb9f6ac | 2016-05-05 13:09:28 -0700 | [diff] [blame] | 3008 | * 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] | 3009 | * a single call to {@link #stopService} will stop it. |
| 3010 | * |
| 3011 | * <p>The system attempts to keep running services around as much as |
| 3012 | * possible. The only time they should be stopped is if the current |
| 3013 | * foreground application is using so many resources that the service needs |
| 3014 | * to be killed. If any errors happen in the service's process, it will |
| 3015 | * automatically be restarted. |
| 3016 | * |
| 3017 | * <p>This function will throw {@link SecurityException} if you do not |
| 3018 | * have permission to start the given service. |
| 3019 | * |
Chris Craik | 1e35352 | 2016-04-18 10:20:50 -0700 | [diff] [blame] | 3020 | * <p class="note"><strong>Note:</strong> Each call to startService() |
| 3021 | * results in significant work done by the system to manage service |
| 3022 | * lifecycle surrounding the processing of the intent, which can take |
| 3023 | * multiple milliseconds of CPU time. Due to this cost, startService() |
| 3024 | * should not be used for frequent intent delivery to a service, and only |
| 3025 | * for scheduling significant work. Use {@link #bindService bound services} |
| 3026 | * for high frequency calls. |
| 3027 | * </p> |
| 3028 | * |
Mark Lu | 94ebbe0 | 2016-12-13 16:29:51 -0800 | [diff] [blame] | 3029 | * @param service Identifies the service to be started. The Intent must be |
| 3030 | * fully explicit (supplying a component name). Additional values |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3031 | * may be included in the Intent extras to supply arguments along with |
| 3032 | * this specific start call. |
| 3033 | * |
| 3034 | * @return If the service is being started or is already running, the |
| 3035 | * {@link ComponentName} of the actual service that was started is |
| 3036 | * returned; else if the service does not exist null is returned. |
| 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 #stopService |
| 3044 | * @see #bindService |
| 3045 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3046 | @Nullable |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3047 | public abstract ComponentName startService(Intent service); |
| 3048 | |
| 3049 | /** |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 3050 | * Similar to {@link #startService(Intent)}, but with an implicit promise that the |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 3051 | * Service will call {@link android.app.Service#startForeground(int, android.app.Notification) |
| 3052 | * 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] | 3053 | * an amount of time comparable to the ANR interval to do this, otherwise the system |
| 3054 | * will automatically stop the service and declare the app ANR. |
| 3055 | * |
| 3056 | * <p>Unlike the ordinary {@link #startService(Intent)}, this method can be used |
| 3057 | * at any time, regardless of whether the app hosting the service is in a foreground |
| 3058 | * state. |
| 3059 | * |
| 3060 | * @param service Identifies the service to be started. The Intent must be |
| 3061 | * fully explicit (supplying a component name). Additional values |
| 3062 | * may be included in the Intent extras to supply arguments along with |
| 3063 | * this specific start call. |
| 3064 | * |
| 3065 | * @return If the service is being started or is already running, the |
| 3066 | * {@link ComponentName} of the actual service that was started is |
| 3067 | * returned; else if the service does not exist null is returned. |
| 3068 | * |
| 3069 | * @throws SecurityException If the caller does not have permission to access the service |
| 3070 | * or the service can not be found. |
| 3071 | * |
| 3072 | * @see #stopService |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 3073 | * @see android.app.Service#startForeground(int, android.app.Notification) |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 3074 | */ |
| 3075 | @Nullable |
| 3076 | public abstract ComponentName startForegroundService(Intent service); |
| 3077 | |
| 3078 | /** |
| 3079 | * @hide like {@link #startForegroundService(Intent)} but for a specific user. |
| 3080 | */ |
| 3081 | @Nullable |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 3082 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 3083 | public abstract ComponentName startForegroundServiceAsUser(Intent service, UserHandle user); |
| 3084 | |
| 3085 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3086 | * Request that a given application service be stopped. If the service is |
| 3087 | * not running, nothing happens. Otherwise it is stopped. Note that calls |
| 3088 | * to startService() are not counted -- this stops the service no matter |
| 3089 | * how many times it was started. |
| 3090 | * |
| 3091 | * <p>Note that if a stopped service still has {@link ServiceConnection} |
| 3092 | * objects bound to it with the {@link #BIND_AUTO_CREATE} set, it will |
| 3093 | * not be destroyed until all of these bindings are removed. See |
| 3094 | * the {@link android.app.Service} documentation for more details on a |
| 3095 | * service's lifecycle. |
| 3096 | * |
| 3097 | * <p>This function will throw {@link SecurityException} if you do not |
| 3098 | * have permission to stop the given service. |
| 3099 | * |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 3100 | * @param service Description of the service to be stopped. The Intent must be either |
| 3101 | * fully explicit (supplying a component name) or specify a specific package |
kopriva | 219f7dc | 2018-10-09 13:42:28 -0700 | [diff] [blame] | 3102 | * name it is targeted to. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3103 | * |
| 3104 | * @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] | 3105 | * 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] | 3106 | * |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 3107 | * @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] | 3108 | * or the service can not be found. |
| 3109 | * @throws IllegalStateException If the application is in a state where the service |
| 3110 | * 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] | 3111 | * |
| 3112 | * @see #startService |
| 3113 | */ |
| 3114 | public abstract boolean stopService(Intent service); |
| 3115 | |
| 3116 | /** |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 3117 | * @hide like {@link #startService(Intent)} but for a specific user. |
| 3118 | */ |
Christopher Tate | 42a386b | 2016-11-07 12:21:21 -0800 | [diff] [blame] | 3119 | @Nullable |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 3120 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 3121 | @UnsupportedAppUsage |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 3122 | public abstract ComponentName startServiceAsUser(Intent service, UserHandle user); |
| 3123 | |
| 3124 | /** |
| 3125 | * @hide like {@link #stopService(Intent)} but for a specific user. |
| 3126 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 3127 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 3128 | public abstract boolean stopServiceAsUser(Intent service, UserHandle user); |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 3129 | |
Dianne Hackborn | 7767eac | 2012-08-23 18:25:40 -0700 | [diff] [blame] | 3130 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3131 | * Connect to an application service, creating it if needed. This defines |
| 3132 | * a dependency between your application and the service. The given |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 3133 | * <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] | 3134 | * told if it dies and restarts. The service will be considered required |
| 3135 | * by the system only for as long as the calling context exists. For |
| 3136 | * example, if this Context is an Activity that is stopped, the service will |
| 3137 | * not be required to continue running until the Activity is resumed. |
| 3138 | * |
Christopher Tate | 5d73b6d | 2017-10-06 16:15:34 -0700 | [diff] [blame] | 3139 | * <p>If the service does not support binding, it may return {@code null} from |
| 3140 | * its {@link android.app.Service#onBind(Intent) onBind()} method. If it does, then |
| 3141 | * the ServiceConnection's |
| 3142 | * {@link ServiceConnection#onNullBinding(ComponentName) onNullBinding()} method |
| 3143 | * will be invoked instead of |
| 3144 | * {@link ServiceConnection#onServiceConnected(ComponentName, IBinder) onServiceConnected()}. |
| 3145 | * |
| 3146 | * <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] | 3147 | * have permission to bind to the given service. |
| 3148 | * |
Christopher Tate | 5d73b6d | 2017-10-06 16:15:34 -0700 | [diff] [blame] | 3149 | * <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] | 3150 | * {@link BroadcastReceiver} component</em>. A pattern you can use to |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 3151 | * 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] | 3152 | * {@link #startService} with the arguments containing the command to be |
| 3153 | * sent, with the service calling its |
| 3154 | * {@link android.app.Service#stopSelf(int)} method when done executing |
| 3155 | * that command. See the API demo App/Service/Service Start Arguments |
| 3156 | * Controller for an illustration of this. It is okay, however, to use |
Ken Wakasa | f76a50c | 2012-03-09 19:56:35 +0900 | [diff] [blame] | 3157 | * 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] | 3158 | * {@link #registerReceiver}, since the lifetime of this BroadcastReceiver |
| 3159 | * is tied to another object (the one that registered it).</p> |
| 3160 | * |
Mark Lu | 94ebbe0 | 2016-12-13 16:29:51 -0800 | [diff] [blame] | 3161 | * @param service Identifies the service to connect to. The Intent must |
| 3162 | * specify an explicit component name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3163 | * @param conn Receives information as the service is started and stopped. |
Christopher Tate | 79b3317 | 2012-06-18 14:54:21 -0700 | [diff] [blame] | 3164 | * This must be a valid ServiceConnection object; it must not be null. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3165 | * @param flags Operation options for the binding. May be 0, |
Dianne Hackborn | c68c913 | 2011-07-29 01:25:18 -0700 | [diff] [blame] | 3166 | * {@link #BIND_AUTO_CREATE}, {@link #BIND_DEBUG_UNBIND}, |
| 3167 | * {@link #BIND_NOT_FOREGROUND}, {@link #BIND_ABOVE_CLIENT}, |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3168 | * {@link #BIND_ALLOW_OOM_MANAGEMENT}, {@link #BIND_WAIVE_PRIORITY}. |
| 3169 | * {@link #BIND_IMPORTANT}, or |
| 3170 | * {@link #BIND_ADJUST_WITH_ACTIVITY}. |
Kevin Hufnagle | 34acbc9b | 2017-06-29 15:58:48 -0700 | [diff] [blame] | 3171 | * @return {@code true} if the system is in the process of bringing up a |
| 3172 | * service that your client has permission to bind to; {@code false} |
| 3173 | * if the system couldn't find the service or if your client doesn't |
| 3174 | * have permission to bind to it. If this value is {@code true}, you |
| 3175 | * should later call {@link #unbindService} to release the |
| 3176 | * connection. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3177 | * |
Christopher Tate | 08992ac | 2017-03-21 11:37:06 -0700 | [diff] [blame] | 3178 | * @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] | 3179 | * or the service can not be found. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3180 | * |
| 3181 | * @see #unbindService |
| 3182 | * @see #startService |
| 3183 | * @see #BIND_AUTO_CREATE |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3184 | * @see #BIND_DEBUG_UNBIND |
| 3185 | * @see #BIND_NOT_FOREGROUND |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3186 | * @see #BIND_ABOVE_CLIENT |
| 3187 | * @see #BIND_ALLOW_OOM_MANAGEMENT |
| 3188 | * @see #BIND_WAIVE_PRIORITY |
| 3189 | * @see #BIND_IMPORTANT |
| 3190 | * @see #BIND_ADJUST_WITH_ACTIVITY |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3191 | */ |
Tor Norbye | 788fc2b | 2015-07-05 16:10:42 -0700 | [diff] [blame] | 3192 | public abstract boolean bindService(@RequiresPermission Intent service, |
| 3193 | @NonNull ServiceConnection conn, @BindServiceFlags int flags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3194 | |
| 3195 | /** |
Bo Liu | 58a5766 | 2019-03-06 20:21:45 +0000 | [diff] [blame] | 3196 | * Same as {@link #bindService(Intent, ServiceConnection, int)} with executor to control |
| 3197 | * ServiceConnection callbacks. |
| 3198 | * @param executor Callbacks on ServiceConnection will be called on executor. Must use same |
| 3199 | * instance for the same instance of ServiceConnection. |
| 3200 | */ |
| 3201 | public boolean bindService(@RequiresPermission @NonNull Intent service, |
| 3202 | @BindServiceFlags int flags, @NonNull @CallbackExecutor Executor executor, |
| 3203 | @NonNull ServiceConnection conn) { |
| 3204 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 3205 | } |
| 3206 | |
| 3207 | /** |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3208 | * Variation of {@link #bindService} that, in the specific case of isolated |
| 3209 | * services, allows the caller to generate multiple instances of a service |
Dianne Hackborn | cc67f96 | 2019-04-29 16:32:44 -0700 | [diff] [blame] | 3210 | * from a single component declaration. In other words, you can use this to bind |
| 3211 | * to a service that has specified {@link android.R.attr#isolatedProcess} and, in |
| 3212 | * addition to the existing behavior of running in an isolated process, you can |
| 3213 | * also through the arguments here have the system bring up multiple concurrent |
| 3214 | * processes hosting their own instances of that service. The <var>instanceName</var> |
| 3215 | * you provide here identifies the different instances, and you can use |
| 3216 | * {@link #updateServiceGroup(ServiceConnection, int, int)} to tell the system how it |
| 3217 | * should manage each of these instances. |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3218 | * |
| 3219 | * @param service Identifies the service to connect to. The Intent must |
| 3220 | * specify an explicit component name. |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3221 | * @param flags Operation options for the binding as per {@link #bindService}. |
| 3222 | * @param instanceName Unique identifier for the service instance. Each unique |
Robert Sesek | e3a5bc6 | 2019-04-22 17:43:03 -0400 | [diff] [blame] | 3223 | * name here will result in a different service instance being created. Identifiers |
| 3224 | * must only contain ASCII letters, digits, underscores, and periods. |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3225 | * @return Returns success of binding as per {@link #bindService}. |
Bo Liu | 58a5766 | 2019-03-06 20:21:45 +0000 | [diff] [blame] | 3226 | * @param executor Callbacks on ServiceConnection will be called on executor. |
| 3227 | * Must use same instance for the same instance of ServiceConnection. |
| 3228 | * @param conn Receives information as the service is started and stopped. |
| 3229 | * This must be a valid ServiceConnection object; it must not be null. |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3230 | * |
| 3231 | * @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] | 3232 | * @throws IllegalArgumentException If the instanceName is invalid. |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3233 | * |
| 3234 | * @see #bindService |
Dianne Hackborn | cc67f96 | 2019-04-29 16:32:44 -0700 | [diff] [blame] | 3235 | * @see #updateServiceGroup |
| 3236 | * @see android.R.attr#isolatedProcess |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3237 | */ |
Adrian Roos | ebc927c | 2019-02-28 16:21:18 +0100 | [diff] [blame] | 3238 | public boolean bindIsolatedService(@RequiresPermission @NonNull Intent service, |
Bo Liu | 58a5766 | 2019-03-06 20:21:45 +0000 | [diff] [blame] | 3239 | @BindServiceFlags int flags, @NonNull String instanceName, |
| 3240 | @NonNull @CallbackExecutor Executor executor, @NonNull ServiceConnection conn) { |
Adrian Roos | fe6aeaf | 2019-01-22 16:58:56 +0100 | [diff] [blame] | 3241 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 3242 | } |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3243 | |
| 3244 | /** |
kholoud mohamed | da3ae49 | 2019-12-31 15:06:11 +0000 | [diff] [blame] | 3245 | * Binds to a service in the given {@code user} in the same manner as |
| 3246 | * {@link #bindService(Intent, ServiceConnection, int)}. |
| 3247 | * |
| 3248 | * <p>If the given {@code user} is in the same profile group and the target package is the |
| 3249 | * same as the caller, {@code android.Manifest.permission.INTERACT_ACROSS_PROFILES} is |
| 3250 | * sufficient. Otherwise, requires {@code android.Manifest.permission.INTERACT_ACROSS_USERS} |
| 3251 | * for interacting with other users. |
| 3252 | * |
| 3253 | * @param service Identifies the service to connect to. The Intent must |
| 3254 | * specify an explicit component name. |
| 3255 | * @param conn Receives information as the service is started and stopped. |
| 3256 | * This must be a valid ServiceConnection object; it must not be null. |
| 3257 | * @param flags Operation options for the binding. May be 0, |
| 3258 | * {@link #BIND_AUTO_CREATE}, {@link #BIND_DEBUG_UNBIND}, |
| 3259 | * {@link #BIND_NOT_FOREGROUND}, {@link #BIND_ABOVE_CLIENT}, |
| 3260 | * {@link #BIND_ALLOW_OOM_MANAGEMENT}, {@link #BIND_WAIVE_PRIORITY}. |
| 3261 | * {@link #BIND_IMPORTANT}, or |
| 3262 | * {@link #BIND_ADJUST_WITH_ACTIVITY}. |
| 3263 | * @return {@code true} if the system is in the process of bringing up a |
| 3264 | * service that your client has permission to bind to; {@code false} |
| 3265 | * if the system couldn't find the service. If this value is {@code true}, you |
| 3266 | * should later call {@link #unbindService} to release the |
| 3267 | * connection. |
| 3268 | * |
| 3269 | * @throws SecurityException if the client does not have the required permission to bind. |
Amith Yamasani | 37ce3a8 | 2012-02-06 12:04:42 -0800 | [diff] [blame] | 3270 | */ |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3271 | @SuppressWarnings("unused") |
kholoud mohamed | da3ae49 | 2019-12-31 15:06:11 +0000 | [diff] [blame] | 3272 | @RequiresPermission(anyOf = { |
| 3273 | android.Manifest.permission.INTERACT_ACROSS_USERS, |
| 3274 | android.Manifest.permission.INTERACT_ACROSS_PROFILES |
| 3275 | }) |
| 3276 | public boolean bindServiceAsUser( |
| 3277 | @NonNull @RequiresPermission Intent service, @NonNull ServiceConnection conn, int flags, |
| 3278 | @NonNull UserHandle user) { |
Amith Yamasani | 37ce3a8 | 2012-02-06 12:04:42 -0800 | [diff] [blame] | 3279 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 3280 | } |
| 3281 | |
| 3282 | /** |
Dianne Hackborn | 27b4d94 | 2018-11-12 15:01:40 -0800 | [diff] [blame] | 3283 | * Same as {@link #bindServiceAsUser(Intent, ServiceConnection, int, UserHandle)}, but with an |
Adrian Roos | 691546e | 2016-02-09 10:13:41 -0800 | [diff] [blame] | 3284 | * explicit non-null Handler to run the ServiceConnection callbacks on. |
| 3285 | * |
| 3286 | * @hide |
| 3287 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 3288 | @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) |
Mathew Inwood | 7bcc174 | 2019-07-04 11:39:42 +0100 | [diff] [blame] | 3289 | @UnsupportedAppUsage(trackingBug = 136728678) |
Adrian Roos | 691546e | 2016-02-09 10:13:41 -0800 | [diff] [blame] | 3290 | public boolean bindServiceAsUser(Intent service, ServiceConnection conn, int flags, |
| 3291 | Handler handler, UserHandle user) { |
| 3292 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 3293 | } |
| 3294 | |
| 3295 | /** |
Dianne Hackborn | a631d56 | 2018-11-20 15:58:15 -0800 | [diff] [blame] | 3296 | * For a service previously bound with {@link #bindService} or a related method, change |
| 3297 | * how the system manages that service's process in relation to other processes. This |
| 3298 | * doesn't modify the original bind flags that were passed in when binding, but adjusts |
| 3299 | * how the process will be managed in some cases based on those flags. Currently only |
| 3300 | * works on isolated processes (will be ignored for non-isolated processes). |
| 3301 | * |
Dianne Hackborn | 2f55e5a | 2018-11-30 16:31:31 -0800 | [diff] [blame] | 3302 | * <p>Note that this call does not take immediate effect, but will be applied the next |
| 3303 | * time the impacted process is adjusted for some other reason. Typically you would |
| 3304 | * call this before then calling a new {@link #bindIsolatedService} on the service |
| 3305 | * of interest, with that binding causing the process to be shuffled accordingly.</p> |
| 3306 | * |
Dianne Hackborn | a631d56 | 2018-11-20 15:58:15 -0800 | [diff] [blame] | 3307 | * @param conn The connection interface previously supplied to bindService(). This |
| 3308 | * parameter must not be null. |
| 3309 | * @param group A group to put this connection's process in. Upon calling here, this |
| 3310 | * will override any previous group that was set for that process. The group |
| 3311 | * tells the system about processes that are logically grouped together, so |
| 3312 | * should be managed as one unit of importance (such as when being considered |
| 3313 | * a recently used app). All processes in the same app with the same group |
| 3314 | * are considered to be related. Supplying 0 reverts to the default behavior |
| 3315 | * of not grouping. |
| 3316 | * @param importance Additional importance of the processes within a group. Upon calling |
Dianne Hackborn | cc67f96 | 2019-04-29 16:32:44 -0700 | [diff] [blame] | 3317 | * here, this will override any previous importance that was set for that |
| 3318 | * process. The most important process is 0, and higher values are |
| 3319 | * successively less important. You can view this as describing how |
| 3320 | * to order the processes in an array, with the processes at the end of |
| 3321 | * the array being the least important. This value has no meaning besides |
| 3322 | * indicating how processes should be ordered in that array one after the |
| 3323 | * other. This provides a way to fine-tune the system's process killing, |
| 3324 | * guiding it to kill processes at the end of the array first. |
| 3325 | * |
| 3326 | * @see #bindIsolatedService |
Dianne Hackborn | a631d56 | 2018-11-20 15:58:15 -0800 | [diff] [blame] | 3327 | */ |
Adrian Roos | fe6aeaf | 2019-01-22 16:58:56 +0100 | [diff] [blame] | 3328 | public void updateServiceGroup(@NonNull ServiceConnection conn, int group, |
| 3329 | int importance) { |
| 3330 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 3331 | } |
Dianne Hackborn | a631d56 | 2018-11-20 15:58:15 -0800 | [diff] [blame] | 3332 | |
| 3333 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3334 | * Disconnect from an application service. You will no longer receive |
| 3335 | * calls as the service is restarted, and the service is now allowed to |
| 3336 | * stop at any time. |
| 3337 | * |
| 3338 | * @param conn The connection interface previously supplied to |
Christopher Tate | 79b3317 | 2012-06-18 14:54:21 -0700 | [diff] [blame] | 3339 | * bindService(). This parameter must not be null. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3340 | * |
| 3341 | * @see #bindService |
| 3342 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3343 | public abstract void unbindService(@NonNull ServiceConnection conn); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3344 | |
| 3345 | /** |
| 3346 | * Start executing an {@link android.app.Instrumentation} class. The given |
| 3347 | * Instrumentation component will be run by killing its target application |
| 3348 | * (if currently running), starting the target process, instantiating the |
| 3349 | * instrumentation component, and then letting it drive the application. |
| 3350 | * |
| 3351 | * <p>This function is not synchronous -- it returns as soon as the |
| 3352 | * instrumentation has started and while it is running. |
| 3353 | * |
| 3354 | * <p>Instrumentation is normally only allowed to run against a package |
| 3355 | * that is either unsigned or signed with a signature that the |
| 3356 | * the instrumentation package is also signed with (ensuring the target |
| 3357 | * trusts the instrumentation). |
| 3358 | * |
| 3359 | * @param className Name of the Instrumentation component to be run. |
| 3360 | * @param profileFile Optional path to write profiling data as the |
| 3361 | * instrumentation runs, or null for no profiling. |
| 3362 | * @param arguments Additional optional arguments to pass to the |
| 3363 | * instrumentation, or null. |
| 3364 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 3365 | * @return {@code true} if the instrumentation was successfully started, |
| 3366 | * else {@code false} if it could not be found. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3367 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3368 | public abstract boolean startInstrumentation(@NonNull ComponentName className, |
| 3369 | @Nullable String profileFile, @Nullable Bundle arguments); |
| 3370 | |
| 3371 | /** @hide */ |
Jeff Sharkey | 5db9a91 | 2017-12-08 17:32:32 -0700 | [diff] [blame] | 3372 | @StringDef(suffix = { "_SERVICE" }, value = { |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3373 | POWER_SERVICE, |
| 3374 | WINDOW_SERVICE, |
| 3375 | LAYOUT_INFLATER_SERVICE, |
| 3376 | ACCOUNT_SERVICE, |
| 3377 | ACTIVITY_SERVICE, |
| 3378 | ALARM_SERVICE, |
| 3379 | NOTIFICATION_SERVICE, |
| 3380 | ACCESSIBILITY_SERVICE, |
| 3381 | CAPTIONING_SERVICE, |
| 3382 | KEYGUARD_SERVICE, |
| 3383 | LOCATION_SERVICE, |
| 3384 | //@hide: COUNTRY_DETECTOR, |
| 3385 | SEARCH_SERVICE, |
| 3386 | SENSOR_SERVICE, |
Chad Brubaker | 90f391f | 2018-10-19 10:26:19 -0700 | [diff] [blame] | 3387 | SENSOR_PRIVACY_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3388 | STORAGE_SERVICE, |
Jeff Sharkey | e8cece9 | 2017-01-04 11:33:33 -0700 | [diff] [blame] | 3389 | STORAGE_STATS_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3390 | WALLPAPER_SERVICE, |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 3391 | TIME_ZONE_RULES_MANAGER_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3392 | VIBRATOR_SERVICE, |
| 3393 | //@hide: STATUS_BAR_SERVICE, |
| 3394 | CONNECTIVITY_SERVICE, |
Chalard Jean | 8c141bd | 2018-12-04 20:20:56 +0900 | [diff] [blame] | 3395 | //@hide: IP_MEMORY_STORE_SERVICE, |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 3396 | IPSEC_SERVICE, |
Benedict Wong | 50b4443 | 2019-11-01 16:46:28 -0700 | [diff] [blame] | 3397 | VPN_MANAGEMENT_SERVICE, |
Benedict Wong | 99a4841 | 2018-11-09 14:45:34 -0800 | [diff] [blame] | 3398 | TEST_NETWORK_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3399 | //@hide: UPDATE_LOCK_SERVICE, |
| 3400 | //@hide: NETWORKMANAGEMENT_SERVICE, |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3401 | NETWORK_STATS_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3402 | //@hide: NETWORK_POLICY_SERVICE, |
| 3403 | WIFI_SERVICE, |
Etan Cohen | 0413327 | 2016-10-26 11:22:06 -0700 | [diff] [blame] | 3404 | WIFI_AWARE_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3405 | WIFI_P2P_SERVICE, |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 3406 | WIFI_SCANNING_SERVICE, |
Robert Quattlebaum | 87a7104 | 2017-05-15 15:45:20 -0700 | [diff] [blame] | 3407 | //@hide: LOWPAN_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3408 | //@hide: WIFI_RTT_SERVICE, |
Lorenzo Colitti | bd8a374 | 2014-05-22 11:51:27 -0700 | [diff] [blame] | 3409 | //@hide: ETHERNET_SERVICE, |
Etan Cohen | 46efb48 | 2017-12-07 13:50:57 -0800 | [diff] [blame] | 3410 | WIFI_RTT_RANGING_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3411 | NSD_SERVICE, |
| 3412 | AUDIO_SERVICE, |
Ilya Matyukhin | e4675b3 | 2019-11-07 16:07:19 -0800 | [diff] [blame] | 3413 | AUTH_SERVICE, |
Jim Miller | ce7eb6d | 2015-04-03 19:29:13 -0700 | [diff] [blame] | 3414 | FINGERPRINT_SERVICE, |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 3415 | //@hide: FACE_SERVICE, |
Kevin Chyn | 05c2150 | 2018-09-18 13:07:19 -0700 | [diff] [blame] | 3416 | BIOMETRIC_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3417 | MEDIA_ROUTER_SERVICE, |
| 3418 | TELEPHONY_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3419 | TELEPHONY_SUBSCRIPTION_SERVICE, |
Jonathan Basseri | 9a1c9b6 | 2015-02-25 13:01:52 -0800 | [diff] [blame] | 3420 | CARRIER_CONFIG_SERVICE, |
hyunhae.lee | 75fdafa | 2019-07-19 22:08:41 +0900 | [diff] [blame] | 3421 | EUICC_SERVICE, |
Sarah Chin | 4affb51 | 2020-01-10 16:09:11 -0800 | [diff] [blame] | 3422 | MMS_SERVICE, |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 3423 | TELECOM_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3424 | CLIPBOARD_SERVICE, |
| 3425 | INPUT_METHOD_SERVICE, |
| 3426 | TEXT_SERVICES_MANAGER_SERVICE, |
Abodunrinwa Toki | 3de110b | 2017-05-04 16:29:04 +0100 | [diff] [blame] | 3427 | TEXT_CLASSIFICATION_SERVICE, |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 3428 | APPWIDGET_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3429 | //@hide: VOICE_INTERACTION_MANAGER_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3430 | //@hide: BACKUP_SERVICE, |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 3431 | ROLLBACK_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3432 | DROPBOX_SERVICE, |
Dianne Hackborn | 1958e5e | 2015-06-12 18:11:41 -0700 | [diff] [blame] | 3433 | //@hide: DEVICE_IDLE_CONTROLLER, |
Kweku Adams | e371b09 | 2019-11-22 10:50:48 -0800 | [diff] [blame] | 3434 | //@hide: POWER_WHITELIST_MANAGER, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3435 | DEVICE_POLICY_SERVICE, |
| 3436 | UI_MODE_SERVICE, |
| 3437 | DOWNLOAD_SERVICE, |
| 3438 | NFC_SERVICE, |
| 3439 | BLUETOOTH_SERVICE, |
| 3440 | //@hide: SIP_SERVICE, |
| 3441 | USB_SERVICE, |
Amith Yamasani | 4f58263 | 2014-02-19 14:31:52 -0800 | [diff] [blame] | 3442 | LAUNCHER_APPS_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3443 | //@hide: SERIAL_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3444 | //@hide: HDMI_CONTROL_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3445 | INPUT_SERVICE, |
| 3446 | DISPLAY_SERVICE, |
Christine Franks | 39b0311 | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 3447 | //@hide COLOR_DISPLAY_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3448 | USER_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3449 | RESTRICTIONS_SERVICE, |
| 3450 | APP_OPS_SERVICE, |
Hai Zhang | b777668 | 2018-09-25 15:10:57 -0700 | [diff] [blame] | 3451 | ROLE_SERVICE, |
Hai Zhang | a4959e5 | 2019-03-06 12:21:07 -0800 | [diff] [blame] | 3452 | //@hide ROLE_CONTROLLER_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3453 | CAMERA_SERVICE, |
atrost | de54a8ac | 2019-08-15 16:53:01 +0100 | [diff] [blame] | 3454 | //@hide: PLATFORM_COMPAT_SERVICE, |
atrost | 8748835 | 2019-10-10 19:27:31 +0100 | [diff] [blame] | 3455 | //@hide: PLATFORM_COMPAT_NATIVE_SERVICE, |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 3456 | PRINT_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3457 | CONSUMER_IR_SERVICE, |
| 3458 | //@hide: TRUST_SERVICE, |
| 3459 | TV_INPUT_SERVICE, |
Amy | 06a551e | 2019-11-07 13:44:33 -0800 | [diff] [blame] | 3460 | //@hide: TV_TUNER_RESOURCE_MGR_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3461 | //@hide: NETWORK_SCORE_SERVICE, |
| 3462 | USAGE_STATS_SERVICE, |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 3463 | MEDIA_SESSION_SERVICE, |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 3464 | BATTERY_SERVICE, |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 3465 | JOB_SCHEDULER_SERVICE, |
Tor Norbye | bf44ce2 | 2015-02-12 11:47:32 -0800 | [diff] [blame] | 3466 | //@hide: PERSISTENT_DATA_BLOCK_SERVICE, |
Andrew Scull | 3b8b46f | 2017-02-13 18:12:15 +0000 | [diff] [blame] | 3467 | //@hide: OEM_LOCK_SERVICE, |
Michael Wright | 446e019 | 2014-12-22 09:38:43 -0800 | [diff] [blame] | 3468 | MEDIA_PROJECTION_SERVICE, |
Mike Lockwood | 67f8e8b | 2014-12-01 13:54:59 -0800 | [diff] [blame] | 3469 | MIDI_SERVICE, |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 3470 | RADIO_SERVICE, |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 3471 | HARDWARE_PROPERTIES_SERVICE, |
Arunesh Mishra | a772e5f | 2016-01-25 10:33:11 -0800 | [diff] [blame] | 3472 | //@hide: SOUND_TRIGGER_SERVICE, |
Makoto Onuki | 6f7362d9 | 2016-03-04 13:39:41 -0800 | [diff] [blame] | 3473 | SHORTCUT_SERVICE, |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 3474 | //@hide: CONTEXTHUB_SERVICE, |
Joe Onorato | 1754d74 | 2016-11-21 17:51:35 -0800 | [diff] [blame] | 3475 | SYSTEM_HEALTH_SERVICE, |
Tor Norbye | 8246c07 | 2017-07-07 10:21:09 -0700 | [diff] [blame] | 3476 | //@hide: INCIDENT_SERVICE, |
Joe Onorato | e21ab7e | 2018-12-18 15:00:25 -0800 | [diff] [blame] | 3477 | //@hide: INCIDENT_COMPANION_SERVICE, |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 3478 | //@hide: STATS_COMPANION_SERVICE, |
Tony Mak | 9240c7f | 2017-12-29 11:02:02 +0000 | [diff] [blame] | 3479 | COMPANION_DEVICE_SERVICE, |
Tao Bao | 07342dc | 2017-01-24 15:08:21 -0800 | [diff] [blame] | 3480 | CROSS_PROFILE_APPS_SERVICE, |
| 3481 | //@hide: SYSTEM_UPDATE_SERVICE, |
Neil Fuller | feeee68 | 2018-05-30 14:35:24 +0100 | [diff] [blame] | 3482 | //@hide: TIME_DETECTOR_SERVICE, |
Neil Fuller | 3e3b540 | 2019-11-07 15:35:05 +0000 | [diff] [blame] | 3483 | //@hide: TIME_ZONE_DETECTOR_SERVICE, |
Philip P. Moltmann | 039678e | 2018-09-18 13:04:38 -0700 | [diff] [blame] | 3484 | PERMISSION_SERVICE, |
Ivailo Karamanolev | 090d02c | 2020-01-09 17:02:49 +0100 | [diff] [blame] | 3485 | LIGHTS_SERVICE, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 3486 | }) |
| 3487 | @Retention(RetentionPolicy.SOURCE) |
| 3488 | public @interface ServiceName {} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3489 | |
| 3490 | /** |
| 3491 | * Return the handle to a system-level service by name. The class of the |
| 3492 | * returned object varies by the requested name. Currently available names |
| 3493 | * are: |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3494 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3495 | * <dl> |
| 3496 | * <dt> {@link #WINDOW_SERVICE} ("window") |
| 3497 | * <dd> The top-level window manager in which you can place custom |
Andrii Kulian | 5877c7d | 2020-01-29 16:57:32 -0800 | [diff] [blame] | 3498 | * windows. The returned object is a {@link android.view.WindowManager}. Must only be obtained |
| 3499 | * from a visual context such as Activity or a Context created with |
| 3500 | * {@link #createWindowContext(int, Bundle)}, which are adjusted to the configuration and |
| 3501 | * visual bounds of an area on screen. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3502 | * <dt> {@link #LAYOUT_INFLATER_SERVICE} ("layout_inflater") |
| 3503 | * <dd> A {@link android.view.LayoutInflater} for inflating layout resources |
Andrii Kulian | 5877c7d | 2020-01-29 16:57:32 -0800 | [diff] [blame] | 3504 | * in this context. Must only be obtained from a visual context such as Activity or a Context |
| 3505 | * created with {@link #createWindowContext(int, Bundle)}, which are adjusted to the |
| 3506 | * configuration and visual bounds of an area on screen. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3507 | * <dt> {@link #ACTIVITY_SERVICE} ("activity") |
| 3508 | * <dd> A {@link android.app.ActivityManager} for interacting with the |
| 3509 | * global activity state of the system. |
Andrii Kulian | 5877c7d | 2020-01-29 16:57:32 -0800 | [diff] [blame] | 3510 | * <dt> {@link #WALLPAPER_SERVICE} ("wallpaper") |
| 3511 | * <dd> A {@link android.service.wallpaper.WallpaperService} for accessing wallpapers in this |
| 3512 | * context. Must only be obtained from a visual context such as Activity or a Context created |
| 3513 | * with {@link #createWindowContext(int, Bundle)}, which are adjusted to the configuration and |
| 3514 | * visual bounds of an area on screen. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3515 | * <dt> {@link #POWER_SERVICE} ("power") |
| 3516 | * <dd> A {@link android.os.PowerManager} for controlling power |
| 3517 | * management. |
| 3518 | * <dt> {@link #ALARM_SERVICE} ("alarm") |
| 3519 | * <dd> A {@link android.app.AlarmManager} for receiving intents at the |
| 3520 | * time of your choosing. |
| 3521 | * <dt> {@link #NOTIFICATION_SERVICE} ("notification") |
| 3522 | * <dd> A {@link android.app.NotificationManager} for informing the user |
| 3523 | * of background events. |
| 3524 | * <dt> {@link #KEYGUARD_SERVICE} ("keyguard") |
| 3525 | * <dd> A {@link android.app.KeyguardManager} for controlling keyguard. |
| 3526 | * <dt> {@link #LOCATION_SERVICE} ("location") |
| 3527 | * <dd> A {@link android.location.LocationManager} for controlling location |
| 3528 | * (e.g., GPS) updates. |
| 3529 | * <dt> {@link #SEARCH_SERVICE} ("search") |
| 3530 | * <dd> A {@link android.app.SearchManager} for handling search. |
| 3531 | * <dt> {@link #VIBRATOR_SERVICE} ("vibrator") |
| 3532 | * <dd> A {@link android.os.Vibrator} for interacting with the vibrator |
| 3533 | * hardware. |
Sudheer Shanka | 09b0ee6 | 2019-10-03 14:45:15 -0700 | [diff] [blame] | 3534 | * <dt> {@link #CONNECTIVITY_SERVICE} ("connectivity") |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3535 | * <dd> A {@link android.net.ConnectivityManager ConnectivityManager} for |
| 3536 | * handling management of network connections. |
Nathan Harold | d999d22 | 2017-09-11 19:53:33 -0700 | [diff] [blame] | 3537 | * <dt> {@link #IPSEC_SERVICE} ("ipsec") |
| 3538 | * <dd> A {@link android.net.IpSecManager IpSecManager} for managing IPSec on |
| 3539 | * sockets and networks. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3540 | * <dt> {@link #WIFI_SERVICE} ("wifi") |
Paul Stewart | 0e164b1 | 2016-08-08 10:20:13 -0700 | [diff] [blame] | 3541 | * <dd> A {@link android.net.wifi.WifiManager WifiManager} for management of Wi-Fi |
| 3542 | * connectivity. On releases before NYC, it should only be obtained from an application |
| 3543 | * context, and not from any other derived context to avoid memory leaks within the calling |
| 3544 | * process. |
Etan Cohen | 6a4b323 | 2017-01-09 21:47:32 -0800 | [diff] [blame] | 3545 | * <dt> {@link #WIFI_AWARE_SERVICE} ("wifiaware") |
| 3546 | * <dd> A {@link android.net.wifi.aware.WifiAwareManager WifiAwareManager} for management of |
| 3547 | * Wi-Fi Aware discovery and connectivity. |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 3548 | * <dt> {@link #WIFI_P2P_SERVICE} ("wifip2p") |
| 3549 | * <dd> A {@link android.net.wifi.p2p.WifiP2pManager WifiP2pManager} for management of |
| 3550 | * Wi-Fi Direct connectivity. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3551 | * <dt> {@link #INPUT_METHOD_SERVICE} ("input_method") |
| 3552 | * <dd> An {@link android.view.inputmethod.InputMethodManager InputMethodManager} |
| 3553 | * for management of input methods. |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 3554 | * <dt> {@link #UI_MODE_SERVICE} ("uimode") |
| 3555 | * <dd> An {@link android.app.UiModeManager} for controlling UI modes. |
Steve Howard | 7083c42 | 2010-07-28 16:01:23 -0700 | [diff] [blame] | 3556 | * <dt> {@link #DOWNLOAD_SERVICE} ("download") |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 3557 | * <dd> A {@link android.app.DownloadManager} for requesting HTTP downloads |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 3558 | * <dt> {@link #BATTERY_SERVICE} ("batterymanager") |
Todd Poynor | 99f7e12 | 2014-04-15 16:03:42 -0700 | [diff] [blame] | 3559 | * <dd> A {@link android.os.BatteryManager} for managing battery state |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 3560 | * <dt> {@link #JOB_SCHEDULER_SERVICE} ("taskmanager") |
| 3561 | * <dd> A {@link android.app.job.JobScheduler} for managing scheduled tasks |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3562 | * <dt> {@link #NETWORK_STATS_SERVICE} ("netstats") |
| 3563 | * <dd> A {@link android.app.usage.NetworkStatsManager NetworkStatsManager} for querying network |
| 3564 | * usage statistics. |
Polina Bondarenko | 8333c73 | 2016-03-09 18:08:42 +0100 | [diff] [blame] | 3565 | * <dt> {@link #HARDWARE_PROPERTIES_SERVICE} ("hardware_properties") |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 3566 | * <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] | 3567 | * </dl> |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3568 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3569 | * <p>Note: System services obtained via this API may be closely associated with |
| 3570 | * the Context in which they are obtained from. In general, do not share the |
| 3571 | * service objects between various different contexts (Activities, Applications, |
| 3572 | * Services, Providers, etc.) |
| 3573 | * |
Svet Ganov | 8f90bcc | 2017-12-22 23:29:24 -0800 | [diff] [blame] | 3574 | * <p>Note: Instant apps, for which {@link PackageManager#isInstantApp()} returns true, |
| 3575 | * 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] | 3576 | * {@link #FINGERPRINT_SERVICE}, {@link #KEYGUARD_SERVICE}, {@link #SHORTCUT_SERVICE}, |
| 3577 | * {@link #USB_SERVICE}, {@link #WALLPAPER_SERVICE}, {@link #WIFI_P2P_SERVICE}, |
| 3578 | * {@link #WIFI_SERVICE}, {@link #WIFI_AWARE_SERVICE}. For these services this method will |
| 3579 | * 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] | 3580 | * check whether the result of this method is {@code null}. |
| 3581 | * |
| 3582 | * <p>Note: When implementing this method, keep in mind that new services can be added on newer |
| 3583 | * Android releases, so if you're looking for just the explicit names mentioned above, make sure |
| 3584 | * to return {@code null} when you don't recognize the name — if you throw a |
| 3585 | * {@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] | 3586 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3587 | * @param name The name of the desired service. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3588 | * |
Felipe Leme | 4685b86 | 2019-03-06 10:32:33 -0800 | [diff] [blame] | 3589 | * @return The service or {@code null} if the name does not exist. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3590 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3591 | * @see #WINDOW_SERVICE |
| 3592 | * @see android.view.WindowManager |
| 3593 | * @see #LAYOUT_INFLATER_SERVICE |
| 3594 | * @see android.view.LayoutInflater |
| 3595 | * @see #ACTIVITY_SERVICE |
| 3596 | * @see android.app.ActivityManager |
| 3597 | * @see #POWER_SERVICE |
| 3598 | * @see android.os.PowerManager |
| 3599 | * @see #ALARM_SERVICE |
| 3600 | * @see android.app.AlarmManager |
| 3601 | * @see #NOTIFICATION_SERVICE |
| 3602 | * @see android.app.NotificationManager |
| 3603 | * @see #KEYGUARD_SERVICE |
| 3604 | * @see android.app.KeyguardManager |
| 3605 | * @see #LOCATION_SERVICE |
| 3606 | * @see android.location.LocationManager |
| 3607 | * @see #SEARCH_SERVICE |
| 3608 | * @see android.app.SearchManager |
| 3609 | * @see #SENSOR_SERVICE |
| 3610 | * @see android.hardware.SensorManager |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 3611 | * @see #STORAGE_SERVICE |
San Mehat | b104340 | 2010-02-05 08:26:50 -0800 | [diff] [blame] | 3612 | * @see android.os.storage.StorageManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3613 | * @see #VIBRATOR_SERVICE |
| 3614 | * @see android.os.Vibrator |
| 3615 | * @see #CONNECTIVITY_SERVICE |
| 3616 | * @see android.net.ConnectivityManager |
| 3617 | * @see #WIFI_SERVICE |
| 3618 | * @see android.net.wifi.WifiManager |
| 3619 | * @see #AUDIO_SERVICE |
| 3620 | * @see android.media.AudioManager |
Dianne Hackborn | b58b8f8 | 2012-06-11 15:08:39 -0700 | [diff] [blame] | 3621 | * @see #MEDIA_ROUTER_SERVICE |
| 3622 | * @see android.media.MediaRouter |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3623 | * @see #TELEPHONY_SERVICE |
| 3624 | * @see android.telephony.TelephonyManager |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 3625 | * @see #TELEPHONY_SUBSCRIPTION_SERVICE |
| 3626 | * @see android.telephony.SubscriptionManager |
Jonathan Basseri | 9a1c9b6 | 2015-02-25 13:01:52 -0800 | [diff] [blame] | 3627 | * @see #CARRIER_CONFIG_SERVICE |
| 3628 | * @see android.telephony.CarrierConfigManager |
hyunhae.lee | 75fdafa | 2019-07-19 22:08:41 +0900 | [diff] [blame] | 3629 | * @see #EUICC_SERVICE |
| 3630 | * @see android.telephony.euicc.EuiccManager |
Sarah Chin | 4affb51 | 2020-01-10 16:09:11 -0800 | [diff] [blame] | 3631 | * @see #MMS_SERVICE |
| 3632 | * @see android.telephony.MmsManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3633 | * @see #INPUT_METHOD_SERVICE |
| 3634 | * @see android.view.inputmethod.InputMethodManager |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 3635 | * @see #UI_MODE_SERVICE |
| 3636 | * @see android.app.UiModeManager |
Steve Howard | 7083c42 | 2010-07-28 16:01:23 -0700 | [diff] [blame] | 3637 | * @see #DOWNLOAD_SERVICE |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 3638 | * @see android.app.DownloadManager |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 3639 | * @see #BATTERY_SERVICE |
| 3640 | * @see android.os.BatteryManager |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 3641 | * @see #JOB_SCHEDULER_SERVICE |
| 3642 | * @see android.app.job.JobScheduler |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3643 | * @see #NETWORK_STATS_SERVICE |
| 3644 | * @see android.app.usage.NetworkStatsManager |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 3645 | * @see android.os.HardwarePropertiesManager |
| 3646 | * @see #HARDWARE_PROPERTIES_SERVICE |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3647 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 3648 | public abstract @Nullable Object getSystemService(@ServiceName @NonNull String name); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3649 | |
| 3650 | /** |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3651 | * Return the handle to a system-level service by class. |
| 3652 | * <p> |
| 3653 | * Currently available classes are: |
| 3654 | * {@link android.view.WindowManager}, {@link android.view.LayoutInflater}, |
| 3655 | * {@link android.app.ActivityManager}, {@link android.os.PowerManager}, |
| 3656 | * {@link android.app.AlarmManager}, {@link android.app.NotificationManager}, |
| 3657 | * {@link android.app.KeyguardManager}, {@link android.location.LocationManager}, |
| 3658 | * {@link android.app.SearchManager}, {@link android.os.Vibrator}, |
| 3659 | * {@link android.net.ConnectivityManager}, |
| 3660 | * {@link android.net.wifi.WifiManager}, |
| 3661 | * {@link android.media.AudioManager}, {@link android.media.MediaRouter}, |
| 3662 | * {@link android.telephony.TelephonyManager}, {@link android.telephony.SubscriptionManager}, |
| 3663 | * {@link android.view.inputmethod.InputMethodManager}, |
| 3664 | * {@link android.app.UiModeManager}, {@link android.app.DownloadManager}, |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 3665 | * {@link android.os.BatteryManager}, {@link android.app.job.JobScheduler}, |
| 3666 | * {@link android.app.usage.NetworkStatsManager}. |
Felipe Leme | 4685b86 | 2019-03-06 10:32:33 -0800 | [diff] [blame] | 3667 | * </p> |
| 3668 | * |
| 3669 | * <p> |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3670 | * Note: System services obtained via this API may be closely associated with |
| 3671 | * the Context in which they are obtained from. In general, do not share the |
| 3672 | * service objects between various different contexts (Activities, Applications, |
| 3673 | * Services, Providers, etc.) |
| 3674 | * </p> |
| 3675 | * |
Svet Ganov | 8f90bcc | 2017-12-22 23:29:24 -0800 | [diff] [blame] | 3676 | * <p>Note: Instant apps, for which {@link PackageManager#isInstantApp()} returns true, |
| 3677 | * 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] | 3678 | * {@link #FINGERPRINT_SERVICE}, {@link #KEYGUARD_SERVICE}, {@link #SHORTCUT_SERVICE}, |
| 3679 | * {@link #USB_SERVICE}, {@link #WALLPAPER_SERVICE}, {@link #WIFI_P2P_SERVICE}, |
| 3680 | * {@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] | 3681 | * return {@code null}. Generally, if you are running as an instant app you should always |
| 3682 | * check whether the result of this method is {@code null}. |
| 3683 | * </p> |
Svet Ganov | 8f90bcc | 2017-12-22 23:29:24 -0800 | [diff] [blame] | 3684 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3685 | * @param serviceClass The class of the desired service. |
Felipe Leme | 4685b86 | 2019-03-06 10:32:33 -0800 | [diff] [blame] | 3686 | * @return The service or {@code null} if the class is not a supported system service. Note: |
| 3687 | * <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] | 3688 | */ |
| 3689 | @SuppressWarnings("unchecked") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 3690 | public final @Nullable <T> T getSystemService(@NonNull Class<T> serviceClass) { |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3691 | // Because subclasses may override getSystemService(String) we cannot |
| 3692 | // perform a lookup by class alone. We must first map the class to its |
| 3693 | // service name then invoke the string-based method. |
| 3694 | String serviceName = getSystemServiceName(serviceClass); |
| 3695 | return serviceName != null ? (T)getSystemService(serviceName) : null; |
| 3696 | } |
| 3697 | |
| 3698 | /** |
| 3699 | * Gets the name of the system-level service that is represented by the specified class. |
| 3700 | * |
| 3701 | * @param serviceClass The class of the desired service. |
| 3702 | * @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] | 3703 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 3704 | public abstract @Nullable String getSystemServiceName(@NonNull Class<?> serviceClass); |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 3705 | |
| 3706 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3707 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3708 | * {@link android.os.PowerManager} for controlling power management, |
| 3709 | * including "wake locks," which let you keep the device on while |
| 3710 | * you're running long tasks. |
| 3711 | */ |
| 3712 | public static final String POWER_SERVICE = "power"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3713 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3714 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3715 | * Use with {@link #getSystemService(String)} to retrieve a |
Tao Bao | e8a403d | 2015-12-31 07:44:55 -0800 | [diff] [blame] | 3716 | * {@link android.os.RecoverySystem} for accessing the recovery system |
| 3717 | * service. |
| 3718 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3719 | * @see #getSystemService(String) |
Tao Bao | e8a403d | 2015-12-31 07:44:55 -0800 | [diff] [blame] | 3720 | * @hide |
| 3721 | */ |
| 3722 | public static final String RECOVERY_SERVICE = "recovery"; |
| 3723 | |
| 3724 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3725 | * Use with {@link #getSystemService(String)} to retrieve a |
Tao Bao | 07342dc | 2017-01-24 15:08:21 -0800 | [diff] [blame] | 3726 | * {@link android.os.SystemUpdateManager} for accessing the system update |
| 3727 | * manager service. |
| 3728 | * |
| 3729 | * @see #getSystemService(String) |
| 3730 | * @hide |
| 3731 | */ |
| 3732 | @SystemApi |
| 3733 | public static final String SYSTEM_UPDATE_SERVICE = "system_update"; |
| 3734 | |
| 3735 | /** |
| 3736 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3737 | * {@link android.view.WindowManager} for accessing the system's window |
| 3738 | * manager. |
| 3739 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3740 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3741 | * @see android.view.WindowManager |
| 3742 | */ |
| 3743 | public static final String WINDOW_SERVICE = "window"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3744 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3745 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3746 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3747 | * {@link android.view.LayoutInflater} for inflating layout resources in this |
| 3748 | * context. |
| 3749 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3750 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3751 | * @see android.view.LayoutInflater |
| 3752 | */ |
| 3753 | public static final String LAYOUT_INFLATER_SERVICE = "layout_inflater"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3754 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3755 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3756 | * Use with {@link #getSystemService(String)} to retrieve a |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 3757 | * {@link android.accounts.AccountManager} for receiving intents at a |
| 3758 | * time of your choosing. |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 3759 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3760 | * @see #getSystemService(String) |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 3761 | * @see android.accounts.AccountManager |
| 3762 | */ |
| 3763 | public static final String ACCOUNT_SERVICE = "account"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3764 | |
Fred Quintana | 6030734 | 2009-03-24 22:48:12 -0700 | [diff] [blame] | 3765 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3766 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3767 | * {@link android.app.ActivityManager} for interacting with the global |
| 3768 | * system state. |
| 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.app.ActivityManager |
| 3772 | */ |
| 3773 | public static final String ACTIVITY_SERVICE = "activity"; |
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 |
Wale Ogunwale | 65ebd95 | 2018-04-25 15:41:44 -0700 | [diff] [blame] | 3777 | * {@link android.app.ActivityTaskManager} for interacting with the global system state. |
| 3778 | * |
| 3779 | * @see #getSystemService(String) |
| 3780 | * @see android.app.ActivityTaskManager |
| 3781 | * @hide |
| 3782 | */ |
| 3783 | public static final String ACTIVITY_TASK_SERVICE = "activity_task"; |
| 3784 | |
| 3785 | /** |
| 3786 | * Use with {@link #getSystemService(String)} to retrieve a |
Wale Ogunwale | 6d50dcc | 2018-07-21 23:00:40 -0700 | [diff] [blame] | 3787 | * {@link android.app.UriGrantsManager} for interacting with the global system state. |
| 3788 | * |
| 3789 | * @see #getSystemService(String) |
| 3790 | * @see android.app.UriGrantsManager |
| 3791 | * @hide |
| 3792 | */ |
| 3793 | public static final String URI_GRANTS_SERVICE = "uri_grants"; |
| 3794 | |
| 3795 | /** |
| 3796 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3797 | * {@link android.app.AlarmManager} for receiving intents at a |
| 3798 | * time of your choosing. |
| 3799 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3800 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3801 | * @see android.app.AlarmManager |
| 3802 | */ |
| 3803 | public static final String ALARM_SERVICE = "alarm"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3804 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3805 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3806 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3807 | * {@link android.app.NotificationManager} for informing the user of |
| 3808 | * background events. |
| 3809 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3810 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3811 | * @see android.app.NotificationManager |
| 3812 | */ |
| 3813 | public static final String NOTIFICATION_SERVICE = "notification"; |
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 |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 3817 | * {@link android.view.accessibility.AccessibilityManager} for giving the user |
| 3818 | * feedback for UI events through the registered event listeners. |
| 3819 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3820 | * @see #getSystemService(String) |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 3821 | * @see android.view.accessibility.AccessibilityManager |
| 3822 | */ |
| 3823 | public static final String ACCESSIBILITY_SERVICE = "accessibility"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3824 | |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 3825 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3826 | * Use with {@link #getSystemService(String)} to retrieve a |
Alan Viverette | 69ce69b | 2013-08-29 12:23:48 -0700 | [diff] [blame] | 3827 | * {@link android.view.accessibility.CaptioningManager} for obtaining |
| 3828 | * captioning properties and listening for changes in captioning |
| 3829 | * preferences. |
| 3830 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3831 | * @see #getSystemService(String) |
Alan Viverette | 69ce69b | 2013-08-29 12:23:48 -0700 | [diff] [blame] | 3832 | * @see android.view.accessibility.CaptioningManager |
| 3833 | */ |
| 3834 | public static final String CAPTIONING_SERVICE = "captioning"; |
| 3835 | |
| 3836 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3837 | * Use with {@link #getSystemService(String)} to retrieve a |
kopriva | 5495dbb | 2018-09-13 14:18:34 -0700 | [diff] [blame] | 3838 | * {@link android.app.KeyguardManager} for controlling keyguard. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3839 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3840 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3841 | * @see android.app.KeyguardManager |
| 3842 | */ |
| 3843 | public static final String KEYGUARD_SERVICE = "keyguard"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3844 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3845 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3846 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3847 | * android.location.LocationManager} for controlling location |
| 3848 | * updates. |
| 3849 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3850 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3851 | * @see android.location.LocationManager |
| 3852 | */ |
| 3853 | public static final String LOCATION_SERVICE = "location"; |
Bai Tao | a58a875 | 2010-07-13 15:32:16 +0800 | [diff] [blame] | 3854 | |
| 3855 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3856 | * Use with {@link #getSystemService(String)} to retrieve a |
Bai Tao | a58a875 | 2010-07-13 15:32:16 +0800 | [diff] [blame] | 3857 | * {@link android.location.CountryDetector} for detecting the country that |
| 3858 | * the user is in. |
| 3859 | * |
| 3860 | * @hide |
| 3861 | */ |
Mathew Inwood | 8c854f8 | 2018-09-14 12:35:36 +0100 | [diff] [blame] | 3862 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Bai Tao | a58a875 | 2010-07-13 15:32:16 +0800 | [diff] [blame] | 3863 | public static final String COUNTRY_DETECTOR = "country_detector"; |
| 3864 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3865 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3866 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3867 | * android.app.SearchManager} for handling searches. |
| 3868 | * |
Erik Wolsheimer | ac5cecd | 2017-12-05 13:11:50 -0800 | [diff] [blame] | 3869 | * <p> |
| 3870 | * {@link Configuration#UI_MODE_TYPE_WATCH} does not support |
| 3871 | * {@link android.app.SearchManager}. |
| 3872 | * |
| 3873 | * @see #getSystemService |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3874 | * @see android.app.SearchManager |
| 3875 | */ |
| 3876 | public static final String SEARCH_SERVICE = "search"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3877 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3878 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3879 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3880 | * android.hardware.SensorManager} for accessing sensors. |
| 3881 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3882 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3883 | * @see android.hardware.SensorManager |
| 3884 | */ |
| 3885 | public static final String SENSOR_SERVICE = "sensor"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3886 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3887 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3888 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Chad Brubaker | 90f391f | 2018-10-19 10:26:19 -0700 | [diff] [blame] | 3889 | * android.hardware.SensorPrivacyManager} for accessing sensor privacy |
| 3890 | * functions. |
| 3891 | * |
| 3892 | * @see #getSystemService(String) |
| 3893 | * @see android.hardware.SensorPrivacyManager |
| 3894 | * |
| 3895 | * @hide |
| 3896 | */ |
| 3897 | public static final String SENSOR_PRIVACY_SERVICE = "sensor_privacy"; |
| 3898 | |
| 3899 | /** |
| 3900 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Kenny Root | 02c8730 | 2010-07-01 08:10:18 -0700 | [diff] [blame] | 3901 | * android.os.storage.StorageManager} for accessing system storage |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 3902 | * functions. |
| 3903 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3904 | * @see #getSystemService(String) |
San Mehat | b104340 | 2010-02-05 08:26:50 -0800 | [diff] [blame] | 3905 | * @see android.os.storage.StorageManager |
San Mehat | c9d8175 | 2010-02-01 10:23:27 -0800 | [diff] [blame] | 3906 | */ |
| 3907 | public static final String STORAGE_SERVICE = "storage"; |
| 3908 | |
| 3909 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3910 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Jeff Sharkey | e8cece9 | 2017-01-04 11:33:33 -0700 | [diff] [blame] | 3911 | * android.app.usage.StorageStatsManager} for accessing system storage |
| 3912 | * statistics. |
| 3913 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3914 | * @see #getSystemService(String) |
Jeff Sharkey | e8cece9 | 2017-01-04 11:33:33 -0700 | [diff] [blame] | 3915 | * @see android.app.usage.StorageStatsManager |
| 3916 | */ |
| 3917 | public static final String STORAGE_STATS_SERVICE = "storagestats"; |
| 3918 | |
| 3919 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3920 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3921 | * com.android.server.WallpaperService for accessing wallpapers. |
| 3922 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3923 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3924 | */ |
| 3925 | public static final String WALLPAPER_SERVICE = "wallpaper"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 3926 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3927 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3928 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3929 | * android.os.Vibrator} for interacting with the vibration hardware. |
| 3930 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3931 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3932 | * @see android.os.Vibrator |
| 3933 | */ |
| 3934 | public static final String VIBRATOR_SERVICE = "vibrator"; |
Robert Greenwalt | 9e696c2 | 2010-04-01 14:45:18 -0700 | [diff] [blame] | 3935 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3936 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3937 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3938 | * android.app.StatusBarManager} for interacting with the status bar. |
| 3939 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3940 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3941 | * @see android.app.StatusBarManager |
Evan Laird | edd016f | 2019-01-23 18:36:29 -0500 | [diff] [blame] | 3942 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3943 | * @hide |
| 3944 | */ |
Evan Laird | edd016f | 2019-01-23 18:36:29 -0500 | [diff] [blame] | 3945 | @SystemApi |
Evan Laird | 418ba8f | 2019-04-17 15:55:21 -0400 | [diff] [blame] | 3946 | @TestApi |
Adrian Roos | d38f509 | 2020-01-16 21:20:24 +0100 | [diff] [blame] | 3947 | @SuppressLint("ServiceName") |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3948 | public static final String STATUS_BAR_SERVICE = "statusbar"; |
| 3949 | |
| 3950 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3951 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3952 | * android.net.ConnectivityManager} for handling management of |
| 3953 | * network connections. |
| 3954 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3955 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3956 | * @see android.net.ConnectivityManager |
| 3957 | */ |
| 3958 | public static final String CONNECTIVITY_SERVICE = "connectivity"; |
| 3959 | |
| 3960 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3961 | * Use with {@link #getSystemService(String)} to retrieve a |
Remi NGUYEN VAN | 3193598 | 2019-01-28 11:40:08 +0900 | [diff] [blame] | 3962 | * {@link android.net.INetd} for communicating with the network stack |
| 3963 | * @hide |
| 3964 | * @see #getSystemService(String) |
| 3965 | * @hide |
| 3966 | */ |
| 3967 | @SystemApi |
| 3968 | public static final String NETD_SERVICE = "netd"; |
| 3969 | |
| 3970 | /** |
Remi NGUYEN VAN | 310da6f | 2019-02-14 18:04:20 +0900 | [diff] [blame] | 3971 | * Use with {@link android.os.ServiceManager.getService()} to retrieve a |
Remi NGUYEN VAN | 05f7b5c | 2020-01-07 11:44:14 +0900 | [diff] [blame] | 3972 | * {@link INetworkStackConnector} IBinder for communicating with the network stack |
Remi NGUYEN VAN | c094a54 | 2018-12-07 16:52:24 +0900 | [diff] [blame] | 3973 | * @hide |
Remi NGUYEN VAN | 310da6f | 2019-02-14 18:04:20 +0900 | [diff] [blame] | 3974 | * @see NetworkStackClient |
Remi NGUYEN VAN | c094a54 | 2018-12-07 16:52:24 +0900 | [diff] [blame] | 3975 | */ |
Remi NGUYEN VAN | 05f7b5c | 2020-01-07 11:44:14 +0900 | [diff] [blame] | 3976 | @SystemApi |
| 3977 | @TestApi |
Remi NGUYEN VAN | c094a54 | 2018-12-07 16:52:24 +0900 | [diff] [blame] | 3978 | public static final String NETWORK_STACK_SERVICE = "network_stack"; |
| 3979 | |
| 3980 | /** |
markchien | ae8aa64 | 2019-12-16 20:15:20 +0800 | [diff] [blame] | 3981 | * Use with {@link android.os.ServiceManager.getService()} to retrieve a |
| 3982 | * {@link ITetheringConnector} IBinder for communicating with the tethering service |
| 3983 | * @hide |
| 3984 | * @see TetheringClient |
| 3985 | */ |
| 3986 | @SystemApi |
| 3987 | public static final String TETHERING_SERVICE = "tethering"; |
| 3988 | |
| 3989 | /** |
Remi NGUYEN VAN | c094a54 | 2018-12-07 16:52:24 +0900 | [diff] [blame] | 3990 | * Use with {@link #getSystemService(String)} to retrieve a |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 3991 | * {@link android.net.IpSecManager} for encrypting Sockets or Networks with |
| 3992 | * IPSec. |
| 3993 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 3994 | * @see #getSystemService(String) |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 3995 | */ |
| 3996 | public static final String IPSEC_SERVICE = "ipsec"; |
| 3997 | |
| 3998 | /** |
Benedict Wong | 50b4443 | 2019-11-01 16:46:28 -0700 | [diff] [blame] | 3999 | * Use with {@link #getSystemService(String)} to retrieve a {@link android.net.VpnManager} to |
| 4000 | * manage profiles for the platform built-in VPN. |
| 4001 | * |
| 4002 | * @see #getSystemService(String) |
| 4003 | */ |
| 4004 | public static final String VPN_MANAGEMENT_SERVICE = "vpn_management"; |
| 4005 | |
| 4006 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4007 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Cody Kesting | b12577600 | 2019-12-17 17:21:40 -0800 | [diff] [blame] | 4008 | * android.net.ConnectivityDiagnosticsManager} for performing network connectivity diagnostics |
| 4009 | * as well as receiving network connectivity information from the system. |
| 4010 | * |
| 4011 | * @see #getSystemService(String) |
| 4012 | * @see android.net.ConnectivityDiagnosticsManager |
| 4013 | */ |
| 4014 | public static final String CONNECTIVITY_DIAGNOSTICS_SERVICE = "connectivity_diagnostics"; |
| 4015 | |
| 4016 | /** |
| 4017 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Benedict Wong | 99a4841 | 2018-11-09 14:45:34 -0800 | [diff] [blame] | 4018 | * android.net.TestNetworkManager} for building TUNs and limited-use Networks |
| 4019 | * |
| 4020 | * @see #getSystemService(String) |
| 4021 | * @hide |
| 4022 | */ |
| 4023 | @TestApi public static final String TEST_NETWORK_SERVICE = "test_network"; |
| 4024 | |
| 4025 | /** |
| 4026 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Christopher Tate | 8662cab5 | 2012-02-23 14:59:36 -0800 | [diff] [blame] | 4027 | * android.os.IUpdateLock} for managing runtime sequences that |
| 4028 | * must not be interrupted by headless OTA application or similar. |
| 4029 | * |
| 4030 | * @hide |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4031 | * @see #getSystemService(String) |
Christopher Tate | 8662cab5 | 2012-02-23 14:59:36 -0800 | [diff] [blame] | 4032 | * @see android.os.UpdateLock |
| 4033 | */ |
| 4034 | public static final String UPDATE_LOCK_SERVICE = "updatelock"; |
| 4035 | |
| 4036 | /** |
Dianne Hackborn | 35f72be | 2013-09-16 10:57:39 -0700 | [diff] [blame] | 4037 | * Constant for the internal network management service, not really a Context service. |
Dianne Hackborn | 0a6a80f | 2013-09-16 15:20:27 -0700 | [diff] [blame] | 4038 | * @hide |
San Mehat | d1df8ac | 2010-01-26 06:17:26 -0800 | [diff] [blame] | 4039 | */ |
| 4040 | public static final String NETWORKMANAGEMENT_SERVICE = "network_management"; |
| 4041 | |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 4042 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4043 | * Use with {@link #getSystemService(String)} to retrieve a |
Jason Monk | 8f5f7ff | 2017-10-17 14:12:42 -0400 | [diff] [blame] | 4044 | * {@link com.android.server.slice.SliceManagerService} for managing slices. |
| 4045 | * @hide |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4046 | * @see #getSystemService(String) |
Jason Monk | 8f5f7ff | 2017-10-17 14:12:42 -0400 | [diff] [blame] | 4047 | */ |
| 4048 | public static final String SLICE_SERVICE = "slice"; |
| 4049 | |
| 4050 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4051 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 4052 | * android.app.usage.NetworkStatsManager} for querying network usage stats. |
| 4053 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4054 | * @see #getSystemService(String) |
Zoltan Szatmary-Ban | 9c5dfa5 | 2015-02-23 17:20:20 +0000 | [diff] [blame] | 4055 | * @see android.app.usage.NetworkStatsManager |
| 4056 | */ |
Jeff Sharkey | 7527990 | 2011-05-24 18:39:45 -0700 | [diff] [blame] | 4057 | public static final String NETWORK_STATS_SERVICE = "netstats"; |
| 4058 | /** {@hide} */ |
Aaron Huang | 1aa5ca3 | 2019-12-31 21:48:45 +0800 | [diff] [blame] | 4059 | @SystemApi |
Adrian Roos | d38f509 | 2020-01-16 21:20:24 +0100 | [diff] [blame] | 4060 | @SuppressLint("ServiceName") |
Jeff Sharkey | eedcb95 | 2011-05-17 14:55:15 -0700 | [diff] [blame] | 4061 | public static final String NETWORK_POLICY_SERVICE = "netpolicy"; |
Ricky Wai | 1a6e667 | 2017-10-27 14:46:01 +0100 | [diff] [blame] | 4062 | /** {@hide} */ |
| 4063 | public static final String NETWORK_WATCHLIST_SERVICE = "network_watchlist"; |
Jeff Sharkey | eedcb95 | 2011-05-17 14:55:15 -0700 | [diff] [blame] | 4064 | |
San Mehat | d1df8ac | 2010-01-26 06:17:26 -0800 | [diff] [blame] | 4065 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4066 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4067 | * android.net.wifi.WifiManager} for handling management of |
| 4068 | * Wi-Fi access. |
| 4069 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4070 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4071 | * @see android.net.wifi.WifiManager |
| 4072 | */ |
| 4073 | public static final String WIFI_SERVICE = "wifi"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4074 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4075 | /** |
Etan Cohen | 73450f2 | 2019-12-12 23:29:25 -0800 | [diff] [blame] | 4076 | * Use with {@link #getSystemService(String)} to retrieve a |
Etan Cohen | b9f28bc | 2020-02-09 12:06:56 -0800 | [diff] [blame] | 4077 | * {@link android.net.wifi.wificond.WifiNl80211Manager} for handling management of the |
| 4078 | * Wi-Fi nl802.11 daemon (wificond). |
Etan Cohen | 73450f2 | 2019-12-12 23:29:25 -0800 | [diff] [blame] | 4079 | * |
| 4080 | * @see #getSystemService(String) |
Etan Cohen | b9f28bc | 2020-02-09 12:06:56 -0800 | [diff] [blame] | 4081 | * @see android.net.wifi.wificond.WifiNl80211Manager |
Etan Cohen | 73450f2 | 2019-12-12 23:29:25 -0800 | [diff] [blame] | 4082 | * @hide |
| 4083 | */ |
Roshan Pius | bae9769 | 2020-01-08 14:15:58 -0800 | [diff] [blame] | 4084 | @SystemApi |
Adrian Roos | df747d1 | 2020-01-16 21:20:24 +0100 | [diff] [blame] | 4085 | @SuppressLint("ServiceName") |
Etan Cohen | b9f28bc | 2020-02-09 12:06:56 -0800 | [diff] [blame] | 4086 | public static final String WIFI_NL80211_SERVICE = "wifinl80211"; |
Etan Cohen | 73450f2 | 2019-12-12 23:29:25 -0800 | [diff] [blame] | 4087 | |
| 4088 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4089 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 4090 | * android.net.wifi.p2p.WifiP2pManager} for handling management of |
Irfan Sheriff | 651cdfc | 2011-09-07 00:31:20 -0700 | [diff] [blame] | 4091 | * Wi-Fi peer-to-peer connections. |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 4092 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4093 | * @see #getSystemService(String) |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 4094 | * @see android.net.wifi.p2p.WifiP2pManager |
repo sync | 55bc5f3 | 2011-06-24 14:23:07 -0700 | [diff] [blame] | 4095 | */ |
| 4096 | public static final String WIFI_P2P_SERVICE = "wifip2p"; |
| 4097 | |
| 4098 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4099 | * Use with {@link #getSystemService(String)} to retrieve a |
Etan Cohen | 0413327 | 2016-10-26 11:22:06 -0700 | [diff] [blame] | 4100 | * {@link android.net.wifi.aware.WifiAwareManager} for handling management of |
| 4101 | * Wi-Fi Aware. |
Etan Cohen | 20d329b | 2015-09-29 13:49:02 -0700 | [diff] [blame] | 4102 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4103 | * @see #getSystemService(String) |
Etan Cohen | 0413327 | 2016-10-26 11:22:06 -0700 | [diff] [blame] | 4104 | * @see android.net.wifi.aware.WifiAwareManager |
Etan Cohen | 20d329b | 2015-09-29 13:49:02 -0700 | [diff] [blame] | 4105 | */ |
Etan Cohen | 0413327 | 2016-10-26 11:22:06 -0700 | [diff] [blame] | 4106 | public static final String WIFI_AWARE_SERVICE = "wifiaware"; |
Etan Cohen | 20d329b | 2015-09-29 13:49:02 -0700 | [diff] [blame] | 4107 | |
| 4108 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4109 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 4110 | * android.net.wifi.WifiScanner} for scanning the wifi universe |
| 4111 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4112 | * @see #getSystemService(String) |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 4113 | * @see android.net.wifi.WifiScanner |
| 4114 | * @hide |
| 4115 | */ |
Wei Wang | 35d552f | 2014-07-08 21:37:01 -0700 | [diff] [blame] | 4116 | @SystemApi |
Vinit Deshapnde | 011e1b3 | 2014-05-07 21:09:11 -0700 | [diff] [blame] | 4117 | public static final String WIFI_SCANNING_SERVICE = "wifiscanner"; |
| 4118 | |
| 4119 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4120 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Vinit Deshpande | 7686c06 | 2014-06-30 15:25:01 -0700 | [diff] [blame] | 4121 | * android.net.wifi.RttManager} for ranging devices with wifi |
| 4122 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4123 | * @see #getSystemService(String) |
Vinit Deshpande | 7686c06 | 2014-06-30 15:25:01 -0700 | [diff] [blame] | 4124 | * @see android.net.wifi.RttManager |
| 4125 | * @hide |
| 4126 | */ |
| 4127 | @SystemApi |
Etan Cohen | d0acccd | 2018-01-31 08:36:33 -0800 | [diff] [blame] | 4128 | @Deprecated |
Vinit Deshpande | 7686c06 | 2014-06-30 15:25:01 -0700 | [diff] [blame] | 4129 | public static final String WIFI_RTT_SERVICE = "rttmanager"; |
| 4130 | |
| 4131 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4132 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Etan Cohen | f4062a9 | 2019-04-11 07:00:42 -0700 | [diff] [blame] | 4133 | * android.net.wifi.rtt.WifiRttManager} for ranging devices with wifi. |
Etan Cohen | 17ba472 | 2017-08-21 10:52:17 -0700 | [diff] [blame] | 4134 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4135 | * @see #getSystemService(String) |
Etan Cohen | 17ba472 | 2017-08-21 10:52:17 -0700 | [diff] [blame] | 4136 | * @see android.net.wifi.rtt.WifiRttManager |
Etan Cohen | 17ba472 | 2017-08-21 10:52:17 -0700 | [diff] [blame] | 4137 | */ |
Etan Cohen | 091d777 | 2018-01-04 17:47:37 -0800 | [diff] [blame] | 4138 | public static final String WIFI_RTT_RANGING_SERVICE = "wifirtt"; |
Etan Cohen | 17ba472 | 2017-08-21 10:52:17 -0700 | [diff] [blame] | 4139 | |
| 4140 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4141 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Robert Quattlebaum | 87a7104 | 2017-05-15 15:45:20 -0700 | [diff] [blame] | 4142 | * android.net.lowpan.LowpanManager} for handling management of |
| 4143 | * LoWPAN access. |
| 4144 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4145 | * @see #getSystemService(String) |
Robert Quattlebaum | 87a7104 | 2017-05-15 15:45:20 -0700 | [diff] [blame] | 4146 | * @see android.net.lowpan.LowpanManager |
| 4147 | * |
| 4148 | * @hide |
| 4149 | */ |
| 4150 | public static final String LOWPAN_SERVICE = "lowpan"; |
| 4151 | |
| 4152 | /** |
Remi NGUYEN VAN | 84229e0 | 2020-01-24 22:57:09 +0900 | [diff] [blame] | 4153 | * Use with {@link #getSystemService(String)} to retrieve a {@link android.net.EthernetManager} |
| 4154 | * for handling management of Ethernet access. |
Lorenzo Colitti | f9ff2c9 | 2014-05-21 16:32:11 -0700 | [diff] [blame] | 4155 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4156 | * @see #getSystemService(String) |
Dianne Hackborn | fee756f | 2014-07-16 17:31:10 -0700 | [diff] [blame] | 4157 | * @see android.net.EthernetManager |
Lorenzo Colitti | f9ff2c9 | 2014-05-21 16:32:11 -0700 | [diff] [blame] | 4158 | * |
| 4159 | * @hide |
| 4160 | */ |
Remi NGUYEN VAN | 84229e0 | 2020-01-24 22:57:09 +0900 | [diff] [blame] | 4161 | @SystemApi |
| 4162 | @TestApi |
Lorenzo Colitti | f9ff2c9 | 2014-05-21 16:32:11 -0700 | [diff] [blame] | 4163 | public static final String ETHERNET_SERVICE = "ethernet"; |
| 4164 | |
| 4165 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4166 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Irfan Sheriff | 60309fc | 2012-04-24 14:52:37 -0700 | [diff] [blame] | 4167 | * android.net.nsd.NsdManager} for handling management of network service |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 4168 | * discovery |
| 4169 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4170 | * @see #getSystemService(String) |
Irfan Sheriff | 60309fc | 2012-04-24 14:52:37 -0700 | [diff] [blame] | 4171 | * @see android.net.nsd.NsdManager |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 4172 | */ |
| 4173 | public static final String NSD_SERVICE = "servicediscovery"; |
| 4174 | |
Irfan Sheriff | 7d024d3 | 2012-03-22 17:01:39 -0700 | [diff] [blame] | 4175 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4176 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4177 | * {@link android.media.AudioManager} for handling management of volume, |
| 4178 | * ringer modes and audio routing. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4179 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4180 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4181 | * @see android.media.AudioManager |
| 4182 | */ |
| 4183 | public static final String AUDIO_SERVICE = "audio"; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4184 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4185 | /** |
Ilya Matyukhin | e4675b3 | 2019-11-07 16:07:19 -0800 | [diff] [blame] | 4186 | * AuthService orchestrates biometric and PIN/pattern/password authentication. |
| 4187 | * |
| 4188 | * BiometricService was split into two services, AuthService and BiometricService, where |
| 4189 | * AuthService is the high level service that orchestrates all types of authentication, and |
| 4190 | * BiometricService is a lower layer responsible only for biometric authentication. |
| 4191 | * |
| 4192 | * Ideally we should have renamed BiometricManager to AuthManager, because it logically |
| 4193 | * corresponds to AuthService. However, because BiometricManager is a public API, we kept |
| 4194 | * the old name but changed the internal implementation to use AuthService. |
| 4195 | * |
| 4196 | * As of now, the AUTH_SERVICE constant is only used to identify the service in |
| 4197 | * SystemServiceRegistry and SELinux. To obtain the manager for AUTH_SERVICE, one should use |
| 4198 | * BIOMETRIC_SERVICE with {@link #getSystemService(String)} to retrieve a |
| 4199 | * {@link android.hardware.biometrics.BiometricManager} |
| 4200 | * |
| 4201 | * Map of the two services and their managers: |
| 4202 | * [Service] [Manager] |
| 4203 | * AuthService BiometricManager |
| 4204 | * BiometricService N/A |
| 4205 | * |
| 4206 | * @hide |
| 4207 | */ |
| 4208 | public static final String AUTH_SERVICE = "auth"; |
| 4209 | |
| 4210 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4211 | * Use with {@link #getSystemService(String)} to retrieve a |
Jim Miller | ce7eb6d | 2015-04-03 19:29:13 -0700 | [diff] [blame] | 4212 | * {@link android.hardware.fingerprint.FingerprintManager} for handling management |
Jim Miller | 08fa40c | 2014-04-29 18:18:47 -0700 | [diff] [blame] | 4213 | * of fingerprints. |
| 4214 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4215 | * @see #getSystemService(String) |
Jim Miller | ce7eb6d | 2015-04-03 19:29:13 -0700 | [diff] [blame] | 4216 | * @see android.hardware.fingerprint.FingerprintManager |
Jim Miller | 08fa40c | 2014-04-29 18:18:47 -0700 | [diff] [blame] | 4217 | */ |
| 4218 | public static final String FINGERPRINT_SERVICE = "fingerprint"; |
| 4219 | |
| 4220 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4221 | * Use with {@link #getSystemService(String)} to retrieve a |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 4222 | * {@link android.hardware.face.FaceManager} for handling management |
| 4223 | * of face authentication. |
| 4224 | * |
| 4225 | * @hide |
| 4226 | * @see #getSystemService |
| 4227 | * @see android.hardware.face.FaceManager |
| 4228 | */ |
| 4229 | public static final String FACE_SERVICE = "face"; |
| 4230 | |
| 4231 | /** |
Kevin Chyn | 05c2150 | 2018-09-18 13:07:19 -0700 | [diff] [blame] | 4232 | * Use with {@link #getSystemService(String)} to retrieve a |
Kevin Chyn | 51676d2 | 2018-11-05 18:00:43 -0800 | [diff] [blame] | 4233 | * {@link android.hardware.iris.IrisManager} for handling management |
| 4234 | * of iris authentication. |
| 4235 | * |
| 4236 | * @hide |
| 4237 | * @see #getSystemService |
| 4238 | * @see android.hardware.iris.IrisManager |
| 4239 | */ |
| 4240 | public static final String IRIS_SERVICE = "iris"; |
| 4241 | |
| 4242 | /** |
| 4243 | * Use with {@link #getSystemService(String)} to retrieve a |
Ilya Matyukhin | e4675b3 | 2019-11-07 16:07:19 -0800 | [diff] [blame] | 4244 | * {@link android.hardware.biometrics.BiometricManager} for handling |
| 4245 | * biometric and PIN/pattern/password authentication. |
Kevin Chyn | 05c2150 | 2018-09-18 13:07:19 -0700 | [diff] [blame] | 4246 | * |
| 4247 | * @see #getSystemService |
| 4248 | * @see android.hardware.biometrics.BiometricManager |
| 4249 | */ |
| 4250 | public static final String BIOMETRIC_SERVICE = "biometric"; |
| 4251 | |
| 4252 | /** |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 4253 | * Use with {@link #getSystemService} to retrieve a |
Dianne Hackborn | b58b8f8 | 2012-06-11 15:08:39 -0700 | [diff] [blame] | 4254 | * {@link android.media.MediaRouter} for controlling and managing |
| 4255 | * routing of media. |
| 4256 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4257 | * @see #getSystemService(String) |
Dianne Hackborn | b58b8f8 | 2012-06-11 15:08:39 -0700 | [diff] [blame] | 4258 | * @see android.media.MediaRouter |
| 4259 | */ |
| 4260 | public static final String MEDIA_ROUTER_SERVICE = "media_router"; |
| 4261 | |
| 4262 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4263 | * Use with {@link #getSystemService(String)} to retrieve a |
RoboErik | 42ea7ee | 2014-05-16 16:27:35 -0700 | [diff] [blame] | 4264 | * {@link android.media.session.MediaSessionManager} for managing media Sessions. |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 4265 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4266 | * @see #getSystemService(String) |
RoboErik | 42ea7ee | 2014-05-16 16:27:35 -0700 | [diff] [blame] | 4267 | * @see android.media.session.MediaSessionManager |
RoboErik | 01fe661 | 2014-02-13 14:19:04 -0800 | [diff] [blame] | 4268 | */ |
| 4269 | public static final String MEDIA_SESSION_SERVICE = "media_session"; |
| 4270 | |
| 4271 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4272 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4273 | * {@link android.telephony.TelephonyManager} for handling management the |
| 4274 | * telephony features of the device. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4275 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4276 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4277 | * @see android.telephony.TelephonyManager |
| 4278 | */ |
| 4279 | public static final String TELEPHONY_SERVICE = "phone"; |
| 4280 | |
| 4281 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4282 | * Use with {@link #getSystemService(String)} to retrieve a |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 4283 | * {@link android.telephony.SubscriptionManager} for handling management the |
| 4284 | * telephony subscriptions of the device. |
| 4285 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4286 | * @see #getSystemService(String) |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 4287 | * @see android.telephony.SubscriptionManager |
| 4288 | */ |
| 4289 | public static final String TELEPHONY_SUBSCRIPTION_SERVICE = "telephony_subscription_service"; |
| 4290 | |
| 4291 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4292 | * Use with {@link #getSystemService(String)} to retrieve a |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 4293 | * {@link android.telecom.TelecomManager} to manage telecom-related features |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 4294 | * of the device. |
| 4295 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4296 | * @see #getSystemService(String) |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 4297 | * @see android.telecom.TelecomManager |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 4298 | */ |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 4299 | public static final String TELECOM_SERVICE = "telecom"; |
Yorke Lee | b4ce143 | 2014-06-09 13:53:23 -0700 | [diff] [blame] | 4300 | |
| 4301 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4302 | * Use with {@link #getSystemService(String)} to retrieve a |
Jonathan Basseri | 9a1c9b6 | 2015-02-25 13:01:52 -0800 | [diff] [blame] | 4303 | * {@link android.telephony.CarrierConfigManager} for reading carrier configuration values. |
| 4304 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4305 | * @see #getSystemService(String) |
Jonathan Basseri | 9a1c9b6 | 2015-02-25 13:01:52 -0800 | [diff] [blame] | 4306 | * @see android.telephony.CarrierConfigManager |
| 4307 | */ |
| 4308 | public static final String CARRIER_CONFIG_SERVICE = "carrier_config"; |
| 4309 | |
| 4310 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4311 | * Use with {@link #getSystemService(String)} to retrieve a |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 4312 | * {@link android.telephony.euicc.EuiccManager} to manage the device eUICC (embedded SIM). |
| 4313 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4314 | * @see #getSystemService(String) |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 4315 | * @see android.telephony.euicc.EuiccManager |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 4316 | */ |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 4317 | public static final String EUICC_SERVICE = "euicc"; |
Jeff Davidson | 35cda39 | 2017-02-27 09:46:00 -0800 | [diff] [blame] | 4318 | |
| 4319 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4320 | * Use with {@link #getSystemService(String)} to retrieve a |
Holly Jiuyu Sun | 5c11024 | 2017-12-21 18:44:59 -0800 | [diff] [blame] | 4321 | * {@link android.telephony.euicc.EuiccCardManager} to access the device eUICC (embedded SIM). |
| 4322 | * |
| 4323 | * @see #getSystemService(String) |
| 4324 | * @see android.telephony.euicc.EuiccCardManager |
Holly Jiuyu Sun | 5c11024 | 2017-12-21 18:44:59 -0800 | [diff] [blame] | 4325 | * @hide |
| 4326 | */ |
Holly Jiuyu Sun | 4f73b9c | 2017-12-12 20:17:09 -0800 | [diff] [blame] | 4327 | @SystemApi |
| 4328 | public static final String EUICC_CARD_SERVICE = "euicc_card"; |
Holly Jiuyu Sun | 5c11024 | 2017-12-21 18:44:59 -0800 | [diff] [blame] | 4329 | |
| 4330 | /** |
| 4331 | * Use with {@link #getSystemService(String)} to retrieve a |
Sarah Chin | 4affb51 | 2020-01-10 16:09:11 -0800 | [diff] [blame] | 4332 | * {@link android.telephony.MmsManager} to send/receive MMS messages. |
| 4333 | * |
| 4334 | * @see #getSystemService(String) |
| 4335 | * @see android.telephony.MmsManager |
| 4336 | */ |
| 4337 | public static final String MMS_SERVICE = "mms"; |
| 4338 | |
| 4339 | /** |
| 4340 | * Use with {@link #getSystemService(String)} to retrieve a |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 4341 | * {@link android.content.ClipboardManager} for accessing and modifying |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4342 | * the contents of the global clipboard. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4343 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4344 | * @see #getSystemService(String) |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 4345 | * @see android.content.ClipboardManager |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4346 | */ |
| 4347 | public static final String CLIPBOARD_SERVICE = "clipboard"; |
| 4348 | |
| 4349 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4350 | * Use with {@link #getSystemService(String)} to retrieve a |
Abodunrinwa Toki | f001fef | 2017-01-04 23:51:42 +0000 | [diff] [blame] | 4351 | * {@link TextClassificationManager} for text classification services. |
Abodunrinwa Toki | 8158af5 | 2016-11-23 20:41:09 +0000 | [diff] [blame] | 4352 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4353 | * @see #getSystemService(String) |
Abodunrinwa Toki | f001fef | 2017-01-04 23:51:42 +0000 | [diff] [blame] | 4354 | * @see TextClassificationManager |
Abodunrinwa Toki | 8158af5 | 2016-11-23 20:41:09 +0000 | [diff] [blame] | 4355 | */ |
| 4356 | public static final String TEXT_CLASSIFICATION_SERVICE = "textclassification"; |
| 4357 | |
| 4358 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4359 | * Use with {@link #getSystemService(String)} to retrieve a |
Alex Salo | 5f5b5f4 | 2019-02-27 10:49:00 -0800 | [diff] [blame] | 4360 | * {@link com.android.server.attention.AttentionManagerService} for attention services. |
| 4361 | * |
| 4362 | * @see #getSystemService(String) |
| 4363 | * @see android.server.attention.AttentionManagerService |
| 4364 | * @hide |
| 4365 | */ |
| 4366 | public static final String ATTENTION_SERVICE = "attention"; |
| 4367 | |
| 4368 | /** |
| 4369 | * Use with {@link #getSystemService(String)} to retrieve a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4370 | * {@link android.view.inputmethod.InputMethodManager} for accessing input |
| 4371 | * methods. |
| 4372 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4373 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4374 | */ |
| 4375 | public static final String INPUT_METHOD_SERVICE = "input_method"; |
| 4376 | |
| 4377 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4378 | * Use with {@link #getSystemService(String)} to retrieve a |
satok | 988323c | 2011-06-22 16:38:13 +0900 | [diff] [blame] | 4379 | * {@link android.view.textservice.TextServicesManager} for accessing |
| 4380 | * text services. |
| 4381 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4382 | * @see #getSystemService(String) |
satok | 988323c | 2011-06-22 16:38:13 +0900 | [diff] [blame] | 4383 | */ |
| 4384 | public static final String TEXT_SERVICES_MANAGER_SERVICE = "textservices"; |
| 4385 | |
| 4386 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4387 | * Use with {@link #getSystemService(String)} to retrieve a |
Dan Egnor | e38d58b | 2009-12-30 19:29:03 -0800 | [diff] [blame] | 4388 | * {@link android.appwidget.AppWidgetManager} for accessing AppWidgets. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4389 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4390 | * @see #getSystemService(String) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4391 | */ |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 4392 | public static final String APPWIDGET_SERVICE = "appwidget"; |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 4393 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4394 | /** |
Dianne Hackborn | 91097de | 2014-04-04 18:02:06 -0700 | [diff] [blame] | 4395 | * Official published name of the (internal) voice interaction manager service. |
| 4396 | * |
| 4397 | * @hide |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4398 | * @see #getSystemService(String) |
Dianne Hackborn | 91097de | 2014-04-04 18:02:06 -0700 | [diff] [blame] | 4399 | */ |
| 4400 | public static final String VOICE_INTERACTION_MANAGER_SERVICE = "voiceinteraction"; |
| 4401 | |
| 4402 | /** |
Felipe Leme | 640f30a | 2017-03-06 15:44:06 -0800 | [diff] [blame] | 4403 | * Official published name of the (internal) autofill service. |
Felipe Leme | 5381aa4 | 2016-10-13 09:02:32 -0700 | [diff] [blame] | 4404 | * |
| 4405 | * @hide |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4406 | * @see #getSystemService(String) |
Felipe Leme | 5381aa4 | 2016-10-13 09:02:32 -0700 | [diff] [blame] | 4407 | */ |
Felipe Leme | 640f30a | 2017-03-06 15:44:06 -0800 | [diff] [blame] | 4408 | public static final String AUTOFILL_MANAGER_SERVICE = "autofill"; |
Felipe Leme | 5381aa4 | 2016-10-13 09:02:32 -0700 | [diff] [blame] | 4409 | |
| 4410 | /** |
Felipe Leme | 749b889 | 2018-12-03 16:30:30 -0800 | [diff] [blame] | 4411 | * Official published name of the content capture service. |
Felipe Leme | e348dc3 | 2018-11-05 12:35:29 -0800 | [diff] [blame] | 4412 | * |
| 4413 | * @hide |
| 4414 | * @see #getSystemService(String) |
| 4415 | */ |
Felipe Leme | a7e4ca6 | 2019-05-23 13:32:40 -0700 | [diff] [blame] | 4416 | @TestApi |
Adrian Roos | d38f509 | 2020-01-16 21:20:24 +0100 | [diff] [blame] | 4417 | @SuppressLint("ServiceName") // TODO: This should be renamed to CONTENT_CAPTURE_SERVICE |
Felipe Leme | 749b889 | 2018-12-03 16:30:30 -0800 | [diff] [blame] | 4418 | public static final String CONTENT_CAPTURE_MANAGER_SERVICE = "content_capture"; |
Felipe Leme | e348dc3 | 2018-11-05 12:35:29 -0800 | [diff] [blame] | 4419 | |
| 4420 | /** |
Winson Chung | 3fb0f25 | 2019-01-08 17:41:55 -0800 | [diff] [blame] | 4421 | * Used for getting content selections and classifications for task snapshots. |
| 4422 | * |
| 4423 | * @hide |
| 4424 | * @see #getSystemService(String) |
| 4425 | */ |
| 4426 | @SystemApi |
| 4427 | public static final String CONTENT_SUGGESTIONS_SERVICE = "content_suggestions"; |
| 4428 | |
| 4429 | /** |
Sunny Goyal | 54e9134 | 2018-11-14 11:59:02 -0800 | [diff] [blame] | 4430 | * Official published name of the app prediction service. |
| 4431 | * |
Felipe Leme | 6378bd4 | 2019-08-14 18:14:55 -0700 | [diff] [blame] | 4432 | * <p><b>NOTE: </b> this service is optional; callers of |
| 4433 | * {@code Context.getSystemServiceName(APP_PREDICTION_SERVICE)} should check for {@code null}. |
| 4434 | * |
Sunny Goyal | 54e9134 | 2018-11-14 11:59:02 -0800 | [diff] [blame] | 4435 | * @hide |
| 4436 | * @see #getSystemService(String) |
| 4437 | */ |
| 4438 | @SystemApi |
| 4439 | public static final String APP_PREDICTION_SERVICE = "app_prediction"; |
| 4440 | |
| 4441 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4442 | * Use with {@link #getSystemService(String)} to access the |
Arunesh Mishra | a772e5f | 2016-01-25 10:33:11 -0800 | [diff] [blame] | 4443 | * {@link com.android.server.voiceinteraction.SoundTriggerService}. |
| 4444 | * |
| 4445 | * @hide |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4446 | * @see #getSystemService(String) |
Arunesh Mishra | a772e5f | 2016-01-25 10:33:11 -0800 | [diff] [blame] | 4447 | */ |
| 4448 | public static final String SOUND_TRIGGER_SERVICE = "soundtrigger"; |
| 4449 | |
Philip P. Moltmann | 039678e | 2018-09-18 13:04:38 -0700 | [diff] [blame] | 4450 | /** |
Ytai Ben-Tsvi | 93c117c86 | 2019-11-25 12:43:28 -0800 | [diff] [blame] | 4451 | * Use with {@link #getSystemService(String)} to access the |
| 4452 | * {@link com.android.server.soundtrigger_middleware.SoundTriggerMiddlewareService}. |
| 4453 | * |
| 4454 | * @hide |
| 4455 | * @see #getSystemService(String) |
| 4456 | */ |
| 4457 | public static final String SOUND_TRIGGER_MIDDLEWARE_SERVICE = "soundtrigger_middleware"; |
| 4458 | |
| 4459 | /** |
Philip P. Moltmann | 039678e | 2018-09-18 13:04:38 -0700 | [diff] [blame] | 4460 | * Official published name of the (internal) permission service. |
| 4461 | * |
| 4462 | * @see #getSystemService(String) |
| 4463 | * @hide |
| 4464 | */ |
Winson | f27394e | 2019-06-07 14:44:40 -0700 | [diff] [blame] | 4465 | @TestApi |
Philip P. Moltmann | 039678e | 2018-09-18 13:04:38 -0700 | [diff] [blame] | 4466 | @SystemApi |
| 4467 | public static final String PERMISSION_SERVICE = "permission"; |
Arunesh Mishra | a772e5f | 2016-01-25 10:33:11 -0800 | [diff] [blame] | 4468 | |
| 4469 | /** |
Philip P. Moltmann | bc054d8 | 2018-12-21 09:41:58 -0800 | [diff] [blame] | 4470 | * Official published name of the (internal) permission controller service. |
| 4471 | * |
| 4472 | * @see #getSystemService(String) |
| 4473 | * @hide |
| 4474 | */ |
| 4475 | public static final String PERMISSION_CONTROLLER_SERVICE = "permission_controller"; |
| 4476 | |
| 4477 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4478 | * Use with {@link #getSystemService(String)} to retrieve an |
Christopher Tate | 4528186 | 2010-03-05 15:46:30 -0800 | [diff] [blame] | 4479 | * {@link android.app.backup.IBackupManager IBackupManager} for communicating |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 4480 | * with the backup mechanism. |
Dianne Hackborn | 7f20543 | 2009-07-28 00:13:47 -0700 | [diff] [blame] | 4481 | * @hide |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 4482 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4483 | * @see #getSystemService(String) |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 4484 | */ |
Christopher Tate | d5cf722 | 2014-07-29 16:53:09 -0700 | [diff] [blame] | 4485 | @SystemApi |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 4486 | public static final String BACKUP_SERVICE = "backup"; |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 4487 | |
| 4488 | /** |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 4489 | * Use with {@link #getSystemService(String)} to retrieve an |
| 4490 | * {@link android.content.rollback.RollbackManager} for communicating |
| 4491 | * with the rollback manager |
| 4492 | * |
| 4493 | * @see #getSystemService(String) |
Richard Uhler | c739c8c | 2018-12-12 11:03:34 +0000 | [diff] [blame] | 4494 | * @hide |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 4495 | */ |
Richard Uhler | 8a97745 | 2019-03-08 13:27:17 +0000 | [diff] [blame] | 4496 | @SystemApi @TestApi |
Richard Uhler | b29f145 | 2018-09-12 16:38:15 +0100 | [diff] [blame] | 4497 | public static final String ROLLBACK_SERVICE = "rollback"; |
| 4498 | |
| 4499 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4500 | * Use with {@link #getSystemService(String)} to retrieve a |
Dan Egnor | 1337b01 | 2010-01-04 11:01:44 -0800 | [diff] [blame] | 4501 | * {@link android.os.DropBoxManager} instance for recording |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 4502 | * diagnostic logs. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4503 | * @see #getSystemService(String) |
Dan Egnor | 9524027 | 2009-10-27 18:23:39 -0700 | [diff] [blame] | 4504 | */ |
| 4505 | public static final String DROPBOX_SERVICE = "dropbox"; |
| 4506 | |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 4507 | /** |
Philip P. Moltmann | f80809f | 2018-04-04 11:20:44 -0700 | [diff] [blame] | 4508 | * System service name for the DeviceIdleManager. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4509 | * @see #getSystemService(String) |
Dianne Hackborn | 1958e5e | 2015-06-12 18:11:41 -0700 | [diff] [blame] | 4510 | * @hide |
| 4511 | */ |
Makoto Onuki | 7d6d9ca | 2019-08-13 11:45:45 -0700 | [diff] [blame] | 4512 | @TestApi |
Adrian Roos | d38f509 | 2020-01-16 21:20:24 +0100 | [diff] [blame] | 4513 | @SuppressLint("ServiceName") // TODO: This should be renamed to DEVICE_IDLE_SERVICE |
Dianne Hackborn | 1958e5e | 2015-06-12 18:11:41 -0700 | [diff] [blame] | 4514 | public static final String DEVICE_IDLE_CONTROLLER = "deviceidle"; |
| 4515 | |
| 4516 | /** |
Kweku Adams | e371b09 | 2019-11-22 10:50:48 -0800 | [diff] [blame] | 4517 | * System service name for the PowerWhitelistManager. |
| 4518 | * |
| 4519 | * @see #getSystemService(String) |
| 4520 | * @hide |
| 4521 | */ |
| 4522 | @TestApi |
Adrian Roos | d38f509 | 2020-01-16 21:20:24 +0100 | [diff] [blame] | 4523 | @SuppressLint("ServiceName") // TODO: This should be renamed to POWER_WHITELIST_SERVICE |
Kweku Adams | e371b09 | 2019-11-22 10:50:48 -0800 | [diff] [blame] | 4524 | public static final String POWER_WHITELIST_MANAGER = "power_whitelist"; |
| 4525 | |
| 4526 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4527 | * Use with {@link #getSystemService(String)} to retrieve a |
Dianne Hackborn | 87bba1e | 2010-02-26 17:25:54 -0800 | [diff] [blame] | 4528 | * {@link android.app.admin.DevicePolicyManager} for working with global |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 4529 | * device policy management. |
| 4530 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4531 | * @see #getSystemService(String) |
Dianne Hackborn | d684784 | 2010-01-12 18:14:19 -0800 | [diff] [blame] | 4532 | */ |
| 4533 | public static final String DEVICE_POLICY_SERVICE = "device_policy"; |
| 4534 | |
| 4535 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4536 | * Use with {@link #getSystemService(String)} to retrieve a |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 4537 | * {@link android.app.UiModeManager} for controlling UI modes. |
| 4538 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4539 | * @see #getSystemService(String) |
Tobias Haamel | 5333288 | 2010-02-18 16:15:43 -0800 | [diff] [blame] | 4540 | */ |
| 4541 | public static final String UI_MODE_SERVICE = "uimode"; |
| 4542 | |
| 4543 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4544 | * Use with {@link #getSystemService(String)} to retrieve a |
Steve Howard | d58429f | 2010-09-27 16:32:39 -0700 | [diff] [blame] | 4545 | * {@link android.app.DownloadManager} for requesting HTTP downloads. |
Steve Howard | a270936 | 2010-07-02 17:12:48 -0700 | [diff] [blame] | 4546 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4547 | * @see #getSystemService(String) |
Steve Howard | a270936 | 2010-07-02 17:12:48 -0700 | [diff] [blame] | 4548 | */ |
| 4549 | public static final String DOWNLOAD_SERVICE = "download"; |
| 4550 | |
| 4551 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4552 | * Use with {@link #getSystemService(String)} to retrieve a |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 4553 | * {@link android.os.BatteryManager} for managing battery state. |
| 4554 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4555 | * @see #getSystemService(String) |
Todd Poynor | e35872d | 2013-12-10 11:57:21 -0800 | [diff] [blame] | 4556 | */ |
| 4557 | public static final String BATTERY_SERVICE = "batterymanager"; |
| 4558 | |
| 4559 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4560 | * Use with {@link #getSystemService(String)} to retrieve a |
Nick Pelly | 50b4d8f | 2010-12-07 22:40:28 -0800 | [diff] [blame] | 4561 | * {@link android.nfc.NfcManager} for using NFC. |
| 4562 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4563 | * @see #getSystemService(String) |
Nick Pelly | 50b4d8f | 2010-12-07 22:40:28 -0800 | [diff] [blame] | 4564 | */ |
| 4565 | public static final String NFC_SERVICE = "nfc"; |
| 4566 | |
| 4567 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4568 | * Use with {@link #getSystemService(String)} to retrieve a |
Florian Salbrechter | 084da9b | 2015-03-25 11:00:55 +0000 | [diff] [blame] | 4569 | * {@link android.bluetooth.BluetoothManager} for using Bluetooth. |
Jaikumar Ganesh | 1abb1cb | 2012-01-25 16:14:50 -0800 | [diff] [blame] | 4570 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4571 | * @see #getSystemService(String) |
Jaikumar Ganesh | 1abb1cb | 2012-01-25 16:14:50 -0800 | [diff] [blame] | 4572 | */ |
| 4573 | public static final String BLUETOOTH_SERVICE = "bluetooth"; |
| 4574 | |
| 4575 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4576 | * Use with {@link #getSystemService(String)} to retrieve a |
Chung-yih Wang | 2d94231 | 2010-08-05 12:17:37 +0800 | [diff] [blame] | 4577 | * {@link android.net.sip.SipManager} for accessing the SIP related service. |
| 4578 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4579 | * @see #getSystemService(String) |
Chung-yih Wang | 2d94231 | 2010-08-05 12:17:37 +0800 | [diff] [blame] | 4580 | */ |
| 4581 | /** @hide */ |
| 4582 | public static final String SIP_SERVICE = "sip"; |
| 4583 | |
| 4584 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4585 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Mike Lockwood | c4308f0 | 2011-03-01 08:04:54 -0800 | [diff] [blame] | 4586 | * 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] | 4587 | * and for controlling this device's behavior as a USB device. |
| 4588 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4589 | * @see #getSystemService(String) |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 4590 | * @see android.hardware.usb.UsbManager |
Mike Lockwood | e7d511e | 2010-12-30 13:39:37 -0500 | [diff] [blame] | 4591 | */ |
| 4592 | public static final String USB_SERVICE = "usb"; |
| 4593 | |
| 4594 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4595 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Kenny Root | f74bfde | 2018-01-18 15:42:48 -0800 | [diff] [blame] | 4596 | * Use with {@link #getSystemService} to retrieve a {@link |
| 4597 | * android.debug.AdbManager} for access to ADB debug functions. |
| 4598 | * |
| 4599 | * @see #getSystemService(String) |
| 4600 | * @see android.debug.AdbManager |
| 4601 | * |
| 4602 | * @hide |
| 4603 | */ |
| 4604 | public static final String ADB_SERVICE = "adb"; |
| 4605 | |
| 4606 | /** |
| 4607 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Mike Lockwood | b01e8bf | 2011-08-29 20:11:07 -0400 | [diff] [blame] | 4608 | * android.hardware.SerialManager} for access to serial ports. |
| 4609 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4610 | * @see #getSystemService(String) |
Dianne Hackborn | 35f72be | 2013-09-16 10:57:39 -0700 | [diff] [blame] | 4611 | * @see android.hardware.SerialManager |
Mike Lockwood | b01e8bf | 2011-08-29 20:11:07 -0400 | [diff] [blame] | 4612 | * |
| 4613 | * @hide |
| 4614 | */ |
| 4615 | public static final String SERIAL_SERVICE = "serial"; |
| 4616 | |
| 4617 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4618 | * Use with {@link #getSystemService(String)} to retrieve a |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 4619 | * {@link android.hardware.hdmi.HdmiControlManager} for controlling and managing |
| 4620 | * HDMI-CEC protocol. |
| 4621 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4622 | * @see #getSystemService(String) |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 4623 | * @see android.hardware.hdmi.HdmiControlManager |
Jinsuk Kim | 66d1eb2 | 2014-06-06 16:12:18 +0900 | [diff] [blame] | 4624 | * @hide |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 4625 | */ |
Jinsuk Kim | 66d1eb2 | 2014-06-06 16:12:18 +0900 | [diff] [blame] | 4626 | @SystemApi |
Jinsuk Kim | 91120c5 | 2014-05-08 17:12:51 +0900 | [diff] [blame] | 4627 | public static final String HDMI_CONTROL_SERVICE = "hdmi_control"; |
Jinsuk Kim | fbcd503 | 2014-03-21 16:25:13 +0900 | [diff] [blame] | 4628 | |
| 4629 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4630 | * Use with {@link #getSystemService(String)} to retrieve a |
Jeff Brown | 9df6e7a | 2012-04-05 11:49:26 -0700 | [diff] [blame] | 4631 | * {@link android.hardware.input.InputManager} for interacting with input devices. |
| 4632 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4633 | * @see #getSystemService(String) |
Jeff Brown | 9df6e7a | 2012-04-05 11:49:26 -0700 | [diff] [blame] | 4634 | * @see android.hardware.input.InputManager |
| 4635 | */ |
| 4636 | public static final String INPUT_SERVICE = "input"; |
| 4637 | |
| 4638 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4639 | * Use with {@link #getSystemService(String)} to retrieve a |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 4640 | * {@link android.hardware.display.DisplayManager} for interacting with display devices. |
| 4641 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4642 | * @see #getSystemService(String) |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 4643 | * @see android.hardware.display.DisplayManager |
| 4644 | */ |
| 4645 | public static final String DISPLAY_SERVICE = "display"; |
| 4646 | |
| 4647 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4648 | * Use with {@link #getSystemService(String)} to retrieve a |
Christine Franks | 39b0311 | 2018-07-03 14:46:07 -0700 | [diff] [blame] | 4649 | * {@link android.hardware.display.ColorDisplayManager} for controlling color transforms. |
| 4650 | * |
| 4651 | * @see #getSystemService(String) |
| 4652 | * @see android.hardware.display.ColorDisplayManager |
| 4653 | * @hide |
| 4654 | */ |
| 4655 | public static final String COLOR_DISPLAY_SERVICE = "color_display"; |
| 4656 | |
| 4657 | /** |
| 4658 | * Use with {@link #getSystemService(String)} to retrieve a |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 4659 | * {@link android.os.UserManager} for managing users on devices that support multiple users. |
| 4660 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4661 | * @see #getSystemService(String) |
Amith Yamasani | 258848d | 2012-08-10 17:06:33 -0700 | [diff] [blame] | 4662 | * @see android.os.UserManager |
| 4663 | */ |
| 4664 | public static final String USER_SERVICE = "user"; |
| 4665 | |
| 4666 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4667 | * Use with {@link #getSystemService(String)} to retrieve a |
Amith Yamasani | 4f58263 | 2014-02-19 14:31:52 -0800 | [diff] [blame] | 4668 | * {@link android.content.pm.LauncherApps} for querying and monitoring launchable apps across |
| 4669 | * profiles of a user. |
| 4670 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4671 | * @see #getSystemService(String) |
Amith Yamasani | 4f58263 | 2014-02-19 14:31:52 -0800 | [diff] [blame] | 4672 | * @see android.content.pm.LauncherApps |
| 4673 | */ |
| 4674 | public static final String LAUNCHER_APPS_SERVICE = "launcherapps"; |
| 4675 | |
| 4676 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4677 | * Use with {@link #getSystemService(String)} to retrieve a |
Amith Yamasani | f20d640 | 2014-05-24 15:34:37 -0700 | [diff] [blame] | 4678 | * {@link android.content.RestrictionsManager} for retrieving application restrictions |
| 4679 | * and requesting permissions for restricted operations. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4680 | * @see #getSystemService(String) |
Amith Yamasani | f20d640 | 2014-05-24 15:34:37 -0700 | [diff] [blame] | 4681 | * @see android.content.RestrictionsManager |
| 4682 | */ |
| 4683 | public static final String RESTRICTIONS_SERVICE = "restrictions"; |
| 4684 | |
| 4685 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4686 | * Use with {@link #getSystemService(String)} to retrieve a |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 4687 | * {@link android.app.AppOpsManager} for tracking application operations |
| 4688 | * on the device. |
| 4689 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4690 | * @see #getSystemService(String) |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 4691 | * @see android.app.AppOpsManager |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 4692 | */ |
| 4693 | public static final String APP_OPS_SERVICE = "appops"; |
| 4694 | |
| 4695 | /** |
Hai Zhang | b777668 | 2018-09-25 15:10:57 -0700 | [diff] [blame] | 4696 | * Use with {@link #getSystemService(String)} to retrieve a {@link android.app.role.RoleManager} |
| 4697 | * for managing roles. |
| 4698 | * |
| 4699 | * @see #getSystemService(String) |
| 4700 | * @see android.app.role.RoleManager |
| 4701 | */ |
| 4702 | public static final String ROLE_SERVICE = "role"; |
| 4703 | |
| 4704 | /** |
Hai Zhang | a4959e5 | 2019-03-06 12:21:07 -0800 | [diff] [blame] | 4705 | * Official published name of the (internal) role controller service. |
| 4706 | * |
| 4707 | * @see #getSystemService(String) |
| 4708 | * @see android.app.role.RoleControllerService |
| 4709 | * |
| 4710 | * @hide |
| 4711 | */ |
| 4712 | public static final String ROLE_CONTROLLER_SERVICE = "role_controller"; |
| 4713 | |
| 4714 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4715 | * Use with {@link #getSystemService(String)} to retrieve a |
Eino-Ville Talvala | 2f1a2e4 | 2013-07-25 17:12:05 -0700 | [diff] [blame] | 4716 | * {@link android.hardware.camera2.CameraManager} for interacting with |
Eino-Ville Talvala | b267554 | 2012-12-12 13:29:45 -0800 | [diff] [blame] | 4717 | * camera devices. |
| 4718 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4719 | * @see #getSystemService(String) |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 4720 | * @see android.hardware.camera2.CameraManager |
Eino-Ville Talvala | b267554 | 2012-12-12 13:29:45 -0800 | [diff] [blame] | 4721 | */ |
| 4722 | public static final String CAMERA_SERVICE = "camera"; |
| 4723 | |
| 4724 | /** |
Svetoslav Ganov | 4b9a4d1 | 2013-06-11 15:20:06 -0700 | [diff] [blame] | 4725 | * {@link android.print.PrintManager} for printing and managing |
Jeff Brown | 511cd35 | 2013-08-23 17:43:37 -0700 | [diff] [blame] | 4726 | * printers and print tasks. |
Svetoslav Ganov | 4b9a4d1 | 2013-06-11 15:20:06 -0700 | [diff] [blame] | 4727 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4728 | * @see #getSystemService(String) |
Svetoslav Ganov | 4b9a4d1 | 2013-06-11 15:20:06 -0700 | [diff] [blame] | 4729 | * @see android.print.PrintManager |
| 4730 | */ |
| 4731 | public static final String PRINT_SERVICE = "print"; |
| 4732 | |
| 4733 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4734 | * Use with {@link #getSystemService(String)} to retrieve a |
Eugene Susla | 6ed45d8 | 2017-01-22 13:52:51 -0800 | [diff] [blame] | 4735 | * {@link android.companion.CompanionDeviceManager} for managing companion devices |
| 4736 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4737 | * @see #getSystemService(String) |
Eugene Susla | 6ed45d8 | 2017-01-22 13:52:51 -0800 | [diff] [blame] | 4738 | * @see android.companion.CompanionDeviceManager |
| 4739 | */ |
Eugene Susla | d7355cc | 2017-04-20 11:14:45 -0700 | [diff] [blame] | 4740 | public static final String COMPANION_DEVICE_SERVICE = "companiondevice"; |
Eugene Susla | 6ed45d8 | 2017-01-22 13:52:51 -0800 | [diff] [blame] | 4741 | |
| 4742 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4743 | * Use with {@link #getSystemService(String)} to retrieve a |
Erik Gilling | 51e95df | 2013-06-26 11:06:51 -0700 | [diff] [blame] | 4744 | * {@link android.hardware.ConsumerIrManager} for transmitting infrared |
| 4745 | * signals from the device. |
| 4746 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4747 | * @see #getSystemService(String) |
Erik Gilling | 51e95df | 2013-06-26 11:06:51 -0700 | [diff] [blame] | 4748 | * @see android.hardware.ConsumerIrManager |
| 4749 | */ |
| 4750 | public static final String CONSUMER_IR_SERVICE = "consumer_ir"; |
| 4751 | |
| 4752 | /** |
Adrian Roos | 82142c2 | 2014-03-27 14:56:59 +0100 | [diff] [blame] | 4753 | * {@link android.app.trust.TrustManager} for managing trust agents. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4754 | * @see #getSystemService(String) |
Adrian Roos | 82142c2 | 2014-03-27 14:56:59 +0100 | [diff] [blame] | 4755 | * @see android.app.trust.TrustManager |
| 4756 | * @hide |
| 4757 | */ |
| 4758 | public static final String TRUST_SERVICE = "trust"; |
| 4759 | |
| 4760 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4761 | * Use with {@link #getSystemService(String)} to retrieve a |
Jae Seo | d5cc4a2 | 2014-05-30 16:57:43 -0700 | [diff] [blame] | 4762 | * {@link android.media.tv.TvInputManager} for interacting with TV inputs |
| 4763 | * on the device. |
Jae Seo | 3957091 | 2014-02-20 18:23:25 -0800 | [diff] [blame] | 4764 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4765 | * @see #getSystemService(String) |
Jae Seo | d5cc4a2 | 2014-05-30 16:57:43 -0700 | [diff] [blame] | 4766 | * @see android.media.tv.TvInputManager |
Jae Seo | 3957091 | 2014-02-20 18:23:25 -0800 | [diff] [blame] | 4767 | */ |
| 4768 | public static final String TV_INPUT_SERVICE = "tv_input"; |
| 4769 | |
| 4770 | /** |
Amy | 06a551e | 2019-11-07 13:44:33 -0800 | [diff] [blame] | 4771 | * Use with {@link #getSystemService(String)} to retrieve a |
| 4772 | * {@link android.media.tv.TunerResourceManager} for interacting with TV |
| 4773 | * tuner resources on the device. |
| 4774 | * |
| 4775 | * @see #getSystemService(String) |
| 4776 | * @see android.media.tv.TunerResourceManager |
| 4777 | * @hide |
| 4778 | */ |
| 4779 | public static final String TV_TUNER_RESOURCE_MGR_SERVICE = "tv_tuner_resource_mgr"; |
| 4780 | |
| 4781 | /** |
Jeff Davidson | b51e0a6 | 2014-04-09 12:38:15 -0700 | [diff] [blame] | 4782 | * {@link android.net.NetworkScoreManager} for managing network scoring. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4783 | * @see #getSystemService(String) |
Jeff Davidson | b51e0a6 | 2014-04-09 12:38:15 -0700 | [diff] [blame] | 4784 | * @see android.net.NetworkScoreManager |
| 4785 | * @hide |
| 4786 | */ |
Jeff Davidson | 5ad2079 | 2014-07-21 13:55:42 -0700 | [diff] [blame] | 4787 | @SystemApi |
Jeff Davidson | b51e0a6 | 2014-04-09 12:38:15 -0700 | [diff] [blame] | 4788 | public static final String NETWORK_SCORE_SERVICE = "network_score"; |
| 4789 | |
| 4790 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4791 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Adam Lesinski | aa60767 | 2014-11-24 11:27:50 -0800 | [diff] [blame] | 4792 | * android.app.usage.UsageStatsManager} for querying device usage stats. |
Dianne Hackborn | e22b3b1 | 2014-05-07 18:06:44 -0700 | [diff] [blame] | 4793 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4794 | * @see #getSystemService(String) |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 4795 | * @see android.app.usage.UsageStatsManager |
Dianne Hackborn | e22b3b1 | 2014-05-07 18:06:44 -0700 | [diff] [blame] | 4796 | */ |
| 4797 | public static final String USAGE_STATS_SERVICE = "usagestats"; |
| 4798 | |
| 4799 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4800 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 4801 | * android.app.job.JobScheduler} instance for managing occasional |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 4802 | * background tasks. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4803 | * @see #getSystemService(String) |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 4804 | * @see android.app.job.JobScheduler |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 4805 | */ |
Christopher Tate | 7060b04 | 2014-06-09 19:50:00 -0700 | [diff] [blame] | 4806 | public static final String JOB_SCHEDULER_SERVICE = "jobscheduler"; |
Christopher Tate | fa380e9 | 2014-05-19 13:46:29 -0700 | [diff] [blame] | 4807 | |
| 4808 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4809 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Andres Morales | 33df937 | 2014-09-26 17:08:59 -0700 | [diff] [blame] | 4810 | * android.service.persistentdata.PersistentDataBlockManager} instance |
| 4811 | * for interacting with a storage device that lives across factory resets. |
| 4812 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4813 | * @see #getSystemService(String) |
Andres Morales | 68d4acd | 2014-07-01 19:40:41 -0700 | [diff] [blame] | 4814 | * @see android.service.persistentdata.PersistentDataBlockManager |
| 4815 | * @hide |
| 4816 | */ |
Andres Morales | 33df937 | 2014-09-26 17:08:59 -0700 | [diff] [blame] | 4817 | @SystemApi |
Andres Morales | 68d4acd | 2014-07-01 19:40:41 -0700 | [diff] [blame] | 4818 | public static final String PERSISTENT_DATA_BLOCK_SERVICE = "persistent_data_block"; |
| 4819 | |
| 4820 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4821 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Andrew Scull | 3b8b46f | 2017-02-13 18:12:15 +0000 | [diff] [blame] | 4822 | * android.service.oemlock.OemLockManager} instance for managing the OEM lock. |
| 4823 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4824 | * @see #getSystemService(String) |
Andrew Scull | 3b8b46f | 2017-02-13 18:12:15 +0000 | [diff] [blame] | 4825 | * @see android.service.oemlock.OemLockManager |
| 4826 | * @hide |
| 4827 | */ |
| 4828 | @SystemApi |
| 4829 | public static final String OEM_LOCK_SERVICE = "oem_lock"; |
| 4830 | |
| 4831 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4832 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 4833 | * android.media.projection.MediaProjectionManager} instance for managing |
| 4834 | * media projection sessions. |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4835 | * @see #getSystemService(String) |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 4836 | * @see android.media.projection.MediaProjectionManager |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 4837 | */ |
| 4838 | public static final String MEDIA_PROJECTION_SERVICE = "media_projection"; |
| 4839 | |
| 4840 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4841 | * Use with {@link #getSystemService(String)} to retrieve a |
Mike Lockwood | b673770 | 2015-02-20 08:28:47 -0800 | [diff] [blame] | 4842 | * {@link android.media.midi.MidiManager} for accessing the MIDI service. |
Mike Lockwood | 67f8e8b | 2014-12-01 13:54:59 -0800 | [diff] [blame] | 4843 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4844 | * @see #getSystemService(String) |
Mike Lockwood | 67f8e8b | 2014-12-01 13:54:59 -0800 | [diff] [blame] | 4845 | */ |
| 4846 | public static final String MIDI_SERVICE = "midi"; |
| 4847 | |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 4848 | |
| 4849 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4850 | * Use with {@link #getSystemService(String)} to retrieve a |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 4851 | * {@link android.hardware.radio.RadioManager} for accessing the broadcast radio service. |
| 4852 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4853 | * @see #getSystemService(String) |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 4854 | * @hide |
| 4855 | */ |
Tomasz Wasilczyk | 9110df7 | 2017-06-22 07:57:20 -0700 | [diff] [blame] | 4856 | public static final String RADIO_SERVICE = "broadcastradio"; |
Eric Laurent | 2035ac8 | 2015-03-05 15:18:44 -0800 | [diff] [blame] | 4857 | |
Paul McLean | a33be21 | 2015-02-20 07:52:45 -0800 | [diff] [blame] | 4858 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4859 | * Use with {@link #getSystemService(String)} to retrieve a |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 4860 | * {@link android.os.HardwarePropertiesManager} for accessing the hardware properties service. |
| 4861 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4862 | * @see #getSystemService(String) |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 4863 | */ |
Polina Bondarenko | 8333c73 | 2016-03-09 18:08:42 +0100 | [diff] [blame] | 4864 | public static final String HARDWARE_PROPERTIES_SERVICE = "hardware_properties"; |
Polina Bondarenko | 965ecbb | 2015-11-13 15:34:28 +0100 | [diff] [blame] | 4865 | |
| 4866 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4867 | * Use with {@link #getSystemService(String)} to retrieve a |
Wei Wang | bad7c20 | 2018-11-01 11:57:39 -0700 | [diff] [blame] | 4868 | * {@link android.os.ThermalService} for accessing the thermal service. |
| 4869 | * |
| 4870 | * @see #getSystemService(String) |
| 4871 | * @hide |
| 4872 | */ |
| 4873 | public static final String THERMAL_SERVICE = "thermalservice"; |
| 4874 | |
| 4875 | /** |
| 4876 | * Use with {@link #getSystemService(String)} to retrieve a |
Makoto Onuki | b5a012f | 2016-06-21 11:13:53 -0700 | [diff] [blame] | 4877 | * {@link android.content.pm.ShortcutManager} for accessing the launcher shortcut service. |
Makoto Onuki | 6f7362d9 | 2016-03-04 13:39:41 -0800 | [diff] [blame] | 4878 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4879 | * @see #getSystemService(String) |
Makoto Onuki | 6f7362d9 | 2016-03-04 13:39:41 -0800 | [diff] [blame] | 4880 | * @see android.content.pm.ShortcutManager |
| 4881 | */ |
| 4882 | public static final String SHORTCUT_SERVICE = "shortcut"; |
| 4883 | |
| 4884 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4885 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 4886 | * android.hardware.location.ContextHubManager} for accessing context hubs. |
| 4887 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4888 | * @see #getSystemService(String) |
Peng Xu | 9ff7d22 | 2016-02-11 13:02:05 -0800 | [diff] [blame] | 4889 | * @see android.hardware.location.ContextHubManager |
| 4890 | * |
| 4891 | * @hide |
| 4892 | */ |
| 4893 | @SystemApi |
| 4894 | public static final String CONTEXTHUB_SERVICE = "contexthub"; |
| 4895 | |
| 4896 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4897 | * Use with {@link #getSystemService(String)} to retrieve a |
Joe Onorato | 713fec8 | 2016-03-04 10:34:02 -0800 | [diff] [blame] | 4898 | * {@link android.os.health.SystemHealthManager} for accessing system health (battery, power, |
| 4899 | * memory, etc) metrics. |
| 4900 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4901 | * @see #getSystemService(String) |
Joe Onorato | 713fec8 | 2016-03-04 10:34:02 -0800 | [diff] [blame] | 4902 | */ |
| 4903 | public static final String SYSTEM_HEALTH_SERVICE = "systemhealth"; |
| 4904 | |
| 4905 | /** |
Amith Yamasani | d04aaa3 | 2016-06-13 12:09:36 -0700 | [diff] [blame] | 4906 | * Gatekeeper Service. |
| 4907 | * @hide |
| 4908 | */ |
| 4909 | public static final String GATEKEEPER_SERVICE = "android.service.gatekeeper.IGateKeeperService"; |
| 4910 | |
| 4911 | /** |
Svet Ganov | 37e4327 | 2016-09-09 16:01:32 -0700 | [diff] [blame] | 4912 | * Service defining the policy for access to device identifiers. |
| 4913 | * @hide |
| 4914 | */ |
| 4915 | public static final String DEVICE_IDENTIFIERS_SERVICE = "device_identifiers"; |
| 4916 | |
| 4917 | /** |
Joe Onorato | 1754d74 | 2016-11-21 17:51:35 -0800 | [diff] [blame] | 4918 | * Service to report a system health "incident" |
| 4919 | * @hide |
| 4920 | */ |
| 4921 | public static final String INCIDENT_SERVICE = "incident"; |
| 4922 | |
| 4923 | /** |
Joe Onorato | e21ab7e | 2018-12-18 15:00:25 -0800 | [diff] [blame] | 4924 | * Service to assist incidentd and dumpstated in reporting status to the user |
| 4925 | * and in confirming authorization to take an incident report or bugreport |
| 4926 | * @hide |
| 4927 | */ |
| 4928 | public static final String INCIDENT_COMPANION_SERVICE = "incidentcompanion"; |
| 4929 | |
| 4930 | /** |
Jeffrey Huang | 8c1ae5a | 2019-12-12 10:56:24 -0800 | [diff] [blame] | 4931 | * Service to assist {@link android.app.StatsManager} that lives in system server. |
| 4932 | * @hide |
| 4933 | */ |
| 4934 | public static final String STATS_MANAGER_SERVICE = "statsmanager"; |
| 4935 | |
| 4936 | /** |
Bookatz | 9472641 | 2017-08-31 09:26:15 -0700 | [diff] [blame] | 4937 | * Service to assist statsd in obtaining general stats. |
| 4938 | * @hide |
| 4939 | */ |
| 4940 | public static final String STATS_COMPANION_SERVICE = "statscompanion"; |
| 4941 | |
| 4942 | /** |
Bookatz | c697797 | 2018-01-16 16:55:05 -0800 | [diff] [blame] | 4943 | * Use with {@link #getSystemService(String)} to retrieve an {@link android.app.StatsManager}. |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 4944 | * @hide |
| 4945 | */ |
| 4946 | @SystemApi |
| 4947 | public static final String STATS_MANAGER = "stats"; |
| 4948 | |
| 4949 | /** |
atrost | de54a8ac | 2019-08-15 16:53:01 +0100 | [diff] [blame] | 4950 | * Use with {@link android.os.ServiceManager.getService()} to retrieve a |
| 4951 | * {@link IPlatformCompat} IBinder for communicating with the platform compat service. |
| 4952 | * @hide |
| 4953 | */ |
| 4954 | public static final String PLATFORM_COMPAT_SERVICE = "platform_compat"; |
| 4955 | |
| 4956 | /** |
atrost | 8748835 | 2019-10-10 19:27:31 +0100 | [diff] [blame] | 4957 | * Use with {@link android.os.ServiceManager.getService()} to retrieve a |
| 4958 | * {@link IPlatformCompatNative} IBinder for native code communicating with the platform compat |
| 4959 | * service. |
| 4960 | * @hide |
| 4961 | */ |
| 4962 | public static final String PLATFORM_COMPAT_NATIVE_SERVICE = "platform_compat_native"; |
| 4963 | |
| 4964 | /** |
Nandana Dutt | d11850c | 2018-12-12 17:26:57 +0000 | [diff] [blame] | 4965 | * Service to capture a bugreport. |
| 4966 | * @see #getSystemService(String) |
| 4967 | * @see android.os.BugreportManager |
| 4968 | * @hide |
| 4969 | */ |
Nandana Dutt | d7e8d5a | 2019-04-11 17:27:45 +0100 | [diff] [blame] | 4970 | @SystemApi @TestApi |
Nandana Dutt | d11850c | 2018-12-12 17:26:57 +0000 | [diff] [blame] | 4971 | public static final String BUGREPORT_SERVICE = "bugreport"; |
| 4972 | |
| 4973 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4974 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
MÃ¥rten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 4975 | * android.content.om.OverlayManager} for managing overlay packages. |
| 4976 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4977 | * @see #getSystemService(String) |
MÃ¥rten Kongstad | eabc9e9 | 2015-12-15 16:40:23 +0100 | [diff] [blame] | 4978 | * @see android.content.om.OverlayManager |
| 4979 | * @hide |
| 4980 | */ |
| 4981 | public static final String OVERLAY_SERVICE = "overlay"; |
| 4982 | |
| 4983 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4984 | * Use with {@link #getSystemService(String)} to retrieve a |
MÃ¥rten Kongstad | 06a1ac8 | 2018-09-20 13:09:47 +0200 | [diff] [blame] | 4985 | * {android.os.IIdmap2} for managing idmap files (used by overlay |
| 4986 | * packages). |
| 4987 | * |
| 4988 | * @see #getSystemService(String) |
| 4989 | * @hide |
| 4990 | */ |
| 4991 | public static final String IDMAP_SERVICE = "idmap"; |
| 4992 | |
| 4993 | /** |
| 4994 | * Use with {@link #getSystemService(String)} to retrieve a |
Zak Cohen | 56345f4 | 2017-01-26 13:54:28 -0800 | [diff] [blame] | 4995 | * {@link VrManager} for accessing the VR service. |
| 4996 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 4997 | * @see #getSystemService(String) |
Zak Cohen | 56345f4 | 2017-01-26 13:54:28 -0800 | [diff] [blame] | 4998 | * @hide |
| 4999 | */ |
| 5000 | @SystemApi |
| 5001 | public static final String VR_SERVICE = "vrmanager"; |
| 5002 | |
| 5003 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 5004 | * Use with {@link #getSystemService(String)} to retrieve an |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 5005 | * {@link android.app.timezone.ITimeZoneRulesManager}. |
| 5006 | * @hide |
| 5007 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 5008 | * @see #getSystemService(String) |
Neil Fuller | fe6ec56 | 2017-03-16 18:29:36 +0000 | [diff] [blame] | 5009 | */ |
| 5010 | public static final String TIME_ZONE_RULES_MANAGER_SERVICE = "timezone"; |
| 5011 | |
| 5012 | /** |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 5013 | * Use with {@link #getSystemService(String)} to retrieve a |
Tony Mak | b0d2262 | 2018-01-18 12:49:49 +0000 | [diff] [blame] | 5014 | * {@link android.content.pm.CrossProfileApps} for cross profile operations. |
Tony Mak | 1b708e6 | 2017-10-12 10:59:11 +0100 | [diff] [blame] | 5015 | * |
Ng Zhi An | f7c1e2b | 2018-01-08 11:18:08 -0800 | [diff] [blame] | 5016 | * @see #getSystemService(String) |
Tony Mak | 1b708e6 | 2017-10-12 10:59:11 +0100 | [diff] [blame] | 5017 | */ |
| 5018 | public static final String CROSS_PROFILE_APPS_SERVICE = "crossprofileapps"; |
| 5019 | |
| 5020 | /** |
Ruchi Kandoi | 6149b0f | 2018-01-03 16:14:57 -0800 | [diff] [blame] | 5021 | * Use with {@link #getSystemService} to retrieve a |
| 5022 | * {@link android.se.omapi.ISecureElementService} |
| 5023 | * for accessing the SecureElementService. |
| 5024 | * |
| 5025 | * @hide |
| 5026 | */ |
| 5027 | @SystemApi |
| 5028 | public static final String SECURE_ELEMENT_SERVICE = "secure_element"; |
| 5029 | |
| 5030 | /** |
Neil Fuller | feeee68 | 2018-05-30 14:35:24 +0100 | [diff] [blame] | 5031 | * Use with {@link #getSystemService(String)} to retrieve an |
Neil Fuller | 3e3b540 | 2019-11-07 15:35:05 +0000 | [diff] [blame] | 5032 | * {@link android.app.timedetector.TimeDetector}. |
Neil Fuller | feeee68 | 2018-05-30 14:35:24 +0100 | [diff] [blame] | 5033 | * @hide |
| 5034 | * |
| 5035 | * @see #getSystemService(String) |
| 5036 | */ |
| 5037 | public static final String TIME_DETECTOR_SERVICE = "time_detector"; |
| 5038 | |
| 5039 | /** |
Neil Fuller | 3e3b540 | 2019-11-07 15:35:05 +0000 | [diff] [blame] | 5040 | * Use with {@link #getSystemService(String)} to retrieve an |
| 5041 | * {@link android.app.timezonedetector.TimeZoneDetector}. |
| 5042 | * @hide |
| 5043 | * |
| 5044 | * @see #getSystemService(String) |
| 5045 | */ |
| 5046 | public static final String TIME_ZONE_DETECTOR_SERVICE = "time_zone_detector"; |
| 5047 | |
| 5048 | /** |
Makoto Onuki | df7e481 | 2018-09-24 14:31:25 -0700 | [diff] [blame] | 5049 | * Binder service name for {@link AppBindingService}. |
| 5050 | * @hide |
| 5051 | */ |
| 5052 | public static final String APP_BINDING_SERVICE = "app_binding"; |
| 5053 | |
| 5054 | /** |
Sahin Caliskan | 9458ebc | 2018-10-31 13:23:29 -0700 | [diff] [blame] | 5055 | * Use with {@link #getSystemService(String)} to retrieve an |
James.cf Lin | 2bc9cd4 | 2019-11-04 20:23:36 +0800 | [diff] [blame] | 5056 | * {@link android.telephony.ims.ImsManager}. |
James.cf Lin | 2bc9cd4 | 2019-11-04 20:23:36 +0800 | [diff] [blame] | 5057 | */ |
| 5058 | public static final String TELEPHONY_IMS_SERVICE = "telephony_ims"; |
| 5059 | |
| 5060 | /** |
| 5061 | * Use with {@link #getSystemService(String)} to retrieve an |
Hall Liu | b38ad5f | 2019-12-23 18:11:10 -0800 | [diff] [blame] | 5062 | * {@link android.os.SystemConfigManager}. |
| 5063 | * @hide |
| 5064 | */ |
| 5065 | @SystemApi |
| 5066 | public static final String SYSTEM_CONFIG_SERVICE = "system_config"; |
| 5067 | |
| 5068 | /** |
| 5069 | * Use with {@link #getSystemService(String)} to retrieve an |
Brad Ebinger | d1cb346 | 2019-06-20 14:20:01 -0700 | [diff] [blame] | 5070 | * {@link android.telephony.ims.RcsMessageManager}. |
Sahin Caliskan | 9458ebc | 2018-10-31 13:23:29 -0700 | [diff] [blame] | 5071 | * @hide |
| 5072 | */ |
Brad Ebinger | d1cb346 | 2019-06-20 14:20:01 -0700 | [diff] [blame] | 5073 | public static final String TELEPHONY_RCS_MESSAGE_SERVICE = "ircsmessage"; |
Sahin Caliskan | 9458ebc | 2018-10-31 13:23:29 -0700 | [diff] [blame] | 5074 | |
Howard Chen | 0a94764 | 2019-01-07 14:10:44 +0800 | [diff] [blame] | 5075 | /** |
| 5076 | * Use with {@link #getSystemService(String)} to retrieve an |
Po-Chien Hsueh | 4e908c2 | 2019-03-07 11:57:17 +0800 | [diff] [blame] | 5077 | * {@link android.os.image.DynamicSystemManager}. |
Howard Chen | 0a94764 | 2019-01-07 14:10:44 +0800 | [diff] [blame] | 5078 | * @hide |
| 5079 | */ |
Po-Chien Hsueh | 4e908c2 | 2019-03-07 11:57:17 +0800 | [diff] [blame] | 5080 | public static final String DYNAMIC_SYSTEM_SERVICE = "dynamic_system"; |
Howard Chen | 0a94764 | 2019-01-07 14:10:44 +0800 | [diff] [blame] | 5081 | |
Sahin Caliskan | 9458ebc | 2018-10-31 13:23:29 -0700 | [diff] [blame] | 5082 | /** |
Sudheer Shanka | f5b3696 | 2019-10-04 16:16:13 -0700 | [diff] [blame] | 5083 | * Use with {@link #getSystemService(String)} to retrieve a {@link |
| 5084 | * android.app.blob.BlobStoreManager} for contributing and accessing data blobs |
| 5085 | * from the blob store maintained by the system. |
| 5086 | * |
| 5087 | * @see #getSystemService(String) |
| 5088 | * @see android.app.blob.BlobStoreManager |
Sudheer Shanka | f5b3696 | 2019-10-04 16:16:13 -0700 | [diff] [blame] | 5089 | */ |
Sudheer Shanka | f5b3696 | 2019-10-04 16:16:13 -0700 | [diff] [blame] | 5090 | public static final String BLOB_STORE_SERVICE = "blob_store"; |
| 5091 | |
| 5092 | /** |
Chen Xu | 288b71c | 2019-09-15 18:28:21 -0700 | [diff] [blame] | 5093 | * Use with {@link #getSystemService(String)} to retrieve an |
Chen Xu | 1f6cfa5 | 2019-10-13 17:30:32 -0700 | [diff] [blame] | 5094 | * {@link TelephonyRegistryManager}. |
Chen Xu | 288b71c | 2019-09-15 18:28:21 -0700 | [diff] [blame] | 5095 | * @hide |
| 5096 | */ |
| 5097 | @SystemApi |
| 5098 | public static final String TELEPHONY_REGISTRY_SERVICE = "telephony_registry"; |
| 5099 | |
| 5100 | /** |
Roshan Pius | 848513e | 2019-10-11 13:44:00 -0700 | [diff] [blame] | 5101 | * Use with {@link #getSystemService(String)} to retrieve an |
| 5102 | * {@link android.os.BatteryStatsManager}. |
| 5103 | * @hide |
| 5104 | */ |
| 5105 | @SystemApi |
Adrian Roos | d38f509 | 2020-01-16 21:20:24 +0100 | [diff] [blame] | 5106 | @SuppressLint("ServiceName") |
Roshan Pius | 848513e | 2019-10-11 13:44:00 -0700 | [diff] [blame] | 5107 | public static final String BATTERY_STATS_SERVICE = "batterystats"; |
| 5108 | |
| 5109 | /** |
Terry Wang | ecc0d1b | 2019-10-17 17:05:18 -0700 | [diff] [blame] | 5110 | * Use with {@link #getSystemService(String)} to retrieve an |
Terry Wang | e05730f | 2020-01-22 16:37:19 -0800 | [diff] [blame] | 5111 | * {@link android.app.appsearch.AppSearchManager} for |
| 5112 | * indexing and querying app data managed by the system. |
Terry Wang | ecc0d1b | 2019-10-17 17:05:18 -0700 | [diff] [blame] | 5113 | * |
| 5114 | * @see #getSystemService(String) |
Terry Wang | e05730f | 2020-01-22 16:37:19 -0800 | [diff] [blame] | 5115 | * @hide |
Terry Wang | ecc0d1b | 2019-10-17 17:05:18 -0700 | [diff] [blame] | 5116 | */ |
| 5117 | public static final String APP_SEARCH_SERVICE = "app_search"; |
| 5118 | |
| 5119 | /** |
Song Pan | 75147d5 | 2019-11-19 00:57:46 +0000 | [diff] [blame] | 5120 | * Use with {@link #getSystemService(String)} to retrieve an |
| 5121 | * {@link android.content.integrity.AppIntegrityManager}. |
| 5122 | * @hide |
| 5123 | */ |
| 5124 | @SystemApi |
Song Pan | 5604437 | 2020-02-03 13:39:45 +0000 | [diff] [blame] | 5125 | @TestApi |
Song Pan | 75147d5 | 2019-11-19 00:57:46 +0000 | [diff] [blame] | 5126 | public static final String APP_INTEGRITY_SERVICE = "app_integrity"; |
| 5127 | |
| 5128 | /** |
Songchun Fan | d1b41d4 | 2019-11-12 17:09:53 -0800 | [diff] [blame] | 5129 | * Use with {@link #getSystemService(String)} to retrieve an |
Songchun Fan | 6dd47b5 | 2019-11-29 15:20:18 -0800 | [diff] [blame] | 5130 | * {@link android.content.pm.DataLoaderManager}. |
| 5131 | * @hide |
| 5132 | */ |
Songchun Fan | 7cc2074 | 2019-12-11 09:47:45 -0800 | [diff] [blame] | 5133 | public static final String DATA_LOADER_MANAGER_SERVICE = "dataloader_manager"; |
Songchun Fan | 6dd47b5 | 2019-11-29 15:20:18 -0800 | [diff] [blame] | 5134 | |
| 5135 | /** |
| 5136 | * Use with {@link #getSystemService(String)} to retrieve an |
Songchun Fan | d1b41d4 | 2019-11-12 17:09:53 -0800 | [diff] [blame] | 5137 | * {@link android.os.incremental.IncrementalManager}. |
| 5138 | * @hide |
| 5139 | */ |
Songchun Fan | f5c894f | 2019-11-29 15:43:58 -0800 | [diff] [blame] | 5140 | public static final String INCREMENTAL_SERVICE = "incremental_service"; |
Songchun Fan | d1b41d4 | 2019-11-12 17:09:53 -0800 | [diff] [blame] | 5141 | |
| 5142 | /** |
Victor Hsieh | 20fe1f6 | 2019-09-30 13:36:21 -0700 | [diff] [blame] | 5143 | * Use with {@link #getSystemService(String)} to retrieve an |
| 5144 | * {@link android.security.FileIntegrityManager}. |
| 5145 | * @see #getSystemService(String) |
| 5146 | * @see android.security.FileIntegrityManager |
| 5147 | */ |
| 5148 | public static final String FILE_INTEGRITY_SERVICE = "file_integrity"; |
| 5149 | |
| 5150 | /** |
Ivailo Karamanolev | 090d02c | 2020-01-09 17:02:49 +0100 | [diff] [blame] | 5151 | * Use with {@link #getSystemService(String)} to retrieve a |
| 5152 | * {@link android.hardware.lights.LightsManager} for controlling device lights. |
| 5153 | * |
| 5154 | * @see #getSystemService(String) |
| 5155 | * @hide |
| 5156 | */ |
| 5157 | public static final String LIGHTS_SERVICE = "lights"; |
| 5158 | |
| 5159 | /** |
Galia Peycheva | 641e2e6 | 2020-02-18 00:47:05 +0100 | [diff] [blame] | 5160 | * Use with {@link #getSystemService(String)} to retrieve a |
| 5161 | * {@link android.app.DreamManager} for controlling Dream states. |
| 5162 | * |
| 5163 | * @see #getSystemService(String) |
| 5164 | |
| 5165 | * @hide |
| 5166 | */ |
| 5167 | @TestApi |
| 5168 | public static final String DREAM_SERVICE = "dream"; |
| 5169 | |
| 5170 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5171 | * Determine whether the given permission is allowed for a particular |
| 5172 | * process and user ID running in the system. |
| 5173 | * |
| 5174 | * @param permission The name of the permission being checked. |
| 5175 | * @param pid The process ID being checked against. Must be > 0. |
| 5176 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 5177 | * user, which will pass every permission check. |
| 5178 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5179 | * @return {@link PackageManager#PERMISSION_GRANTED} if the given |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5180 | * pid/uid is allowed that permission, or |
| 5181 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 5182 | * |
| 5183 | * @see PackageManager#checkPermission(String, String) |
| 5184 | * @see #checkCallingPermission |
| 5185 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 5186 | @CheckResult(suggest="#enforcePermission(String,int,int,String)") |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5187 | @PackageManager.PermissionResult |
| 5188 | 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] | 5189 | |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 5190 | /** @hide */ |
| 5191 | @PackageManager.PermissionResult |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 5192 | @UnsupportedAppUsage |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 5193 | public abstract int checkPermission(@NonNull String permission, int pid, int uid, |
| 5194 | IBinder callerToken); |
| 5195 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5196 | /** |
| 5197 | * Determine whether the calling process of an IPC you are handling has been |
| 5198 | * granted a particular permission. This is basically the same as calling |
| 5199 | * {@link #checkPermission(String, int, int)} with the pid and uid returned |
| 5200 | * by {@link android.os.Binder#getCallingPid} and |
| 5201 | * {@link android.os.Binder#getCallingUid}. One important difference |
| 5202 | * is that if you are not currently processing an IPC, this function |
| 5203 | * will always fail. This is done to protect against accidentally |
| 5204 | * leaking permissions; you can use {@link #checkCallingOrSelfPermission} |
| 5205 | * to avoid this protection. |
| 5206 | * |
| 5207 | * @param permission The name of the permission being checked. |
| 5208 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5209 | * @return {@link PackageManager#PERMISSION_GRANTED} if the calling |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5210 | * pid/uid is allowed that permission, or |
| 5211 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 5212 | * |
| 5213 | * @see PackageManager#checkPermission(String, String) |
| 5214 | * @see #checkPermission |
| 5215 | * @see #checkCallingOrSelfPermission |
| 5216 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 5217 | @CheckResult(suggest="#enforceCallingPermission(String,String)") |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5218 | @PackageManager.PermissionResult |
| 5219 | public abstract int checkCallingPermission(@NonNull String permission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5220 | |
| 5221 | /** |
| 5222 | * Determine whether the calling process of an IPC <em>or you</em> have been |
| 5223 | * granted a particular permission. This is the same as |
| 5224 | * {@link #checkCallingPermission}, except it grants your own permissions |
| 5225 | * if you are not currently processing an IPC. Use with care! |
| 5226 | * |
| 5227 | * @param permission The name of the permission being checked. |
| 5228 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5229 | * @return {@link PackageManager#PERMISSION_GRANTED} if the calling |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5230 | * pid/uid is allowed that permission, or |
| 5231 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 5232 | * |
| 5233 | * @see PackageManager#checkPermission(String, String) |
| 5234 | * @see #checkPermission |
| 5235 | * @see #checkCallingPermission |
| 5236 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 5237 | @CheckResult(suggest="#enforceCallingOrSelfPermission(String,String)") |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5238 | @PackageManager.PermissionResult |
| 5239 | public abstract int checkCallingOrSelfPermission(@NonNull String permission); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5240 | |
| 5241 | /** |
Svetoslav | c6d1c34 | 2015-02-26 14:44:43 -0800 | [diff] [blame] | 5242 | * Determine whether <em>you</em> have been granted a particular permission. |
| 5243 | * |
| 5244 | * @param permission The name of the permission being checked. |
| 5245 | * |
| 5246 | * @return {@link PackageManager#PERMISSION_GRANTED} if you have the |
| 5247 | * permission, or {@link PackageManager#PERMISSION_DENIED} if not. |
| 5248 | * |
| 5249 | * @see PackageManager#checkPermission(String, String) |
| 5250 | * @see #checkCallingPermission(String) |
| 5251 | */ |
| 5252 | @PackageManager.PermissionResult |
| 5253 | public abstract int checkSelfPermission(@NonNull String permission); |
| 5254 | |
| 5255 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5256 | * If the given permission is not allowed for a particular process |
| 5257 | * and user ID running in the system, throw a {@link SecurityException}. |
| 5258 | * |
| 5259 | * @param permission The name of the permission being checked. |
| 5260 | * @param pid The process ID being checked against. Must be > 0. |
| 5261 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 5262 | * user, which will pass every permission check. |
| 5263 | * @param message A message to include in the exception if it is thrown. |
| 5264 | * |
| 5265 | * @see #checkPermission(String, int, int) |
| 5266 | */ |
| 5267 | public abstract void enforcePermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5268 | @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] | 5269 | |
| 5270 | /** |
| 5271 | * If the calling process of an IPC you are handling has not been |
| 5272 | * granted a particular permission, throw a {@link |
| 5273 | * SecurityException}. This is basically the same as calling |
| 5274 | * {@link #enforcePermission(String, int, int, String)} with the |
| 5275 | * pid and uid returned by {@link android.os.Binder#getCallingPid} |
| 5276 | * and {@link android.os.Binder#getCallingUid}. One important |
| 5277 | * difference is that if you are not currently processing an IPC, |
| 5278 | * this function will always throw the SecurityException. This is |
| 5279 | * done to protect against accidentally leaking permissions; you |
| 5280 | * can use {@link #enforceCallingOrSelfPermission} to avoid this |
| 5281 | * protection. |
| 5282 | * |
| 5283 | * @param permission The name of the permission being checked. |
| 5284 | * @param message A message to include in the exception if it is thrown. |
| 5285 | * |
| 5286 | * @see #checkCallingPermission(String) |
| 5287 | */ |
| 5288 | public abstract void enforceCallingPermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5289 | @NonNull String permission, @Nullable String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5290 | |
| 5291 | /** |
| 5292 | * If neither you nor the calling process of an IPC you are |
| 5293 | * handling has been granted a particular permission, throw a |
| 5294 | * {@link SecurityException}. This is the same as {@link |
| 5295 | * #enforceCallingPermission}, except it grants your own |
| 5296 | * permissions if you are not currently processing an IPC. Use |
| 5297 | * with care! |
| 5298 | * |
| 5299 | * @param permission The name of the permission being checked. |
| 5300 | * @param message A message to include in the exception if it is thrown. |
| 5301 | * |
| 5302 | * @see #checkCallingOrSelfPermission(String) |
| 5303 | */ |
| 5304 | public abstract void enforceCallingOrSelfPermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5305 | @NonNull String permission, @Nullable String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5306 | |
| 5307 | /** |
| 5308 | * Grant permission to access a specific Uri to another package, regardless |
| 5309 | * of whether that package has general permission to access the Uri's |
| 5310 | * content provider. This can be used to grant specific, temporary |
| 5311 | * permissions, typically in response to user interaction (such as the |
| 5312 | * user opening an attachment that you would like someone else to |
| 5313 | * display). |
| 5314 | * |
| 5315 | * <p>Normally you should use {@link Intent#FLAG_GRANT_READ_URI_PERMISSION |
| 5316 | * Intent.FLAG_GRANT_READ_URI_PERMISSION} or |
| 5317 | * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION |
| 5318 | * Intent.FLAG_GRANT_WRITE_URI_PERMISSION} with the Intent being used to |
| 5319 | * start an activity instead of this function directly. If you use this |
| 5320 | * function directly, you should be sure to call |
| 5321 | * {@link #revokeUriPermission} when the target should no longer be allowed |
| 5322 | * to access it. |
| 5323 | * |
| 5324 | * <p>To succeed, the content provider owning the Uri must have set the |
| 5325 | * {@link android.R.styleable#AndroidManifestProvider_grantUriPermissions |
| 5326 | * grantUriPermissions} attribute in its manifest or included the |
| 5327 | * {@link android.R.styleable#AndroidManifestGrantUriPermission |
| 5328 | * <grant-uri-permissions>} tag. |
| 5329 | * |
| 5330 | * @param toPackage The package you would like to allow to access the Uri. |
| 5331 | * @param uri The Uri you would like to grant access to. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5332 | * @param modeFlags The desired access modes. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5333 | * |
| 5334 | * @see #revokeUriPermission |
| 5335 | */ |
| 5336 | public abstract void grantUriPermission(String toPackage, Uri uri, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5337 | @Intent.GrantUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5338 | |
| 5339 | /** |
| 5340 | * Remove all permissions to access a particular content provider Uri |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 5341 | * that were previously added with {@link #grantUriPermission} or <em>any other</em> mechanism. |
| 5342 | * 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] | 5343 | * 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] | 5344 | * revoke both "content://foo/target" and "content://foo/target/sub", but not |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5345 | * "content://foo". It will not remove any prefix grants that exist at a |
| 5346 | * higher level. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5347 | * |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 5348 | * <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] | 5349 | * regular permission access to a Uri, but had received access to it through |
| 5350 | * a specific Uri permission grant, you could not revoke that grant with this |
| 5351 | * function and a {@link SecurityException} would be thrown. As of |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 5352 | * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this function will not throw a security |
| 5353 | * 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] | 5354 | * (or none).</p> |
| 5355 | * |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 5356 | * <p>Unlike {@link #revokeUriPermission(String, Uri, int)}, this method impacts all permission |
| 5357 | * grants matching the given Uri, for any package they had been granted to, through any |
| 5358 | * mechanism this had happened (such as indirectly through the clipboard, activity launch, |
| 5359 | * service start, etc). That means this can be potentially dangerous to use, as it can |
| 5360 | * revoke grants that another app could be strongly expecting to stick around.</p> |
| 5361 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5362 | * @param uri The Uri you would like to revoke access to. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5363 | * @param modeFlags The access modes to revoke. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5364 | * |
| 5365 | * @see #grantUriPermission |
| 5366 | */ |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5367 | 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] | 5368 | |
| 5369 | /** |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 5370 | * Remove permissions to access a particular content provider Uri |
| 5371 | * that were previously added with {@link #grantUriPermission} for a specific target |
| 5372 | * package. The given Uri will match all previously granted Uris that are the same or a |
| 5373 | * sub-path of the given Uri. That is, revoking "content://foo/target" will |
| 5374 | * revoke both "content://foo/target" and "content://foo/target/sub", but not |
| 5375 | * "content://foo". It will not remove any prefix grants that exist at a |
| 5376 | * higher level. |
| 5377 | * |
| 5378 | * <p>Unlike {@link #revokeUriPermission(Uri, int)}, this method will <em>only</em> |
| 5379 | * revoke permissions that had been explicitly granted through {@link #grantUriPermission} |
| 5380 | * and only for the package specified. Any matching grants that have happened through |
| 5381 | * other mechanisms (clipboard, activity launching, service starting, etc) will not be |
| 5382 | * removed.</p> |
| 5383 | * |
| 5384 | * @param toPackage The package you had previously granted access to. |
| 5385 | * @param uri The Uri you would like to revoke access to. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5386 | * @param modeFlags The access modes to revoke. |
Dianne Hackborn | a47223f | 2017-03-30 13:49:13 -0700 | [diff] [blame] | 5387 | * |
| 5388 | * @see #grantUriPermission |
| 5389 | */ |
| 5390 | public abstract void revokeUriPermission(String toPackage, Uri uri, |
| 5391 | @Intent.AccessUriMode int modeFlags); |
| 5392 | |
| 5393 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5394 | * Determine whether a particular process and user ID has been granted |
| 5395 | * permission to access a specific URI. This only checks for permissions |
| 5396 | * that have been explicitly granted -- if the given process/uid has |
| 5397 | * more general access to the URI's content provider then this check will |
| 5398 | * always fail. |
| 5399 | * |
| 5400 | * @param uri The uri that is being checked. |
| 5401 | * @param pid The process ID being checked against. Must be > 0. |
| 5402 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 5403 | * user, which will pass every permission check. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5404 | * @param modeFlags The access modes to check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5405 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5406 | * @return {@link PackageManager#PERMISSION_GRANTED} if the given |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5407 | * pid/uid is allowed to access that uri, or |
| 5408 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 5409 | * |
| 5410 | * @see #checkCallingUriPermission |
| 5411 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 5412 | @CheckResult(suggest="#enforceUriPermission(Uri,int,int,String)") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5413 | @PackageManager.PermissionResult |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5414 | public abstract int checkUriPermission(Uri uri, int pid, int uid, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5415 | @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5416 | |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 5417 | /** @hide */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5418 | @PackageManager.PermissionResult |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 5419 | public abstract int checkUriPermission(Uri uri, int pid, int uid, |
| 5420 | @Intent.AccessUriMode int modeFlags, IBinder callerToken); |
| 5421 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5422 | /** |
| 5423 | * Determine whether the calling process and user ID has been |
| 5424 | * granted permission to access a specific URI. This is basically |
| 5425 | * the same as calling {@link #checkUriPermission(Uri, int, int, |
| 5426 | * int)} with the pid and uid returned by {@link |
| 5427 | * android.os.Binder#getCallingPid} and {@link |
| 5428 | * android.os.Binder#getCallingUid}. One important difference is |
| 5429 | * that if you are not currently processing an IPC, this function |
| 5430 | * will always fail. |
| 5431 | * |
| 5432 | * @param uri The uri that is being checked. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5433 | * @param modeFlags The access modes to check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5434 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5435 | * @return {@link PackageManager#PERMISSION_GRANTED} if the caller |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5436 | * is allowed to access that uri, or |
| 5437 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 5438 | * |
| 5439 | * @see #checkUriPermission(Uri, int, int, int) |
| 5440 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 5441 | @CheckResult(suggest="#enforceCallingUriPermission(Uri,int,String)") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5442 | @PackageManager.PermissionResult |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5443 | 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] | 5444 | |
| 5445 | /** |
| 5446 | * Determine whether the calling process of an IPC <em>or you</em> has been granted |
| 5447 | * permission to access a specific URI. This is the same as |
| 5448 | * {@link #checkCallingUriPermission}, except it grants your own permissions |
| 5449 | * if you are not currently processing an IPC. Use with care! |
| 5450 | * |
| 5451 | * @param uri The uri that is being checked. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5452 | * @param modeFlags The access modes to check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5453 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5454 | * @return {@link PackageManager#PERMISSION_GRANTED} if the caller |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5455 | * is allowed to access that uri, or |
| 5456 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 5457 | * |
| 5458 | * @see #checkCallingUriPermission |
| 5459 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 5460 | @CheckResult(suggest="#enforceCallingOrSelfUriPermission(Uri,int,String)") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5461 | @PackageManager.PermissionResult |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5462 | public abstract int checkCallingOrSelfUriPermission(Uri uri, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5463 | @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5464 | |
| 5465 | /** |
| 5466 | * Check both a Uri and normal permission. This allows you to perform |
| 5467 | * both {@link #checkPermission} and {@link #checkUriPermission} in one |
| 5468 | * call. |
| 5469 | * |
| 5470 | * @param uri The Uri whose permission is to be checked, or null to not |
| 5471 | * do this check. |
| 5472 | * @param readPermission The permission that provides overall read access, |
| 5473 | * or null to not do this check. |
| 5474 | * @param writePermission The permission that provides overall write |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5475 | * access, or null to not do this check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5476 | * @param pid The process ID being checked against. Must be > 0. |
| 5477 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 5478 | * user, which will pass every permission check. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5479 | * @param modeFlags The access modes to check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5480 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5481 | * @return {@link PackageManager#PERMISSION_GRANTED} if the caller |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5482 | * is allowed to access that uri or holds one of the given permissions, or |
| 5483 | * {@link PackageManager#PERMISSION_DENIED} if it is not. |
| 5484 | */ |
Tor Norbye | 1c2bf03 | 2015-03-02 10:57:08 -0800 | [diff] [blame] | 5485 | @CheckResult(suggest="#enforceUriPermission(Uri,String,String,int,int,int,String)") |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5486 | @PackageManager.PermissionResult |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5487 | public abstract int checkUriPermission(@Nullable Uri uri, @Nullable String readPermission, |
| 5488 | @Nullable String writePermission, int pid, int uid, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5489 | @Intent.AccessUriMode int modeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5490 | |
| 5491 | /** |
| 5492 | * If a particular process and user ID has not been granted |
| 5493 | * permission to access a specific URI, throw {@link |
| 5494 | * SecurityException}. This only checks for permissions that have |
| 5495 | * been explicitly granted -- if the given process/uid has more |
| 5496 | * general access to the URI's content provider then this check |
| 5497 | * will always fail. |
| 5498 | * |
| 5499 | * @param uri The uri that is being checked. |
| 5500 | * @param pid The process ID being checked against. Must be > 0. |
| 5501 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 5502 | * user, which will pass every permission check. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5503 | * @param modeFlags The access modes to enforce. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5504 | * @param message A message to include in the exception if it is thrown. |
| 5505 | * |
| 5506 | * @see #checkUriPermission(Uri, int, int, int) |
| 5507 | */ |
| 5508 | public abstract void enforceUriPermission( |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5509 | 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] | 5510 | |
| 5511 | /** |
| 5512 | * If the calling process and user ID has not been granted |
| 5513 | * permission to access a specific URI, throw {@link |
| 5514 | * SecurityException}. This is basically the same as calling |
| 5515 | * {@link #enforceUriPermission(Uri, int, int, int, String)} with |
| 5516 | * the pid and uid returned by {@link |
| 5517 | * android.os.Binder#getCallingPid} and {@link |
| 5518 | * android.os.Binder#getCallingUid}. One important difference is |
| 5519 | * that if you are not currently processing an IPC, this function |
| 5520 | * will always throw a SecurityException. |
| 5521 | * |
| 5522 | * @param uri The uri that is being checked. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5523 | * @param modeFlags The access modes to enforce. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5524 | * @param message A message to include in the exception if it is thrown. |
| 5525 | * |
| 5526 | * @see #checkCallingUriPermission(Uri, int) |
| 5527 | */ |
| 5528 | public abstract void enforceCallingUriPermission( |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5529 | Uri uri, @Intent.AccessUriMode int modeFlags, String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5530 | |
| 5531 | /** |
| 5532 | * If the calling process of an IPC <em>or you</em> has not been |
| 5533 | * granted permission to access a specific URI, throw {@link |
| 5534 | * SecurityException}. This is the same as {@link |
| 5535 | * #enforceCallingUriPermission}, except it grants your own |
| 5536 | * permissions if you are not currently processing an IPC. Use |
| 5537 | * with care! |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 5538 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5539 | * @param uri The uri that is being checked. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5540 | * @param modeFlags The access modes to enforce. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5541 | * @param message A message to include in the exception if it is thrown. |
| 5542 | * |
| 5543 | * @see #checkCallingOrSelfUriPermission(Uri, int) |
| 5544 | */ |
| 5545 | public abstract void enforceCallingOrSelfUriPermission( |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5546 | Uri uri, @Intent.AccessUriMode int modeFlags, String message); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5547 | |
| 5548 | /** |
| 5549 | * Enforce both a Uri and normal permission. This allows you to perform |
| 5550 | * both {@link #enforcePermission} and {@link #enforceUriPermission} in one |
| 5551 | * call. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 5552 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5553 | * @param uri The Uri whose permission is to be checked, or null to not |
| 5554 | * do this check. |
| 5555 | * @param readPermission The permission that provides overall read access, |
| 5556 | * or null to not do this check. |
| 5557 | * @param writePermission The permission that provides overall write |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5558 | * access, or null to not do this check. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5559 | * @param pid The process ID being checked against. Must be > 0. |
| 5560 | * @param uid The user ID being checked against. A uid of 0 is the root |
| 5561 | * user, which will pass every permission check. |
Jeff Sharkey | 6503bd8 | 2017-04-19 23:24:18 -0600 | [diff] [blame] | 5562 | * @param modeFlags The access modes to enforce. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5563 | * @param message A message to include in the exception if it is thrown. |
| 5564 | * |
| 5565 | * @see #checkUriPermission(Uri, String, String, int, int, int) |
| 5566 | */ |
| 5567 | public abstract void enforceUriPermission( |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5568 | @Nullable Uri uri, @Nullable String readPermission, |
Jeff Sharkey | 846318a | 2014-04-04 12:12:41 -0700 | [diff] [blame] | 5569 | @Nullable String writePermission, int pid, int uid, @Intent.AccessUriMode int modeFlags, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5570 | @Nullable String message); |
| 5571 | |
| 5572 | /** @hide */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5573 | @IntDef(flag = true, prefix = { "CONTEXT_" }, value = { |
| 5574 | CONTEXT_INCLUDE_CODE, |
| 5575 | CONTEXT_IGNORE_SECURITY, |
| 5576 | CONTEXT_RESTRICTED, |
| 5577 | CONTEXT_DEVICE_PROTECTED_STORAGE, |
| 5578 | CONTEXT_CREDENTIAL_PROTECTED_STORAGE, |
| 5579 | CONTEXT_REGISTER_PACKAGE, |
| 5580 | }) |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5581 | @Retention(RetentionPolicy.SOURCE) |
| 5582 | public @interface CreatePackageOptions {} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5583 | |
| 5584 | /** |
| 5585 | * Flag for use with {@link #createPackageContext}: include the application |
| 5586 | * code with the context. This means loading code into the caller's |
| 5587 | * process, so that {@link #getClassLoader()} can be used to instantiate |
| 5588 | * the application's classes. Setting this flags imposes security |
| 5589 | * restrictions on what application context you can access; if the |
| 5590 | * requested application can not be safely loaded into your process, |
| 5591 | * java.lang.SecurityException will be thrown. If this flag is not set, |
| 5592 | * there will be no restrictions on the packages that can be loaded, |
| 5593 | * but {@link #getClassLoader} will always return the default system |
| 5594 | * class loader. |
| 5595 | */ |
| 5596 | public static final int CONTEXT_INCLUDE_CODE = 0x00000001; |
| 5597 | |
| 5598 | /** |
| 5599 | * Flag for use with {@link #createPackageContext}: ignore any security |
| 5600 | * restrictions on the Context being requested, allowing it to always |
| 5601 | * be loaded. For use with {@link #CONTEXT_INCLUDE_CODE} to allow code |
| 5602 | * to be loaded into a process even when it isn't safe to do so. Use |
| 5603 | * with extreme care! |
| 5604 | */ |
| 5605 | public static final int CONTEXT_IGNORE_SECURITY = 0x00000002; |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 5606 | |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 5607 | /** |
| 5608 | * Flag for use with {@link #createPackageContext}: a restricted context may |
| 5609 | * disable specific features. For instance, a View associated with a restricted |
| 5610 | * context would ignore particular XML attributes. |
| 5611 | */ |
| 5612 | public static final int CONTEXT_RESTRICTED = 0x00000004; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5613 | |
| 5614 | /** |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5615 | * Flag for use with {@link #createPackageContext}: point all file APIs at |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5616 | * device-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5617 | * |
| 5618 | * @hide |
| 5619 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5620 | public static final int CONTEXT_DEVICE_PROTECTED_STORAGE = 0x00000008; |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5621 | |
| 5622 | /** |
| 5623 | * Flag for use with {@link #createPackageContext}: point all file APIs at |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5624 | * credential-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5625 | * |
| 5626 | * @hide |
| 5627 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5628 | public static final int CONTEXT_CREDENTIAL_PROTECTED_STORAGE = 0x00000010; |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5629 | |
| 5630 | /** |
Dianne Hackborn | fee756f | 2014-07-16 17:31:10 -0700 | [diff] [blame] | 5631 | * @hide Used to indicate we should tell the activity manager about the process |
| 5632 | * loading this code. |
| 5633 | */ |
| 5634 | public static final int CONTEXT_REGISTER_PACKAGE = 0x40000000; |
| 5635 | |
| 5636 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5637 | * Return a new Context object for the given application name. This |
| 5638 | * Context is the same as what the named application gets when it is |
| 5639 | * launched, containing the same resources and class loader. Each call to |
| 5640 | * this method returns a new instance of a Context object; Context objects |
| 5641 | * are not shared, however they share common state (Resources, ClassLoader, |
| 5642 | * etc) so the Context instance itself is fairly lightweight. |
| 5643 | * |
Jeff Brown | 6e53931 | 2015-02-24 18:53:21 -0800 | [diff] [blame] | 5644 | * <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] | 5645 | * application with the given package name. |
| 5646 | * |
| 5647 | * <p>Throws {@link java.lang.SecurityException} if the Context requested |
| 5648 | * can not be loaded into the caller's process for security reasons (see |
| 5649 | * {@link #CONTEXT_INCLUDE_CODE} for more information}. |
| 5650 | * |
| 5651 | * @param packageName Name of the application's package. |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5652 | * @param flags Option flags. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5653 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5654 | * @return A {@link Context} for the application. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5655 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5656 | * @throws SecurityException |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5657 | * @throws PackageManager.NameNotFoundException if there is no application with |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5658 | * the given package name. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 5659 | */ |
| 5660 | public abstract Context createPackageContext(String packageName, |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5661 | @CreatePackageOptions int flags) throws PackageManager.NameNotFoundException; |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 5662 | |
| 5663 | /** |
Jeff Sharkey | 6d51571 | 2012-09-20 16:06:08 -0700 | [diff] [blame] | 5664 | * Similar to {@link #createPackageContext(String, int)}, but with a |
| 5665 | * different {@link UserHandle}. For example, {@link #getContentResolver()} |
| 5666 | * will open any {@link Uri} as the given user. |
| 5667 | * |
| 5668 | * @hide |
| 5669 | */ |
Patrick Baumann | ef4c407 | 2018-02-01 08:54:05 -0800 | [diff] [blame] | 5670 | @SystemApi |
Jeff Sharkey | ec5f7d1 | 2018-08-08 09:15:04 -0600 | [diff] [blame] | 5671 | @TestApi |
Makoto Onuki | b844001 | 2019-10-09 15:33:11 -0700 | [diff] [blame] | 5672 | @NonNull |
Patrick Baumann | ef4c407 | 2018-02-01 08:54:05 -0800 | [diff] [blame] | 5673 | public Context createPackageContextAsUser( |
Makoto Onuki | b844001 | 2019-10-09 15:33:11 -0700 | [diff] [blame] | 5674 | @NonNull String packageName, @CreatePackageOptions int flags, @NonNull UserHandle user) |
Patrick Baumann | ef4c407 | 2018-02-01 08:54:05 -0800 | [diff] [blame] | 5675 | throws PackageManager.NameNotFoundException { |
| 5676 | if (Build.IS_ENG) { |
| 5677 | throw new IllegalStateException("createPackageContextAsUser not overridden!"); |
| 5678 | } |
| 5679 | return this; |
| 5680 | } |
Jeff Sharkey | 6d51571 | 2012-09-20 16:06:08 -0700 | [diff] [blame] | 5681 | |
| 5682 | /** |
Makoto Onuki | b844001 | 2019-10-09 15:33:11 -0700 | [diff] [blame] | 5683 | * Similar to {@link #createPackageContext(String, int)}, but for the own package with a |
| 5684 | * different {@link UserHandle}. For example, {@link #getContentResolver()} |
| 5685 | * will open any {@link Uri} as the given user. |
| 5686 | * |
| 5687 | * @hide |
| 5688 | */ |
| 5689 | @SystemApi |
| 5690 | @TestApi |
| 5691 | @NonNull |
Makoto Onuki | e5449f0 | 2019-10-11 20:19:58 -0700 | [diff] [blame] | 5692 | public Context createContextAsUser(@NonNull UserHandle user, @CreatePackageOptions int flags) { |
Makoto Onuki | b844001 | 2019-10-09 15:33:11 -0700 | [diff] [blame] | 5693 | if (Build.IS_ENG) { |
| 5694 | throw new IllegalStateException("createContextAsUser not overridden!"); |
| 5695 | } |
| 5696 | return this; |
| 5697 | } |
| 5698 | |
| 5699 | /** |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5700 | * Creates a context given an {@link android.content.pm.ApplicationInfo}. |
| 5701 | * |
| 5702 | * @hide |
| 5703 | */ |
Mathew Inwood | 5c0d354 | 2018-08-14 13:54:31 +0100 | [diff] [blame] | 5704 | @UnsupportedAppUsage |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5705 | public abstract Context createApplicationContext(ApplicationInfo application, |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 5706 | @CreatePackageOptions int flags) throws PackageManager.NameNotFoundException; |
Svetoslav | 976e8bd | 2014-07-16 15:12:03 -0700 | [diff] [blame] | 5707 | |
| 5708 | /** |
Adam Lesinski | 4e86281 | 2016-11-21 16:02:24 -0800 | [diff] [blame] | 5709 | * Return a new Context object for the given split name. The new Context has a ClassLoader and |
| 5710 | * Resources object that can access the split's and all of its dependencies' code/resources. |
| 5711 | * Each call to this method returns a new instance of a Context object; |
| 5712 | * Context objects are not shared, however common state (ClassLoader, other Resources for |
| 5713 | * the same split) may be so the Context itself can be fairly lightweight. |
| 5714 | * |
| 5715 | * @param splitName The name of the split to include, as declared in the split's |
| 5716 | * <code>AndroidManifest.xml</code>. |
| 5717 | * @return A {@link Context} with the given split's code and/or resources loaded. |
| 5718 | */ |
| 5719 | public abstract Context createContextForSplit(String splitName) |
| 5720 | throws PackageManager.NameNotFoundException; |
| 5721 | |
| 5722 | /** |
Jeff Sharkey | ad357d1 | 2018-02-02 13:25:31 -0700 | [diff] [blame] | 5723 | * Get the user associated with this context |
Jim Miller | a75a883 | 2013-02-07 16:53:32 -0800 | [diff] [blame] | 5724 | * @hide |
| 5725 | */ |
Jeff Sharkey | a73b8fd | 2016-01-06 17:02:08 -0700 | [diff] [blame] | 5726 | @TestApi |
Jeff Sharkey | ad357d1 | 2018-02-02 13:25:31 -0700 | [diff] [blame] | 5727 | public UserHandle getUser() { |
| 5728 | return android.os.Process.myUserHandle(); |
| 5729 | } |
| 5730 | |
| 5731 | /** |
| 5732 | * Get the user associated with this context |
| 5733 | * @hide |
| 5734 | */ |
Artur Satayev | f0b7d0b | 2019-11-04 11:16:45 +0000 | [diff] [blame] | 5735 | @UnsupportedAppUsage |
Jeff Sharkey | ad357d1 | 2018-02-02 13:25:31 -0700 | [diff] [blame] | 5736 | @TestApi |
| 5737 | public @UserIdInt int getUserId() { |
| 5738 | return android.os.UserHandle.myUserId(); |
| 5739 | } |
Jim Miller | a75a883 | 2013-02-07 16:53:32 -0800 | [diff] [blame] | 5740 | |
| 5741 | /** |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 5742 | * Return a new Context object for the current Context but whose resources |
| 5743 | * are adjusted to match the given Configuration. Each call to this method |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 5744 | * returns a new instance of a Context object; Context objects are not |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 5745 | * shared, however common state (ClassLoader, other Resources for the |
| 5746 | * same configuration) may be so the Context itself can be fairly lightweight. |
| 5747 | * |
| 5748 | * @param overrideConfiguration A {@link Configuration} specifying what |
| 5749 | * values to modify in the base Configuration of the original Context's |
| 5750 | * resources. If the base configuration changes (such as due to an |
| 5751 | * orientation change), the resources of this context will also change except |
| 5752 | * for those that have been explicitly overridden with a value here. |
| 5753 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5754 | * @return A {@link Context} with the given configuration override. |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 5755 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5756 | public abstract Context createConfigurationContext( |
| 5757 | @NonNull Configuration overrideConfiguration); |
Dianne Hackborn | 756220b | 2012-08-14 16:45:30 -0700 | [diff] [blame] | 5758 | |
| 5759 | /** |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 5760 | * Return a new Context object for the current Context but whose resources |
| 5761 | * are adjusted to match the metrics of the given Display. Each call to this method |
| 5762 | * returns a new instance of a Context object; Context objects are not |
| 5763 | * shared, however common state (ClassLoader, other Resources for the |
| 5764 | * same configuration) may be so the Context itself can be fairly lightweight. |
| 5765 | * |
Andrii Kulian | e57f2dc | 2020-01-26 20:59:07 -0800 | [diff] [blame] | 5766 | * To obtain an instance of a {@link WindowManager} (see {@link #getSystemService(String)}) that |
| 5767 | * is configured to show windows on the given display call |
| 5768 | * {@link #createWindowContext(int, Bundle)} on the returned display Context or use an |
| 5769 | * {@link android.app.Activity}. |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 5770 | * |
Andrii Kulian | e57f2dc | 2020-01-26 20:59:07 -0800 | [diff] [blame] | 5771 | * @param display A {@link Display} object specifying the display for whose metrics the |
| 5772 | * Context's resources should be tailored. |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 5773 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5774 | * @return A {@link Context} for the display. |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 5775 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 5776 | public abstract Context createDisplayContext(@NonNull Display display); |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 5777 | |
| 5778 | /** |
Andrii Kulian | 4a31697 | 2020-01-21 21:41:38 -0800 | [diff] [blame] | 5779 | * Creates a Context for a non-activity window. |
| 5780 | * |
| 5781 | * <p> |
| 5782 | * A window context is a context that can be used to add non-activity windows, such as |
| 5783 | * {@link android.view.WindowManager.LayoutParams#TYPE_APPLICATION_OVERLAY}. A window context |
| 5784 | * must be created from a context that has an associated {@link Display}, such as |
| 5785 | * {@link android.app.Activity Activity} or a context created with |
| 5786 | * {@link #createDisplayContext(Display)}. |
| 5787 | * |
| 5788 | * <p> |
| 5789 | * The window context is created with the appropriate {@link Configuration} for the area of the |
| 5790 | * display that the windows created with it can occupy; it must be used when |
| 5791 | * {@link android.view.LayoutInflater inflating} views, such that they can be inflated with |
| 5792 | * proper {@link Resources}. |
| 5793 | * |
| 5794 | * Below is a sample code to <b>add an application overlay window on the primary display:<b/> |
| 5795 | * <pre class="prettyprint"> |
| 5796 | * ... |
| 5797 | * final DisplayManager dm = anyContext.getSystemService(DisplayManager.class); |
| 5798 | * final Display primaryDisplay = dm.getDisplay(DEFAULT_DISPLAY); |
| 5799 | * final Context windowContext = anyContext.createDisplayContext(primaryDisplay) |
Andrii Kulian | ea32563 | 2020-01-28 17:52:57 -0800 | [diff] [blame] | 5800 | * .createWindowContext(TYPE_APPLICATION_OVERLAY, null); |
Andrii Kulian | 4a31697 | 2020-01-21 21:41:38 -0800 | [diff] [blame] | 5801 | * final View overlayView = Inflater.from(windowContext).inflate(someLayoutXml, null); |
| 5802 | * |
| 5803 | * // WindowManager.LayoutParams initialization |
| 5804 | * ... |
| 5805 | * mParams.type = TYPE_APPLICATION_OVERLAY; |
| 5806 | * ... |
| 5807 | * |
| 5808 | * mWindowContext.getSystemService(WindowManager.class).addView(overlayView, mParams); |
| 5809 | * </pre> |
| 5810 | * |
| 5811 | * <p> |
| 5812 | * This context's configuration and resources are adjusted to a display area where the windows |
| 5813 | * with provided type will be added. <b>Note that all windows associated with the same context |
| 5814 | * will have an affinity and can only be moved together between different displays or areas on a |
| 5815 | * display.</b> If there is a need to add different window types, or non-associated windows, |
| 5816 | * separate Contexts should be used. |
| 5817 | * </p> |
| 5818 | * |
| 5819 | * @param type Window type in {@link WindowManager.LayoutParams} |
Andrii Kulian | ea32563 | 2020-01-28 17:52:57 -0800 | [diff] [blame] | 5820 | * @param options Bundle used to pass window-related options. |
Andrii Kulian | 4a31697 | 2020-01-21 21:41:38 -0800 | [diff] [blame] | 5821 | * @return A {@link Context} that can be used to create windows. |
| 5822 | * @throws UnsupportedOperationException if this is called on a non-UI context, such as |
| 5823 | * {@link android.app.Application Application} or {@link android.app.Service Service}. |
| 5824 | * |
| 5825 | * @see #getSystemService(String) |
| 5826 | * @see #getSystemService(Class) |
| 5827 | * @see #WINDOW_SERVICE |
| 5828 | * @see #LAYOUT_INFLATER_SERVICE |
| 5829 | * @see #WALLPAPER_SERVICE |
| 5830 | * @throws IllegalArgumentException if token is invalid |
| 5831 | */ |
Andrii Kulian | ea32563 | 2020-01-28 17:52:57 -0800 | [diff] [blame] | 5832 | public @NonNull Context createWindowContext(int type, @Nullable Bundle options) { |
Andrii Kulian | 4a31697 | 2020-01-21 21:41:38 -0800 | [diff] [blame] | 5833 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 5834 | } |
| 5835 | |
| 5836 | /** |
Philip P. Moltmann | 59076d8 | 2019-08-19 15:00:40 -0700 | [diff] [blame] | 5837 | * Return a new Context object for the current Context but for a different feature in the app. |
| 5838 | * Features can be used by complex apps to separate logical parts. |
| 5839 | * |
| 5840 | * @param featureId The feature id or {@code null} to create a context for the default feature. |
| 5841 | * |
| 5842 | * @return A {@link Context} for the feature |
| 5843 | * |
| 5844 | * @see #getFeatureId() |
| 5845 | */ |
| 5846 | public @NonNull Context createFeatureContext(@Nullable String featureId) { |
Philip P. Moltmann | f1a634c | 2019-10-18 09:10:56 -0700 | [diff] [blame] | 5847 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
Philip P. Moltmann | 59076d8 | 2019-08-19 15:00:40 -0700 | [diff] [blame] | 5848 | } |
| 5849 | |
| 5850 | /** |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5851 | * Return a new Context object for the current Context but whose storage |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5852 | * APIs are backed by device-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5853 | * <p> |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 5854 | * On devices with direct boot, data stored in this location is encrypted |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5855 | * with a key tied to the physical device, and it can be accessed |
| 5856 | * immediately after the device has booted successfully, both |
| 5857 | * <em>before and after</em> the user has authenticated with their |
| 5858 | * credentials (such as a lock pattern or PIN). |
| 5859 | * <p> |
| 5860 | * Because device-protected data is available without user authentication, |
| 5861 | * you should carefully limit the data you store using this Context. For |
| 5862 | * example, storing sensitive authentication tokens or passwords in the |
| 5863 | * device-protected area is strongly discouraged. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5864 | * <p> |
Jeff Sharkey | 3ea44a5 | 2016-01-09 15:19:56 -0700 | [diff] [blame] | 5865 | * If the underlying device does not have the ability to store |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5866 | * device-protected and credential-protected data using different keys, then |
| 5867 | * both storage areas will become available at the same time. They remain as |
| 5868 | * two distinct storage locations on disk, and only the window of |
| 5869 | * availability changes. |
Jeff Sharkey | 3ea44a5 | 2016-01-09 15:19:56 -0700 | [diff] [blame] | 5870 | * <p> |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5871 | * Each call to this method returns a new instance of a Context object; |
| 5872 | * Context objects are not shared, however common state (ClassLoader, other |
| 5873 | * Resources for the same configuration) may be so the Context itself can be |
| 5874 | * fairly lightweight. |
| 5875 | * |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5876 | * @see #isDeviceProtectedStorage() |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5877 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5878 | public abstract Context createDeviceProtectedStorageContext(); |
| 5879 | |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5880 | /** |
| 5881 | * Return a new Context object for the current Context but whose storage |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5882 | * APIs are backed by credential-protected storage. This is the default |
| 5883 | * storage area for apps unless |
| 5884 | * {@link android.R.attr#defaultToDeviceProtectedStorage} was requested. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5885 | * <p> |
Jeff Sharkey | cf3f0a1 | 2016-03-17 19:57:58 -0600 | [diff] [blame] | 5886 | * On devices with direct boot, data stored in this location is encrypted |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5887 | * with a key tied to user credentials, which can be accessed |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5888 | * <em>only after</em> the user has entered their credentials (such as a |
| 5889 | * lock pattern or PIN). |
| 5890 | * <p> |
Jeff Sharkey | 3ea44a5 | 2016-01-09 15:19:56 -0700 | [diff] [blame] | 5891 | * If the underlying device does not have the ability to store |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5892 | * device-protected and credential-protected data using different keys, then |
| 5893 | * both storage areas will become available at the same time. They remain as |
| 5894 | * two distinct storage locations on disk, and only the window of |
| 5895 | * availability changes. |
Jeff Sharkey | 3ea44a5 | 2016-01-09 15:19:56 -0700 | [diff] [blame] | 5896 | * <p> |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5897 | * Each call to this method returns a new instance of a Context object; |
| 5898 | * Context objects are not shared, however common state (ClassLoader, other |
| 5899 | * Resources for the same configuration) may be so the Context itself can be |
| 5900 | * fairly lightweight. |
| 5901 | * |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5902 | * @see #isCredentialProtectedStorage() |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 5903 | * @hide |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5904 | */ |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 5905 | @SystemApi |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5906 | public abstract Context createCredentialProtectedStorageContext(); |
| 5907 | |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5908 | /** |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 5909 | * Gets the display adjustments holder for this context. This information |
| 5910 | * is provided on a per-application or activity basis and is used to simulate lower density |
| 5911 | * display metrics for legacy applications and restricted screen sizes. |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 5912 | * |
Jeff Brown | a492c3a | 2012-08-23 19:48:44 -0700 | [diff] [blame] | 5913 | * @param displayId The display id for which to get compatibility info. |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 5914 | * @return The compatibility info holder, or null if not required by the application. |
| 5915 | * @hide |
| 5916 | */ |
Craig Mautner | 48d0d18 | 2013-06-11 07:53:06 -0700 | [diff] [blame] | 5917 | public abstract DisplayAdjustments getDisplayAdjustments(int displayId); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 5918 | |
| 5919 | /** |
Andrii Kulian | 4a31697 | 2020-01-21 21:41:38 -0800 | [diff] [blame] | 5920 | * Get the display this context is associated with. Applications should use this method with |
| 5921 | * {@link android.app.Activity} or a context associated with a {@link Display} via |
| 5922 | * {@link #createDisplayContext(Display)} to get a display object associated with a Context, or |
| 5923 | * {@link android.hardware.display.DisplayManager#getDisplay} to get a display object by id. |
Wale Ogunwale | 691af68 | 2019-02-11 03:09:10 -0800 | [diff] [blame] | 5924 | * @return Returns the {@link Display} object this context is associated with. |
Andrii Kulian | 5877c7d | 2020-01-29 16:57:32 -0800 | [diff] [blame] | 5925 | * @throws UnsupportedOperationException if the method is called on an instance that is not |
| 5926 | * associated with any display. |
Adam Lesinski | 4ece3d6 | 2016-06-16 18:05:41 -0700 | [diff] [blame] | 5927 | */ |
Andrii Kulian | 4a31697 | 2020-01-21 21:41:38 -0800 | [diff] [blame] | 5928 | @Nullable |
| 5929 | public Display getDisplay() { |
| 5930 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 5931 | } |
Adam Lesinski | 4ece3d6 | 2016-06-16 18:05:41 -0700 | [diff] [blame] | 5932 | |
| 5933 | /** |
Andrii Kulian | 5877c7d | 2020-01-29 16:57:32 -0800 | [diff] [blame] | 5934 | * A version of {@link #getDisplay()} that does not perform a Context misuse check to be used by |
| 5935 | * legacy APIs. |
| 5936 | * TODO(b/149790106): Fix usages and remove. |
| 5937 | * @hide |
| 5938 | */ |
| 5939 | @Nullable |
| 5940 | public Display getDisplayNoVerify() { |
| 5941 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 5942 | } |
| 5943 | |
| 5944 | /** |
Andrii Kulian | 4a31697 | 2020-01-21 21:41:38 -0800 | [diff] [blame] | 5945 | * Gets the ID of the display this context is associated with. |
Yohei Yukawa | 5281b6b | 2018-10-15 07:38:25 +0800 | [diff] [blame] | 5946 | * |
| 5947 | * @return display ID associated with this {@link Context}. |
Andrii Kulian | 4a31697 | 2020-01-21 21:41:38 -0800 | [diff] [blame] | 5948 | * @see #getDisplay() |
Yohei Yukawa | 5281b6b | 2018-10-15 07:38:25 +0800 | [diff] [blame] | 5949 | * @hide |
| 5950 | */ |
wilsonshih | 5db7b39 | 2019-02-20 23:08:45 +0800 | [diff] [blame] | 5951 | @TestApi |
Yohei Yukawa | 5281b6b | 2018-10-15 07:38:25 +0800 | [diff] [blame] | 5952 | public abstract int getDisplayId(); |
| 5953 | |
| 5954 | /** |
Andrii Kulian | b047b8b | 2017-02-08 18:38:26 -0800 | [diff] [blame] | 5955 | * @hide |
| 5956 | */ |
| 5957 | public abstract void updateDisplay(int displayId); |
| 5958 | |
| 5959 | /** |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 5960 | * Indicates whether this Context is restricted. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 5961 | * |
John Spurlock | 6098c5d | 2013-06-17 10:32:46 -0400 | [diff] [blame] | 5962 | * @return {@code true} if this Context is restricted, {@code false} otherwise. |
Scott Main | 4b5da68 | 2010-10-21 11:49:12 -0700 | [diff] [blame] | 5963 | * |
Romain Guy | 870e09f | 2009-07-06 16:35:25 -0700 | [diff] [blame] | 5964 | * @see #CONTEXT_RESTRICTED |
| 5965 | */ |
| 5966 | public boolean isRestricted() { |
| 5967 | return false; |
| 5968 | } |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5969 | |
| 5970 | /** |
| 5971 | * Indicates if the storage APIs of this Context are backed by |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5972 | * device-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5973 | * |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5974 | * @see #createDeviceProtectedStorageContext() |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5975 | */ |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5976 | public abstract boolean isDeviceProtectedStorage(); |
| 5977 | |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5978 | /** |
| 5979 | * Indicates if the storage APIs of this Context are backed by |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5980 | * credential-protected storage. |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5981 | * |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5982 | * @see #createCredentialProtectedStorageContext() |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 5983 | * @hide |
Jeff Sharkey | 7a30a30 | 2015-12-08 14:20:06 -0700 | [diff] [blame] | 5984 | */ |
Jeff Sharkey | e13529a | 2015-12-09 14:15:27 -0700 | [diff] [blame] | 5985 | @SystemApi |
Jeff Sharkey | 8a372a0 | 2016-03-16 16:25:45 -0600 | [diff] [blame] | 5986 | public abstract boolean isCredentialProtectedStorage(); |
| 5987 | |
Tony Mak | 46aabe5 | 2016-11-14 12:53:06 +0000 | [diff] [blame] | 5988 | /** |
Seigo Nonaka | 6d6cd68 | 2017-06-22 08:22:18 -0700 | [diff] [blame] | 5989 | * Returns true if the context can load unsafe resources, e.g. fonts. |
| 5990 | * @hide |
| 5991 | */ |
| 5992 | public abstract boolean canLoadUnsafeResources(); |
| 5993 | |
| 5994 | /** |
Tony Mak | 46aabe5 | 2016-11-14 12:53:06 +0000 | [diff] [blame] | 5995 | * @hide |
| 5996 | */ |
| 5997 | public IBinder getActivityToken() { |
| 5998 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 5999 | } |
| 6000 | |
| 6001 | /** |
| 6002 | * @hide |
| 6003 | */ |
| 6004 | @Nullable |
| 6005 | public IServiceConnection getServiceDispatcher(ServiceConnection conn, Handler handler, |
| 6006 | int flags) { |
| 6007 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 6008 | } |
| 6009 | |
| 6010 | /** |
| 6011 | * @hide |
| 6012 | */ |
| 6013 | public IApplicationThread getIApplicationThread() { |
| 6014 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 6015 | } |
Tony Mak | bf9928d | 2016-12-22 11:02:45 +0000 | [diff] [blame] | 6016 | |
| 6017 | /** |
| 6018 | * @hide |
| 6019 | */ |
| 6020 | public Handler getMainThreadHandler() { |
| 6021 | throw new RuntimeException("Not implemented. Must override in a subclass."); |
| 6022 | } |
Adam Lesinski | a82b626 | 2017-03-21 16:56:17 -0700 | [diff] [blame] | 6023 | |
| 6024 | /** |
Felipe Leme | bb567ae | 2017-10-04 09:56:21 -0700 | [diff] [blame] | 6025 | * @hide |
| 6026 | */ |
| 6027 | public AutofillClient getAutofillClient() { |
| 6028 | return null; |
| 6029 | } |
| 6030 | |
| 6031 | /** |
| 6032 | * @hide |
| 6033 | */ |
Svet Ganov | 47b37aa | 2018-02-16 00:11:39 -0800 | [diff] [blame] | 6034 | public void setAutofillClient(@SuppressWarnings("unused") AutofillClient client) { |
Felipe Leme | bb567ae | 2017-10-04 09:56:21 -0700 | [diff] [blame] | 6035 | } |
| 6036 | |
| 6037 | /** |
Svetoslav Ganov | 24c9045 | 2017-12-27 15:17:14 -0800 | [diff] [blame] | 6038 | * @hide |
| 6039 | */ |
Felipe Leme | cbf7f26 | 2019-04-17 13:57:59 -0700 | [diff] [blame] | 6040 | @Nullable |
| 6041 | public ContentCaptureClient getContentCaptureClient() { |
| 6042 | return null; |
| 6043 | } |
| 6044 | |
| 6045 | /** |
| 6046 | * @hide |
| 6047 | */ |
Felipe Leme | a4f39cd | 2019-02-19 15:08:59 -0800 | [diff] [blame] | 6048 | public final boolean isAutofillCompatibilityEnabled() { |
| 6049 | final AutofillOptions options = getAutofillOptions(); |
| 6050 | return options != null && options.compatModeEnabled; |
| 6051 | } |
| 6052 | |
| 6053 | /** |
| 6054 | * @hide |
| 6055 | */ |
| 6056 | @Nullable |
| 6057 | public AutofillOptions getAutofillOptions() { |
| 6058 | return null; |
Svetoslav Ganov | 24c9045 | 2017-12-27 15:17:14 -0800 | [diff] [blame] | 6059 | } |
| 6060 | |
| 6061 | /** |
| 6062 | * @hide |
| 6063 | */ |
Svet Ganov | 47b37aa | 2018-02-16 00:11:39 -0800 | [diff] [blame] | 6064 | @TestApi |
Felipe Leme | a4f39cd | 2019-02-19 15:08:59 -0800 | [diff] [blame] | 6065 | public void setAutofillOptions(@SuppressWarnings("unused") @Nullable AutofillOptions options) { |
Svetoslav Ganov | 24c9045 | 2017-12-27 15:17:14 -0800 | [diff] [blame] | 6066 | } |
| 6067 | |
| 6068 | /** |
Felipe Leme | 326f15a | 2019-02-19 09:42:24 -0800 | [diff] [blame] | 6069 | * 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] | 6070 | * |
| 6071 | * @hide |
| 6072 | */ |
Felipe Leme | 326f15a | 2019-02-19 09:42:24 -0800 | [diff] [blame] | 6073 | @Nullable |
| 6074 | public ContentCaptureOptions getContentCaptureOptions() { |
| 6075 | return null; |
Felipe Leme | ecb08be | 2018-11-27 15:48:47 -0800 | [diff] [blame] | 6076 | } |
| 6077 | |
| 6078 | /** |
| 6079 | * @hide |
| 6080 | */ |
Felipe Leme | 326f15a | 2019-02-19 09:42:24 -0800 | [diff] [blame] | 6081 | @TestApi |
| 6082 | public void setContentCaptureOptions( |
| 6083 | @SuppressWarnings("unused") @Nullable ContentCaptureOptions options) { |
Felipe Leme | ecb08be | 2018-11-27 15:48:47 -0800 | [diff] [blame] | 6084 | } |
| 6085 | |
| 6086 | /** |
Adam Lesinski | a82b626 | 2017-03-21 16:56:17 -0700 | [diff] [blame] | 6087 | * Throws an exception if the Context is using system resources, |
| 6088 | * which are non-runtime-overlay-themable and may show inconsistent UI. |
| 6089 | * @hide |
| 6090 | */ |
| 6091 | public void assertRuntimeOverlayThemable() { |
| 6092 | // Resources.getSystem() is a singleton and the only Resources not managed by |
| 6093 | // ResourcesManager; therefore Resources.getSystem() is not themable. |
| 6094 | if (getResources() == Resources.getSystem()) { |
| 6095 | throw new IllegalArgumentException("Non-UI context used to display UI; " |
| 6096 | + "get a UI context from ActivityThread#getSystemUiContext()"); |
| 6097 | } |
| 6098 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 6099 | } |