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 19 import android.annotation.CallbackExecutor; 20 import android.annotation.FlaggedApi; 21 import android.annotation.NonNull; 22 import android.annotation.Nullable; 23 import android.annotation.RequiresPermission; 24 import android.annotation.SuppressLint; 25 import android.annotation.SystemApi; 26 import android.annotation.TestApi; 27 import android.annotation.UiContext; 28 import android.app.BroadcastOptions; 29 import android.app.IApplicationThread; 30 import android.app.IServiceConnection; 31 import android.app.compat.CompatChanges; 32 import android.compat.annotation.UnsupportedAppUsage; 33 import android.content.pm.ApplicationInfo; 34 import android.content.pm.PackageManager; 35 import android.content.res.AssetManager; 36 import android.content.res.Configuration; 37 import android.content.res.Resources; 38 import android.database.DatabaseErrorHandler; 39 import android.database.sqlite.SQLiteDatabase; 40 import android.database.sqlite.SQLiteDatabase.CursorFactory; 41 import android.graphics.Bitmap; 42 import android.graphics.drawable.Drawable; 43 import android.net.Uri; 44 import android.os.Build; 45 import android.os.Bundle; 46 import android.os.Handler; 47 import android.os.IBinder; 48 import android.os.Looper; 49 import android.os.UserHandle; 50 import android.view.Display; 51 import android.view.DisplayAdjustments; 52 import android.view.WindowManager.LayoutParams.WindowType; 53 import android.view.autofill.AutofillManager.AutofillClient; 54 55 import com.android.internal.annotations.GuardedBy; 56 import com.android.internal.annotations.VisibleForTesting; 57 58 import java.io.File; 59 import java.io.FileInputStream; 60 import java.io.FileNotFoundException; 61 import java.io.FileOutputStream; 62 import java.io.IOException; 63 import java.io.InputStream; 64 import java.util.ArrayList; 65 import java.util.Collection; 66 import java.util.List; 67 import java.util.concurrent.Executor; 68 import java.util.function.IntConsumer; 69 70 /** 71 * Proxying implementation of Context that simply delegates all of its calls to 72 * another Context. Can be subclassed to modify behavior without changing 73 * the original Context. 74 */ 75 @android.ravenwood.annotation.RavenwoodKeepWholeClass 76 public class ContextWrapper extends Context { 77 @UnsupportedAppUsage 78 Context mBase; 79 80 /** 81 * A list to store {@link ComponentCallbacks} which 82 * passes to {@link #registerComponentCallbacks(ComponentCallbacks)} before 83 * {@link #attachBaseContext(Context)}. 84 * It is to provide compatibility behavior for Application targeted prior to 85 * {@link Build.VERSION_CODES#TIRAMISU}. 86 * 87 * @hide 88 */ 89 @GuardedBy("mLock") 90 @VisibleForTesting 91 public List<ComponentCallbacks> mCallbacksRegisteredToSuper; 92 93 private final Object mLock = new Object(); 94 ContextWrapper(Context base)95 public ContextWrapper(Context base) { 96 mBase = base; 97 } 98 99 /** 100 * Set the base context for this ContextWrapper. All calls will then be 101 * delegated to the base context. Throws 102 * IllegalStateException if a base context has already been set. 103 * 104 * @param base The new base context for this wrapper. 105 */ attachBaseContext(Context base)106 protected void attachBaseContext(Context base) { 107 if (mBase != null) { 108 throw new IllegalStateException("Base context already set"); 109 } 110 mBase = base; 111 } 112 113 /** 114 * @return the base context as set by the constructor or setBaseContext 115 */ getBaseContext()116 public Context getBaseContext() { 117 return mBase; 118 } 119 120 @Override getAssets()121 public AssetManager getAssets() { 122 return mBase.getAssets(); 123 } 124 125 @Override getResources()126 public Resources getResources() { 127 return mBase.getResources(); 128 } 129 130 @Override getPackageManager()131 public PackageManager getPackageManager() { 132 return mBase.getPackageManager(); 133 } 134 135 @Override getContentResolver()136 public ContentResolver getContentResolver() { 137 return mBase.getContentResolver(); 138 } 139 140 @Override getMainLooper()141 public Looper getMainLooper() { 142 return mBase.getMainLooper(); 143 } 144 145 @Override getMainExecutor()146 public Executor getMainExecutor() { 147 return mBase.getMainExecutor(); 148 } 149 150 @Override getApplicationContext()151 public Context getApplicationContext() { 152 return mBase.getApplicationContext(); 153 } 154 155 @Override setTheme(int resid)156 public void setTheme(int resid) { 157 mBase.setTheme(resid); 158 } 159 160 /** @hide */ 161 @Override 162 @UnsupportedAppUsage getThemeResId()163 public int getThemeResId() { 164 return mBase.getThemeResId(); 165 } 166 167 @Override getTheme()168 public Resources.Theme getTheme() { 169 return mBase.getTheme(); 170 } 171 172 @Override getClassLoader()173 public ClassLoader getClassLoader() { 174 return mBase.getClassLoader(); 175 } 176 177 @Override getPackageName()178 public String getPackageName() { 179 return mBase.getPackageName(); 180 } 181 182 /** @hide */ 183 @Override 184 @UnsupportedAppUsage getBasePackageName()185 public String getBasePackageName() { 186 return mBase.getBasePackageName(); 187 } 188 189 /** @hide */ 190 @Override getOpPackageName()191 public String getOpPackageName() { 192 return mBase.getOpPackageName(); 193 } 194 195 /** @hide */ 196 @Override getAttributionTag()197 public @Nullable String getAttributionTag() { 198 return mBase.getAttributionTag(); 199 } 200 201 @Override getParams()202 public @Nullable ContextParams getParams() { 203 return mBase.getParams(); 204 } 205 206 @Override getApplicationInfo()207 public ApplicationInfo getApplicationInfo() { 208 return mBase.getApplicationInfo(); 209 } 210 211 @Override getPackageResourcePath()212 public String getPackageResourcePath() { 213 return mBase.getPackageResourcePath(); 214 } 215 216 @Override getPackageCodePath()217 public String getPackageCodePath() { 218 return mBase.getPackageCodePath(); 219 } 220 221 @Override getSharedPreferences(String name, int mode)222 public SharedPreferences getSharedPreferences(String name, int mode) { 223 return mBase.getSharedPreferences(name, mode); 224 } 225 226 /** @removed */ 227 @Override getSharedPreferences(File file, int mode)228 public SharedPreferences getSharedPreferences(File file, int mode) { 229 return mBase.getSharedPreferences(file, mode); 230 } 231 232 /** @hide */ 233 @Override reloadSharedPreferences()234 public void reloadSharedPreferences() { 235 mBase.reloadSharedPreferences(); 236 } 237 238 @Override moveSharedPreferencesFrom(Context sourceContext, String name)239 public boolean moveSharedPreferencesFrom(Context sourceContext, String name) { 240 return mBase.moveSharedPreferencesFrom(sourceContext, name); 241 } 242 243 @Override deleteSharedPreferences(String name)244 public boolean deleteSharedPreferences(String name) { 245 return mBase.deleteSharedPreferences(name); 246 } 247 248 @Override openFileInput(String name)249 public FileInputStream openFileInput(String name) 250 throws FileNotFoundException { 251 return mBase.openFileInput(name); 252 } 253 254 @Override openFileOutput(String name, int mode)255 public FileOutputStream openFileOutput(String name, int mode) 256 throws FileNotFoundException { 257 return mBase.openFileOutput(name, mode); 258 } 259 260 @Override deleteFile(String name)261 public boolean deleteFile(String name) { 262 return mBase.deleteFile(name); 263 } 264 265 @Override getFileStreamPath(String name)266 public File getFileStreamPath(String name) { 267 return mBase.getFileStreamPath(name); 268 } 269 270 /** @removed */ 271 @Override getSharedPreferencesPath(String name)272 public File getSharedPreferencesPath(String name) { 273 return mBase.getSharedPreferencesPath(name); 274 } 275 276 @Override fileList()277 public String[] fileList() { 278 return mBase.fileList(); 279 } 280 281 @Override getDataDir()282 public File getDataDir() { 283 return mBase.getDataDir(); 284 } 285 286 @Override getFilesDir()287 public File getFilesDir() { 288 return mBase.getFilesDir(); 289 } 290 291 /** 292 * {@inheritDoc Context#getCrateDir()} 293 * @hide 294 */ 295 @NonNull 296 @Override getCrateDir(@onNull String cratedId)297 public File getCrateDir(@NonNull String cratedId) { 298 return mBase.getCrateDir(cratedId); 299 } 300 301 @Override getNoBackupFilesDir()302 public File getNoBackupFilesDir() { 303 return mBase.getNoBackupFilesDir(); 304 } 305 306 @Override getExternalFilesDir(@ullable String type)307 public @Nullable File getExternalFilesDir(@Nullable String type) { 308 return mBase.getExternalFilesDir(type); 309 } 310 311 @Override getExternalFilesDirs(String type)312 public File[] getExternalFilesDirs(String type) { 313 return mBase.getExternalFilesDirs(type); 314 } 315 316 @Override getObbDir()317 public File getObbDir() { 318 return mBase.getObbDir(); 319 } 320 321 @Override getObbDirs()322 public File[] getObbDirs() { 323 return mBase.getObbDirs(); 324 } 325 326 @Override getCacheDir()327 public File getCacheDir() { 328 return mBase.getCacheDir(); 329 } 330 331 @Override getCodeCacheDir()332 public File getCodeCacheDir() { 333 return mBase.getCodeCacheDir(); 334 } 335 336 @Override getExternalCacheDir()337 public @Nullable File getExternalCacheDir() { 338 return mBase.getExternalCacheDir(); 339 } 340 341 @Override getExternalCacheDirs()342 public File[] getExternalCacheDirs() { 343 return mBase.getExternalCacheDirs(); 344 } 345 346 @Override getExternalMediaDirs()347 public File[] getExternalMediaDirs() { 348 return mBase.getExternalMediaDirs(); 349 } 350 351 @Override getDir(String name, int mode)352 public File getDir(String name, int mode) { 353 return mBase.getDir(name, mode); 354 } 355 356 357 /** @hide **/ 358 @Override getPreloadsFileCache()359 public @Nullable File getPreloadsFileCache() { 360 return mBase.getPreloadsFileCache(); 361 } 362 363 @Override openOrCreateDatabase(String name, int mode, CursorFactory factory)364 public SQLiteDatabase openOrCreateDatabase(String name, int mode, CursorFactory factory) { 365 return mBase.openOrCreateDatabase(name, mode, factory); 366 } 367 368 @Override openOrCreateDatabase(String name, int mode, CursorFactory factory, @Nullable DatabaseErrorHandler errorHandler)369 public SQLiteDatabase openOrCreateDatabase(String name, int mode, CursorFactory factory, 370 @Nullable DatabaseErrorHandler errorHandler) { 371 return mBase.openOrCreateDatabase(name, mode, factory, errorHandler); 372 } 373 374 @Override moveDatabaseFrom(Context sourceContext, String name)375 public boolean moveDatabaseFrom(Context sourceContext, String name) { 376 return mBase.moveDatabaseFrom(sourceContext, name); 377 } 378 379 @Override deleteDatabase(String name)380 public boolean deleteDatabase(String name) { 381 return mBase.deleteDatabase(name); 382 } 383 384 @Override getDatabasePath(String name)385 public File getDatabasePath(String name) { 386 return mBase.getDatabasePath(name); 387 } 388 389 @Override databaseList()390 public String[] databaseList() { 391 return mBase.databaseList(); 392 } 393 394 @Override 395 @Deprecated getWallpaper()396 public Drawable getWallpaper() { 397 return mBase.getWallpaper(); 398 } 399 400 @Override 401 @Deprecated peekWallpaper()402 public Drawable peekWallpaper() { 403 return mBase.peekWallpaper(); 404 } 405 406 @Override 407 @Deprecated getWallpaperDesiredMinimumWidth()408 public int getWallpaperDesiredMinimumWidth() { 409 return mBase.getWallpaperDesiredMinimumWidth(); 410 } 411 412 @Override 413 @Deprecated getWallpaperDesiredMinimumHeight()414 public int getWallpaperDesiredMinimumHeight() { 415 return mBase.getWallpaperDesiredMinimumHeight(); 416 } 417 418 @Override 419 @Deprecated setWallpaper(Bitmap bitmap)420 public void setWallpaper(Bitmap bitmap) throws IOException { 421 mBase.setWallpaper(bitmap); 422 } 423 424 @Override 425 @Deprecated setWallpaper(InputStream data)426 public void setWallpaper(InputStream data) throws IOException { 427 mBase.setWallpaper(data); 428 } 429 430 @Override 431 @Deprecated clearWallpaper()432 public void clearWallpaper() throws IOException { 433 mBase.clearWallpaper(); 434 } 435 436 @Override startActivity(Intent intent)437 public void startActivity(Intent intent) { 438 mBase.startActivity(intent); 439 } 440 441 /** @hide */ 442 @Override startActivityAsUser(Intent intent, UserHandle user)443 public void startActivityAsUser(Intent intent, UserHandle user) { 444 mBase.startActivityAsUser(intent, user); 445 } 446 447 /** @hide **/ startActivityForResult( String who, Intent intent, int requestCode, @Nullable Bundle options)448 public void startActivityForResult( 449 String who, Intent intent, int requestCode, @Nullable Bundle options) { 450 mBase.startActivityForResult(who, intent, requestCode, options); 451 } 452 453 /** @hide **/ canStartActivityForResult()454 public boolean canStartActivityForResult() { 455 return mBase.canStartActivityForResult(); 456 } 457 458 @Override startActivity(Intent intent, @Nullable Bundle options)459 public void startActivity(Intent intent, @Nullable Bundle options) { 460 mBase.startActivity(intent, options); 461 } 462 463 /** @hide */ 464 @Override startActivityAsUser(Intent intent, @Nullable Bundle options, UserHandle user)465 public void startActivityAsUser(Intent intent, @Nullable Bundle options, UserHandle user) { 466 mBase.startActivityAsUser(intent, options, user); 467 } 468 469 @Override startActivities(Intent[] intents)470 public void startActivities(Intent[] intents) { 471 mBase.startActivities(intents); 472 } 473 474 @Override startActivities(Intent[] intents, @Nullable Bundle options)475 public void startActivities(Intent[] intents, @Nullable Bundle options) { 476 mBase.startActivities(intents, options); 477 } 478 479 /** @hide */ 480 @Override startActivitiesAsUser(Intent[] intents, @Nullable Bundle options, UserHandle userHandle)481 public int startActivitiesAsUser(Intent[] intents, @Nullable Bundle options, 482 UserHandle userHandle) { 483 return mBase.startActivitiesAsUser(intents, options, userHandle); 484 } 485 486 @Override startIntentSender(IntentSender intent, @Nullable Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)487 public void startIntentSender(IntentSender intent, 488 @Nullable Intent fillInIntent, int flagsMask, int flagsValues, 489 int extraFlags) 490 throws IntentSender.SendIntentException { 491 mBase.startIntentSender(intent, fillInIntent, flagsMask, 492 flagsValues, extraFlags); 493 } 494 495 @Override startIntentSender(IntentSender intent, @Nullable Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags, @Nullable Bundle options)496 public void startIntentSender(IntentSender intent, 497 @Nullable Intent fillInIntent, int flagsMask, int flagsValues, 498 int extraFlags, @Nullable Bundle options) 499 throws IntentSender.SendIntentException { 500 mBase.startIntentSender(intent, fillInIntent, flagsMask, 501 flagsValues, extraFlags, options); 502 } 503 504 @Override sendBroadcast(Intent intent)505 public void sendBroadcast(Intent intent) { 506 mBase.sendBroadcast(intent); 507 } 508 509 @Override sendBroadcast(Intent intent, @Nullable String receiverPermission)510 public void sendBroadcast(Intent intent, @Nullable String receiverPermission) { 511 mBase.sendBroadcast(intent, receiverPermission); 512 } 513 514 /** @hide */ 515 @Override sendBroadcastMultiplePermissions(@onNull Intent intent, @NonNull String[] receiverPermissions)516 public void sendBroadcastMultiplePermissions(@NonNull Intent intent, 517 @NonNull String[] receiverPermissions) { 518 mBase.sendBroadcastMultiplePermissions(intent, receiverPermissions); 519 } 520 521 /** @hide */ 522 @Override sendBroadcastMultiplePermissions(@onNull Intent intent, @NonNull String[] receiverPermissions, @Nullable String[] excludedPermissions, @Nullable String[] excludedPackages, @Nullable BroadcastOptions options)523 public void sendBroadcastMultiplePermissions(@NonNull Intent intent, 524 @NonNull String[] receiverPermissions, @Nullable String[] excludedPermissions, 525 @Nullable String[] excludedPackages, @Nullable BroadcastOptions options) { 526 mBase.sendBroadcastMultiplePermissions(intent, receiverPermissions, excludedPermissions, 527 excludedPackages, options); 528 } 529 530 /** @hide */ 531 @Override sendBroadcastMultiplePermissions(@onNull Intent intent, @NonNull String[] receiverPermissions, @Nullable Bundle options)532 public void sendBroadcastMultiplePermissions(@NonNull Intent intent, 533 @NonNull String[] receiverPermissions, @Nullable Bundle options) { 534 mBase.sendBroadcastMultiplePermissions(intent, receiverPermissions, options); 535 } 536 537 /** @hide */ 538 @Override sendBroadcastAsUserMultiplePermissions(Intent intent, UserHandle user, String[] receiverPermissions)539 public void sendBroadcastAsUserMultiplePermissions(Intent intent, UserHandle user, 540 String[] receiverPermissions) { 541 mBase.sendBroadcastAsUserMultiplePermissions(intent, user, receiverPermissions); 542 } 543 544 @Override sendBroadcast(@onNull Intent intent, @Nullable String receiverPermission, @Nullable Bundle options)545 public void sendBroadcast(@NonNull Intent intent, @Nullable String receiverPermission, 546 @Nullable Bundle options) { 547 mBase.sendBroadcast(intent, receiverPermission, options); 548 } 549 550 /** @hide */ 551 @Override sendBroadcast(Intent intent, @Nullable String receiverPermission, int appOp)552 public void sendBroadcast(Intent intent, @Nullable String receiverPermission, int appOp) { 553 mBase.sendBroadcast(intent, receiverPermission, appOp); 554 } 555 556 @Override sendOrderedBroadcast(Intent intent, @Nullable String receiverPermission)557 public void sendOrderedBroadcast(Intent intent, 558 @Nullable String receiverPermission) { 559 mBase.sendOrderedBroadcast(intent, receiverPermission); 560 } 561 562 @SuppressLint("AndroidFrameworkRequiresPermission") 563 @Override sendOrderedBroadcast(@onNull Intent intent, @Nullable String receiverPermission, @Nullable Bundle options)564 public void sendOrderedBroadcast(@NonNull Intent intent, 565 @Nullable String receiverPermission, 566 @Nullable Bundle options) { 567 mBase.sendOrderedBroadcast(intent, receiverPermission, options); 568 } 569 570 @Override sendOrderedBroadcast( Intent intent, @Nullable String receiverPermission, @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras)571 public void sendOrderedBroadcast( 572 Intent intent, @Nullable String receiverPermission, 573 @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, 574 int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras) { 575 mBase.sendOrderedBroadcast(intent, receiverPermission, 576 resultReceiver, scheduler, initialCode, 577 initialData, initialExtras); 578 } 579 580 @Override sendOrderedBroadcast( @onNull Intent intent, @Nullable String receiverPermission, @Nullable Bundle options, @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras)581 public void sendOrderedBroadcast( 582 @NonNull Intent intent, @Nullable String receiverPermission, @Nullable Bundle options, 583 @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, 584 int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras) { 585 mBase.sendOrderedBroadcast(intent, receiverPermission, 586 options, resultReceiver, scheduler, initialCode, 587 initialData, initialExtras); 588 } 589 590 /** @hide */ 591 @Override sendOrderedBroadcast( Intent intent, @Nullable String receiverPermission, int appOp, @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras)592 public void sendOrderedBroadcast( 593 Intent intent, @Nullable String receiverPermission, int appOp, 594 @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, 595 int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras) { 596 mBase.sendOrderedBroadcast(intent, receiverPermission, appOp, 597 resultReceiver, scheduler, initialCode, 598 initialData, initialExtras); 599 } 600 601 @Override sendBroadcastAsUser(Intent intent, UserHandle user)602 public void sendBroadcastAsUser(Intent intent, UserHandle user) { 603 mBase.sendBroadcastAsUser(intent, user); 604 } 605 606 @Override sendBroadcastAsUser(Intent intent, UserHandle user, String receiverPermission)607 public void sendBroadcastAsUser(Intent intent, UserHandle user, 608 String receiverPermission) { 609 mBase.sendBroadcastAsUser(intent, user, receiverPermission); 610 } 611 612 /** @hide */ 613 @Override sendBroadcastAsUser(Intent intent, UserHandle user, @Nullable String receiverPermission, @Nullable Bundle options)614 public void sendBroadcastAsUser(Intent intent, UserHandle user, 615 @Nullable String receiverPermission, @Nullable Bundle options) { 616 mBase.sendBroadcastAsUser(intent, user, receiverPermission, options); 617 } 618 619 /** @hide */ 620 @Override sendBroadcastAsUser(Intent intent, UserHandle user, @Nullable String receiverPermission, int appOp)621 public void sendBroadcastAsUser(Intent intent, UserHandle user, 622 @Nullable String receiverPermission, int appOp) { 623 mBase.sendBroadcastAsUser(intent, user, receiverPermission, appOp); 624 } 625 626 @Override sendOrderedBroadcastAsUser(Intent intent, UserHandle user, @Nullable String receiverPermission, @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras)627 public void sendOrderedBroadcastAsUser(Intent intent, UserHandle user, 628 @Nullable String receiverPermission, @Nullable BroadcastReceiver resultReceiver, 629 @Nullable Handler scheduler, int initialCode, @Nullable String initialData, 630 @Nullable Bundle initialExtras) { 631 mBase.sendOrderedBroadcastAsUser(intent, user, receiverPermission, resultReceiver, 632 scheduler, initialCode, initialData, initialExtras); 633 } 634 635 /** @hide */ 636 @Override sendOrderedBroadcastAsUser(Intent intent, UserHandle user, @Nullable String receiverPermission, int appOp, @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras)637 public void sendOrderedBroadcastAsUser(Intent intent, UserHandle user, 638 @Nullable String receiverPermission, int appOp, 639 @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, 640 int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras) { 641 mBase.sendOrderedBroadcastAsUser(intent, user, receiverPermission, appOp, resultReceiver, 642 scheduler, initialCode, initialData, initialExtras); 643 } 644 645 /** @hide */ 646 @Override sendOrderedBroadcastAsUser(Intent intent, UserHandle user, @Nullable String receiverPermission, int appOp, @Nullable Bundle options, @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras)647 public void sendOrderedBroadcastAsUser(Intent intent, UserHandle user, 648 @Nullable String receiverPermission, int appOp, @Nullable Bundle options, 649 @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, 650 int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras) { 651 mBase.sendOrderedBroadcastAsUser(intent, user, receiverPermission, appOp, options, 652 resultReceiver, scheduler, initialCode, initialData, initialExtras); 653 } 654 655 /** @hide */ 656 @Override sendOrderedBroadcastAsUserMultiplePermissions(Intent intent, UserHandle user, @Nullable String[] receiverPermission, int appOp, @Nullable Bundle options, @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras)657 public void sendOrderedBroadcastAsUserMultiplePermissions(Intent intent, UserHandle user, 658 @Nullable String[] receiverPermission, int appOp, @Nullable Bundle options, 659 @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, 660 int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras) { 661 mBase.sendOrderedBroadcastAsUserMultiplePermissions(intent, user, receiverPermission, appOp, 662 options, resultReceiver, scheduler, initialCode, initialData, initialExtras); 663 } 664 665 @Override sendOrderedBroadcast(@equiresPermission @onNull Intent intent, @Nullable String receiverPermission, @Nullable String receiverAppOp, @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras)666 public void sendOrderedBroadcast(@RequiresPermission @NonNull Intent intent, 667 @Nullable String receiverPermission, @Nullable String receiverAppOp, 668 @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, 669 int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras) { 670 mBase.sendOrderedBroadcast(intent, receiverPermission, receiverAppOp, resultReceiver, 671 scheduler, initialCode, initialData, initialExtras); 672 } 673 674 /** @hide */ 675 @Override sendOrderedBroadcastMultiplePermissions( @onNull Intent intent, @NonNull String[] receiverPermissions, @Nullable String receiverAppOp, @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras, @Nullable Bundle options)676 public void sendOrderedBroadcastMultiplePermissions( 677 @NonNull Intent intent, @NonNull String[] receiverPermissions, 678 @Nullable String receiverAppOp, @Nullable BroadcastReceiver resultReceiver, 679 @Nullable Handler scheduler, int initialCode, @Nullable String initialData, 680 @Nullable Bundle initialExtras, @Nullable Bundle options) { 681 mBase.sendOrderedBroadcastMultiplePermissions(intent, receiverPermissions, receiverAppOp, 682 resultReceiver, scheduler, initialCode, initialData, initialExtras, options); 683 } 684 685 @Override sendOrderedBroadcast(@equiresPermission @onNull Intent intent, int initialCode, @Nullable String receiverPermission, @Nullable String receiverAppOp, @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, @Nullable String initialData, @Nullable Bundle initialExtras, @Nullable Bundle options)686 public void sendOrderedBroadcast(@RequiresPermission @NonNull Intent intent, int initialCode, 687 @Nullable String receiverPermission, @Nullable String receiverAppOp, 688 @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, 689 @Nullable String initialData, @Nullable Bundle initialExtras, 690 @Nullable Bundle options) { 691 mBase.sendOrderedBroadcast(intent, initialCode, receiverPermission, receiverAppOp, 692 resultReceiver, scheduler, initialData, initialExtras, options); 693 } 694 695 @Override 696 @Deprecated sendStickyBroadcast(Intent intent)697 public void sendStickyBroadcast(Intent intent) { 698 mBase.sendStickyBroadcast(intent); 699 } 700 701 /** 702 * <p>Perform a {@link #sendBroadcast(Intent)} that is "sticky," meaning the 703 * Intent you are sending stays around after the broadcast is complete, 704 * so that others can quickly retrieve that data through the return 705 * value of {@link #registerReceiver(BroadcastReceiver, IntentFilter)}. In 706 * all other ways, this behaves the same as 707 * {@link #sendBroadcast(Intent)}. 708 * 709 * @deprecated Sticky broadcasts should not be used. They provide no security (anyone 710 * can access them), no protection (anyone can modify them), and many other problems. 711 * The recommended pattern is to use a non-sticky broadcast to report that <em>something</em> 712 * has changed, with another mechanism for apps to retrieve the current value whenever 713 * desired. 714 * 715 * @param intent The Intent to broadcast; all receivers matching this 716 * Intent will receive the broadcast, and the Intent will be held to 717 * be re-broadcast to future receivers. 718 * @param options (optional) Additional sending options, generated from a 719 * {@link android.app.BroadcastOptions}. 720 * 721 * @see #sendBroadcast(Intent) 722 * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle) 723 */ 724 @Override 725 @Deprecated sendStickyBroadcast(@onNull Intent intent, @Nullable Bundle options)726 public void sendStickyBroadcast(@NonNull Intent intent, @Nullable Bundle options) { 727 mBase.sendStickyBroadcast(intent, options); 728 } 729 730 @Override 731 @Deprecated sendStickyOrderedBroadcast(Intent intent, @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras)732 public void sendStickyOrderedBroadcast(Intent intent, 733 @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, 734 int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras) { 735 mBase.sendStickyOrderedBroadcast(intent, 736 resultReceiver, scheduler, initialCode, 737 initialData, initialExtras); 738 } 739 740 @Override 741 @Deprecated removeStickyBroadcast(Intent intent)742 public void removeStickyBroadcast(Intent intent) { 743 mBase.removeStickyBroadcast(intent); 744 } 745 746 @Override 747 @Deprecated sendStickyBroadcastAsUser(Intent intent, UserHandle user)748 public void sendStickyBroadcastAsUser(Intent intent, UserHandle user) { 749 mBase.sendStickyBroadcastAsUser(intent, user); 750 } 751 752 /** @hide */ 753 @Override 754 @Deprecated sendStickyBroadcastAsUser(Intent intent, UserHandle user, @Nullable Bundle options)755 public void sendStickyBroadcastAsUser(Intent intent, UserHandle user, 756 @Nullable Bundle options) { 757 mBase.sendStickyBroadcastAsUser(intent, user, options); 758 } 759 760 @Override 761 @Deprecated sendStickyOrderedBroadcastAsUser(Intent intent, UserHandle user, @Nullable BroadcastReceiver resultReceiver, @Nullable Handler scheduler, int initialCode, @Nullable String initialData, @Nullable Bundle initialExtras)762 public void sendStickyOrderedBroadcastAsUser(Intent intent, 763 UserHandle user, @Nullable BroadcastReceiver resultReceiver, 764 @Nullable Handler scheduler, int initialCode, @Nullable String initialData, 765 @Nullable Bundle initialExtras) { 766 mBase.sendStickyOrderedBroadcastAsUser(intent, user, resultReceiver, 767 scheduler, initialCode, initialData, initialExtras); 768 } 769 770 @Override 771 @Deprecated removeStickyBroadcastAsUser(Intent intent, UserHandle user)772 public void removeStickyBroadcastAsUser(Intent intent, UserHandle user) { 773 mBase.removeStickyBroadcastAsUser(intent, user); 774 } 775 776 @Override registerReceiver(@ullable BroadcastReceiver receiver, IntentFilter filter)777 public Intent registerReceiver(@Nullable BroadcastReceiver receiver, IntentFilter filter) { 778 return mBase.registerReceiver(receiver, filter); 779 } 780 781 @Override registerReceiver(@ullable BroadcastReceiver receiver, IntentFilter filter, int flags)782 public Intent registerReceiver(@Nullable BroadcastReceiver receiver, IntentFilter filter, 783 int flags) { 784 return mBase.registerReceiver(receiver, filter, flags); 785 } 786 787 @Override registerReceiver(@ullable BroadcastReceiver receiver, IntentFilter filter, @Nullable String broadcastPermission, @Nullable Handler scheduler)788 public Intent registerReceiver(@Nullable BroadcastReceiver receiver, IntentFilter filter, 789 @Nullable String broadcastPermission, @Nullable Handler scheduler) { 790 return mBase.registerReceiver(receiver, filter, broadcastPermission, 791 scheduler); 792 } 793 794 @Override registerReceiver(@ullable BroadcastReceiver receiver, IntentFilter filter, @Nullable String broadcastPermission, @Nullable Handler scheduler, int flags)795 public Intent registerReceiver(@Nullable BroadcastReceiver receiver, IntentFilter filter, 796 @Nullable String broadcastPermission, @Nullable Handler scheduler, int flags) { 797 return mBase.registerReceiver(receiver, filter, broadcastPermission, 798 scheduler, flags); 799 } 800 801 /** @hide */ 802 @Override 803 @Nullable registerReceiverForAllUsers(@ullable BroadcastReceiver receiver, @NonNull IntentFilter filter, @Nullable String broadcastPermission, @Nullable Handler scheduler)804 public Intent registerReceiverForAllUsers(@Nullable BroadcastReceiver receiver, 805 @NonNull IntentFilter filter, @Nullable String broadcastPermission, 806 @Nullable Handler scheduler) { 807 return mBase.registerReceiverForAllUsers(receiver, filter, broadcastPermission, 808 scheduler); 809 } 810 811 /** @hide */ 812 @Override 813 @Nullable registerReceiverForAllUsers(@ullable BroadcastReceiver receiver, @NonNull IntentFilter filter, @Nullable String broadcastPermission, @Nullable Handler scheduler, int flags)814 public Intent registerReceiverForAllUsers(@Nullable BroadcastReceiver receiver, 815 @NonNull IntentFilter filter, @Nullable String broadcastPermission, 816 @Nullable Handler scheduler, int flags) { 817 return mBase.registerReceiverForAllUsers(receiver, filter, broadcastPermission, 818 scheduler, flags); 819 } 820 821 /** @hide */ 822 @Override 823 @UnsupportedAppUsage registerReceiverAsUser(@ullable BroadcastReceiver receiver, UserHandle user, IntentFilter filter, @Nullable String broadcastPermission, @Nullable Handler scheduler)824 public Intent registerReceiverAsUser(@Nullable BroadcastReceiver receiver, UserHandle user, 825 IntentFilter filter, @Nullable String broadcastPermission, 826 @Nullable Handler scheduler) { 827 return mBase.registerReceiverAsUser(receiver, user, filter, broadcastPermission, 828 scheduler); 829 } 830 831 /** @hide */ 832 @Override 833 @UnsupportedAppUsage registerReceiverAsUser(@ullable BroadcastReceiver receiver, UserHandle user, IntentFilter filter, @Nullable String broadcastPermission, @Nullable Handler scheduler, int flags)834 public Intent registerReceiverAsUser(@Nullable BroadcastReceiver receiver, UserHandle user, 835 IntentFilter filter, @Nullable String broadcastPermission, 836 @Nullable Handler scheduler, int flags) { 837 return mBase.registerReceiverAsUser(receiver, user, filter, broadcastPermission, 838 scheduler, flags); 839 } 840 841 @Override unregisterReceiver(BroadcastReceiver receiver)842 public void unregisterReceiver(BroadcastReceiver receiver) { 843 mBase.unregisterReceiver(receiver); 844 } 845 846 /** @hide */ 847 @Override 848 @NonNull getRegisteredIntentFilters(@onNull BroadcastReceiver receiver)849 public List<IntentFilter> getRegisteredIntentFilters(@NonNull BroadcastReceiver receiver) { 850 return mBase.getRegisteredIntentFilters(receiver); 851 } 852 853 @Override startService(Intent service)854 public @Nullable ComponentName startService(Intent service) { 855 return mBase.startService(service); 856 } 857 858 @Override startForegroundService(Intent service)859 public @Nullable ComponentName startForegroundService(Intent service) { 860 return mBase.startForegroundService(service); 861 } 862 863 @Override stopService(Intent name)864 public boolean stopService(Intent name) { 865 return mBase.stopService(name); 866 } 867 868 /** @hide */ 869 @Override 870 @UnsupportedAppUsage startServiceAsUser(Intent service, UserHandle user)871 public @Nullable ComponentName startServiceAsUser(Intent service, UserHandle user) { 872 return mBase.startServiceAsUser(service, user); 873 } 874 875 /** @hide */ 876 @Override 877 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) startForegroundServiceAsUser(Intent service, UserHandle user)878 public @Nullable ComponentName startForegroundServiceAsUser(Intent service, UserHandle user) { 879 return mBase.startForegroundServiceAsUser(service, user); 880 } 881 882 /** @hide */ 883 @Override stopServiceAsUser(Intent name, UserHandle user)884 public boolean stopServiceAsUser(Intent name, UserHandle user) { 885 return mBase.stopServiceAsUser(name, user); 886 } 887 888 @Override bindService(Intent service, ServiceConnection conn, int flags)889 public boolean bindService(Intent service, ServiceConnection conn, 890 int flags) { 891 return mBase.bindService(service, conn, flags); 892 } 893 894 @Override bindService(@onNull Intent service, @NonNull ServiceConnection conn, @NonNull BindServiceFlags flags)895 public boolean bindService(@NonNull Intent service, @NonNull ServiceConnection conn, 896 @NonNull BindServiceFlags flags) { 897 return mBase.bindService(service, conn, flags); 898 } 899 900 @Override bindService(Intent service, int flags, Executor executor, ServiceConnection conn)901 public boolean bindService(Intent service, int flags, Executor executor, 902 ServiceConnection conn) { 903 return mBase.bindService(service, flags, executor, conn); 904 } 905 906 @Override bindService(@onNull Intent service, @NonNull BindServiceFlags flags, @NonNull Executor executor, @NonNull ServiceConnection conn)907 public boolean bindService(@NonNull Intent service, @NonNull BindServiceFlags flags, 908 @NonNull Executor executor, @NonNull ServiceConnection conn) { 909 return mBase.bindService(service, flags, executor, conn); 910 } 911 912 @Override bindIsolatedService(Intent service, int flags, String instanceName, Executor executor, ServiceConnection conn)913 public boolean bindIsolatedService(Intent service, int flags, String instanceName, 914 Executor executor, ServiceConnection conn) { 915 return mBase.bindIsolatedService(service, flags, instanceName, executor, conn); 916 } 917 918 /** @hide */ 919 @Override bindServiceAsUser(Intent service, ServiceConnection conn, int flags, UserHandle user)920 public boolean bindServiceAsUser(Intent service, ServiceConnection conn, int flags, 921 UserHandle user) { 922 return mBase.bindServiceAsUser(service, conn, flags, user); 923 } 924 925 /** @hide */ 926 @Override bindServiceAsUser(Intent service, ServiceConnection conn, @NonNull BindServiceFlags flags, UserHandle user)927 public boolean bindServiceAsUser(Intent service, ServiceConnection conn, 928 @NonNull BindServiceFlags flags, UserHandle user) { 929 return mBase.bindServiceAsUser(service, conn, flags, user); 930 } 931 932 /** @hide */ 933 @Override bindServiceAsUser(Intent service, ServiceConnection conn, int flags, Handler handler, UserHandle user)934 public boolean bindServiceAsUser(Intent service, ServiceConnection conn, int flags, 935 Handler handler, UserHandle user) { 936 return mBase.bindServiceAsUser(service, conn, flags, handler, user); 937 } 938 939 /** @hide */ 940 @Override bindServiceAsUser(Intent service, ServiceConnection conn, @NonNull BindServiceFlags flags, Handler handler, UserHandle user)941 public boolean bindServiceAsUser(Intent service, ServiceConnection conn, 942 @NonNull BindServiceFlags flags, Handler handler, UserHandle user) { 943 return mBase.bindServiceAsUser(service, conn, flags, handler, user); 944 } 945 946 @Override updateServiceGroup(ServiceConnection conn, int group, int importance)947 public void updateServiceGroup(ServiceConnection conn, int group, int importance) { 948 mBase.updateServiceGroup(conn, group, importance); 949 } 950 951 @Override unbindService(ServiceConnection conn)952 public void unbindService(ServiceConnection conn) { 953 mBase.unbindService(conn); 954 } 955 956 @Override startInstrumentation(ComponentName className, @Nullable String profileFile, @Nullable Bundle arguments)957 public boolean startInstrumentation(ComponentName className, 958 @Nullable String profileFile, @Nullable Bundle arguments) { 959 return mBase.startInstrumentation(className, profileFile, arguments); 960 } 961 962 @Override getSystemService(String name)963 public Object getSystemService(String name) { 964 return mBase.getSystemService(name); 965 } 966 967 @Override getSystemServiceName(Class<?> serviceClass)968 public String getSystemServiceName(Class<?> serviceClass) { 969 return mBase.getSystemServiceName(serviceClass); 970 } 971 972 @Override checkPermission(String permission, int pid, int uid)973 public int checkPermission(String permission, int pid, int uid) { 974 return mBase.checkPermission(permission, pid, uid); 975 } 976 977 /** @hide */ 978 @Override checkPermission(String permission, int pid, int uid, IBinder callerToken)979 public int checkPermission(String permission, int pid, int uid, IBinder callerToken) { 980 return mBase.checkPermission(permission, pid, uid, callerToken); 981 } 982 983 @Override checkCallingPermission(String permission)984 public int checkCallingPermission(String permission) { 985 return mBase.checkCallingPermission(permission); 986 } 987 988 @Override checkCallingOrSelfPermission(String permission)989 public int checkCallingOrSelfPermission(String permission) { 990 return mBase.checkCallingOrSelfPermission(permission); 991 } 992 993 @Override checkSelfPermission(String permission)994 public int checkSelfPermission(String permission) { 995 return mBase.checkSelfPermission(permission); 996 } 997 998 @Override enforcePermission( String permission, int pid, int uid, @Nullable String message)999 public void enforcePermission( 1000 String permission, int pid, int uid, @Nullable String message) { 1001 mBase.enforcePermission(permission, pid, uid, message); 1002 } 1003 1004 @Override enforceCallingPermission(String permission, @Nullable String message)1005 public void enforceCallingPermission(String permission, @Nullable String message) { 1006 mBase.enforceCallingPermission(permission, message); 1007 } 1008 1009 @Override enforceCallingOrSelfPermission( String permission, @Nullable String message)1010 public void enforceCallingOrSelfPermission( 1011 String permission, @Nullable String message) { 1012 mBase.enforceCallingOrSelfPermission(permission, message); 1013 } 1014 1015 /** @hide */ 1016 @Override getPermissionRequestState(String permission)1017 public int getPermissionRequestState(String permission) { 1018 return mBase.getPermissionRequestState(permission); 1019 } 1020 1021 @Override grantUriPermission(String toPackage, Uri uri, int modeFlags)1022 public void grantUriPermission(String toPackage, Uri uri, int modeFlags) { 1023 mBase.grantUriPermission(toPackage, uri, modeFlags); 1024 } 1025 1026 @Override revokeUriPermission(Uri uri, int modeFlags)1027 public void revokeUriPermission(Uri uri, int modeFlags) { 1028 mBase.revokeUriPermission(uri, modeFlags); 1029 } 1030 1031 @Override revokeUriPermission(String targetPackage, Uri uri, int modeFlags)1032 public void revokeUriPermission(String targetPackage, Uri uri, int modeFlags) { 1033 mBase.revokeUriPermission(targetPackage, uri, modeFlags); 1034 } 1035 1036 @Override checkUriPermission(Uri uri, int pid, int uid, int modeFlags)1037 public int checkUriPermission(Uri uri, int pid, int uid, int modeFlags) { 1038 return mBase.checkUriPermission(uri, pid, uid, modeFlags); 1039 } 1040 1041 @FlaggedApi(android.security.Flags.FLAG_CONTENT_URI_PERMISSION_APIS) 1042 @Override checkContentUriPermissionFull(@onNull Uri uri, int pid, int uid, int modeFlags)1043 public int checkContentUriPermissionFull(@NonNull Uri uri, int pid, int uid, int modeFlags) { 1044 return mBase.checkContentUriPermissionFull(uri, pid, uid, modeFlags); 1045 } 1046 1047 @NonNull 1048 @Override checkUriPermissions(@onNull List<Uri> uris, int pid, int uid, int modeFlags)1049 public int[] checkUriPermissions(@NonNull List<Uri> uris, int pid, int uid, 1050 int modeFlags) { 1051 return mBase.checkUriPermissions(uris, pid, uid, modeFlags); 1052 } 1053 1054 /** @hide */ 1055 @Override checkUriPermission(Uri uri, int pid, int uid, int modeFlags, IBinder callerToken)1056 public int checkUriPermission(Uri uri, int pid, int uid, int modeFlags, IBinder callerToken) { 1057 return mBase.checkUriPermission(uri, pid, uid, modeFlags, callerToken); 1058 } 1059 1060 @Override checkCallingUriPermission(Uri uri, int modeFlags)1061 public int checkCallingUriPermission(Uri uri, int modeFlags) { 1062 return mBase.checkCallingUriPermission(uri, modeFlags); 1063 } 1064 1065 @NonNull 1066 @Override checkCallingUriPermissions(@onNull List<Uri> uris, int modeFlags)1067 public int[] checkCallingUriPermissions(@NonNull List<Uri> uris, int modeFlags) { 1068 return mBase.checkCallingUriPermissions(uris, modeFlags); 1069 } 1070 1071 @Override checkCallingOrSelfUriPermission(Uri uri, int modeFlags)1072 public int checkCallingOrSelfUriPermission(Uri uri, int modeFlags) { 1073 return mBase.checkCallingOrSelfUriPermission(uri, modeFlags); 1074 } 1075 1076 @NonNull 1077 @Override checkCallingOrSelfUriPermissions(@onNull List<Uri> uris, int modeFlags)1078 public int[] checkCallingOrSelfUriPermissions(@NonNull List<Uri> uris, int modeFlags) { 1079 return mBase.checkCallingOrSelfUriPermissions(uris, modeFlags); 1080 } 1081 1082 @Override checkUriPermission(@ullable Uri uri, @Nullable String readPermission, @Nullable String writePermission, int pid, int uid, int modeFlags)1083 public int checkUriPermission(@Nullable Uri uri, @Nullable String readPermission, 1084 @Nullable String writePermission, int pid, int uid, int modeFlags) { 1085 return mBase.checkUriPermission(uri, readPermission, writePermission, 1086 pid, uid, modeFlags); 1087 } 1088 1089 @Override enforceUriPermission( Uri uri, int pid, int uid, int modeFlags, String message)1090 public void enforceUriPermission( 1091 Uri uri, int pid, int uid, int modeFlags, String message) { 1092 mBase.enforceUriPermission(uri, pid, uid, modeFlags, message); 1093 } 1094 1095 @Override enforceCallingUriPermission( Uri uri, int modeFlags, String message)1096 public void enforceCallingUriPermission( 1097 Uri uri, int modeFlags, String message) { 1098 mBase.enforceCallingUriPermission(uri, modeFlags, message); 1099 } 1100 1101 @Override enforceCallingOrSelfUriPermission( Uri uri, int modeFlags, String message)1102 public void enforceCallingOrSelfUriPermission( 1103 Uri uri, int modeFlags, String message) { 1104 mBase.enforceCallingOrSelfUriPermission(uri, modeFlags, message); 1105 } 1106 1107 @Override enforceUriPermission( @ullable Uri uri, @Nullable String readPermission, @Nullable String writePermission, int pid, int uid, int modeFlags, @Nullable String message)1108 public void enforceUriPermission( 1109 @Nullable Uri uri, @Nullable String readPermission, @Nullable String writePermission, 1110 int pid, int uid, int modeFlags, @Nullable String message) { 1111 mBase.enforceUriPermission( 1112 uri, readPermission, writePermission, pid, uid, modeFlags, 1113 message); 1114 } 1115 1116 @Override revokeSelfPermissionsOnKill(@onNull Collection<String> permissions)1117 public void revokeSelfPermissionsOnKill(@NonNull Collection<String> permissions) { 1118 mBase.revokeSelfPermissionsOnKill(permissions); 1119 } 1120 1121 @Override createPackageContext(String packageName, int flags)1122 public Context createPackageContext(String packageName, int flags) 1123 throws PackageManager.NameNotFoundException { 1124 return mBase.createPackageContext(packageName, flags); 1125 } 1126 1127 /** @hide */ 1128 @Override createPackageContextAsUser(String packageName, int flags, UserHandle user)1129 public Context createPackageContextAsUser(String packageName, int flags, UserHandle user) 1130 throws PackageManager.NameNotFoundException { 1131 return mBase.createPackageContextAsUser(packageName, flags, user); 1132 } 1133 1134 /** @hide */ 1135 @Override createContextAsUser(UserHandle user, @CreatePackageOptions int flags)1136 public Context createContextAsUser(UserHandle user, @CreatePackageOptions int flags) { 1137 return mBase.createContextAsUser(user, flags); 1138 } 1139 1140 /** @hide */ 1141 @Override 1142 @UnsupportedAppUsage(trackingBug = 175981568) createApplicationContext(ApplicationInfo application, int flags)1143 public Context createApplicationContext(ApplicationInfo application, 1144 int flags) throws PackageManager.NameNotFoundException { 1145 return mBase.createApplicationContext(application, flags); 1146 } 1147 1148 /** @hide */ 1149 @Override 1150 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 1151 @NonNull createContextForSdkInSandbox(@onNull ApplicationInfo sdkInfo, int flags)1152 public Context createContextForSdkInSandbox(@NonNull ApplicationInfo sdkInfo, int flags) 1153 throws PackageManager.NameNotFoundException { 1154 return mBase.createContextForSdkInSandbox(sdkInfo, flags); 1155 } 1156 1157 /** @hide */ 1158 @Override createContextForSplit(String splitName)1159 public Context createContextForSplit(String splitName) 1160 throws PackageManager.NameNotFoundException { 1161 return mBase.createContextForSplit(splitName); 1162 } 1163 1164 /** @hide */ 1165 @Override getUserId()1166 public int getUserId() { 1167 return mBase.getUserId(); 1168 } 1169 1170 /** @hide */ 1171 @Override getUser()1172 public UserHandle getUser() { 1173 return mBase.getUser(); 1174 } 1175 1176 @Override createConfigurationContext(Configuration overrideConfiguration)1177 public Context createConfigurationContext(Configuration overrideConfiguration) { 1178 return mBase.createConfigurationContext(overrideConfiguration); 1179 } 1180 1181 @Override createDisplayContext(Display display)1182 public Context createDisplayContext(Display display) { 1183 return mBase.createDisplayContext(display); 1184 } 1185 1186 @Override createDeviceContext(int deviceId)1187 public @NonNull Context createDeviceContext(int deviceId) { 1188 return mBase.createDeviceContext(deviceId); 1189 } 1190 1191 @Override 1192 @NonNull createWindowContext(@indowType int type, @Nullable Bundle options)1193 public Context createWindowContext(@WindowType int type, @Nullable Bundle options) { 1194 return mBase.createWindowContext(type, options); 1195 } 1196 1197 @Override 1198 @NonNull createWindowContext(@onNull Display display, @WindowType int type, @Nullable Bundle options)1199 public Context createWindowContext(@NonNull Display display, @WindowType int type, 1200 @Nullable Bundle options) { 1201 return mBase.createWindowContext(display, type, options); 1202 } 1203 1204 @Override 1205 @NonNull createContext(@onNull ContextParams contextParams)1206 public Context createContext(@NonNull ContextParams contextParams) { 1207 return mBase.createContext(contextParams); 1208 } 1209 1210 @Override createAttributionContext(@ullable String attributionTag)1211 public @NonNull Context createAttributionContext(@Nullable String attributionTag) { 1212 return mBase.createAttributionContext(attributionTag); 1213 } 1214 1215 @NonNull 1216 @Override getAttributionSource()1217 public AttributionSource getAttributionSource() { 1218 return mBase.getAttributionSource(); 1219 } 1220 1221 @Override isRestricted()1222 public boolean isRestricted() { 1223 return mBase.isRestricted(); 1224 } 1225 1226 /** @hide */ 1227 @Override getDisplayAdjustments(int displayId)1228 public DisplayAdjustments getDisplayAdjustments(int displayId) { 1229 return mBase.getDisplayAdjustments(displayId); 1230 } 1231 1232 @Override getDisplay()1233 public @Nullable Display getDisplay() { 1234 return mBase.getDisplay(); 1235 } 1236 1237 /** @hide */ 1238 @Override getDisplayNoVerify()1239 public @Nullable Display getDisplayNoVerify() { 1240 return mBase.getDisplayNoVerify(); 1241 } 1242 1243 /** 1244 * @hide 1245 */ 1246 @Override getDisplayId()1247 public int getDisplayId() { 1248 return mBase.getDisplayId(); 1249 } 1250 1251 /** 1252 * @hide 1253 */ 1254 @Override getAssociatedDisplayId()1255 public int getAssociatedDisplayId() { 1256 return mBase.getAssociatedDisplayId(); 1257 } 1258 1259 /** 1260 * @hide 1261 */ 1262 @Override updateDisplay(int displayId)1263 public void updateDisplay(int displayId) { 1264 mBase.updateDisplay(displayId); 1265 } 1266 1267 /** 1268 * @hide 1269 */ 1270 @Override updateDeviceId(int deviceId)1271 public void updateDeviceId(int deviceId) { 1272 mBase.updateDeviceId(deviceId); 1273 } 1274 1275 @Override getDeviceId()1276 public int getDeviceId() { 1277 return mBase.getDeviceId(); 1278 } 1279 1280 @Override registerDeviceIdChangeListener(@onNull @allbackExecutor Executor executor, @NonNull IntConsumer listener)1281 public void registerDeviceIdChangeListener(@NonNull @CallbackExecutor Executor executor, 1282 @NonNull IntConsumer listener) { 1283 mBase.registerDeviceIdChangeListener(executor, listener); 1284 } 1285 1286 @Override unregisterDeviceIdChangeListener(@onNull IntConsumer listener)1287 public void unregisterDeviceIdChangeListener(@NonNull IntConsumer listener) { 1288 mBase.unregisterDeviceIdChangeListener(listener); 1289 } 1290 1291 @Override createDeviceProtectedStorageContext()1292 public Context createDeviceProtectedStorageContext() { 1293 return mBase.createDeviceProtectedStorageContext(); 1294 } 1295 1296 /** {@hide} */ 1297 @SystemApi 1298 @Override createCredentialProtectedStorageContext()1299 public Context createCredentialProtectedStorageContext() { 1300 return mBase.createCredentialProtectedStorageContext(); 1301 } 1302 1303 /** @hide */ 1304 @UiContext 1305 @NonNull 1306 @Override createTokenContext(@onNull IBinder token, @NonNull Display display)1307 public Context createTokenContext(@NonNull IBinder token, @NonNull Display display) { 1308 return mBase.createTokenContext(token, display); 1309 } 1310 1311 @Override isDeviceProtectedStorage()1312 public boolean isDeviceProtectedStorage() { 1313 return mBase.isDeviceProtectedStorage(); 1314 } 1315 1316 /** {@hide} */ 1317 @SystemApi 1318 @Override isCredentialProtectedStorage()1319 public boolean isCredentialProtectedStorage() { 1320 return mBase.isCredentialProtectedStorage(); 1321 } 1322 1323 /** {@hide} */ 1324 @Override canLoadUnsafeResources()1325 public boolean canLoadUnsafeResources() { 1326 return mBase.canLoadUnsafeResources(); 1327 } 1328 1329 /** 1330 * @hide 1331 */ 1332 @Override getActivityToken()1333 public @Nullable IBinder getActivityToken() { 1334 return mBase.getActivityToken(); 1335 } 1336 1337 /** 1338 * @hide 1339 */ 1340 @Override getWindowContextToken()1341 public @Nullable IBinder getWindowContextToken() { 1342 return mBase != null ? mBase.getWindowContextToken() : null; 1343 } 1344 1345 /** 1346 * @hide 1347 */ 1348 @Override getServiceDispatcher(ServiceConnection conn, Handler handler, long flags)1349 public @Nullable IServiceConnection getServiceDispatcher(ServiceConnection conn, 1350 Handler handler, long flags) { 1351 return mBase.getServiceDispatcher(conn, handler, flags); 1352 } 1353 1354 /** 1355 * @hide 1356 */ 1357 @Override getIApplicationThread()1358 public IApplicationThread getIApplicationThread() { 1359 return mBase.getIApplicationThread(); 1360 } 1361 1362 /** 1363 * @hide 1364 */ 1365 @Override getProcessToken()1366 public IBinder getProcessToken() { 1367 return mBase.getProcessToken(); 1368 } 1369 1370 /** 1371 * @hide 1372 */ 1373 @Override getMainThreadHandler()1374 public Handler getMainThreadHandler() { 1375 return mBase.getMainThreadHandler(); 1376 } 1377 1378 /** 1379 * @hide 1380 */ 1381 @Override getNextAutofillId()1382 public int getNextAutofillId() { 1383 return mBase.getNextAutofillId(); 1384 } 1385 1386 /** 1387 * @hide 1388 */ 1389 @Override getAutofillClient()1390 public AutofillClient getAutofillClient() { 1391 return mBase.getAutofillClient(); 1392 } 1393 1394 /** 1395 * @hide 1396 */ 1397 @Override setAutofillClient(AutofillClient client)1398 public void setAutofillClient(AutofillClient client) { 1399 mBase.setAutofillClient(client); 1400 } 1401 1402 /** @hide */ 1403 @Override getAutofillOptions()1404 public AutofillOptions getAutofillOptions() { 1405 return mBase == null ? null : mBase.getAutofillOptions(); 1406 } 1407 1408 /** @hide */ 1409 @Override setAutofillOptions(AutofillOptions options)1410 public void setAutofillOptions(AutofillOptions options) { 1411 if (mBase != null) { 1412 mBase.setAutofillOptions(options); 1413 } 1414 } 1415 1416 /** 1417 * @hide 1418 */ 1419 @Override getContentCaptureOptions()1420 public @Nullable ContentCaptureOptions getContentCaptureOptions() { 1421 return mBase == null ? null : mBase.getContentCaptureOptions(); 1422 } 1423 1424 /** 1425 * @hide 1426 */ 1427 @TestApi 1428 @Override setContentCaptureOptions(@ullable ContentCaptureOptions options)1429 public void setContentCaptureOptions(@Nullable ContentCaptureOptions options) { 1430 if (mBase != null) { 1431 mBase.setContentCaptureOptions(options); 1432 } 1433 } 1434 1435 /** 1436 * @hide 1437 */ 1438 @Override isUiContext()1439 public boolean isUiContext() { 1440 if (mBase == null) { 1441 return false; 1442 } 1443 return mBase.isUiContext(); 1444 } 1445 1446 /** 1447 * @hide 1448 */ 1449 @Override isConfigurationContext()1450 public boolean isConfigurationContext() { 1451 if (mBase == null) { 1452 return false; 1453 } 1454 return mBase.isConfigurationContext(); 1455 } 1456 1457 /** 1458 * Add a new {@link ComponentCallbacks} to the base application of the 1459 * Context, which will be called at the same times as the ComponentCallbacks 1460 * methods of activities and other components are called. Note that you 1461 * <em>must</em> be sure to use {@link #unregisterComponentCallbacks} when 1462 * appropriate in the future; this will not be removed for you. 1463 * <p> 1464 * After {@link Build.VERSION_CODES#TIRAMISU}, the {@link ComponentCallbacks} will be registered 1465 * to {@link #getBaseContext() the base Context}, and can be only used after 1466 * {@link #attachBaseContext(Context)}. Users can still call to 1467 * {@code getApplicationContext().registerComponentCallbacks(ComponentCallbacks)} to add 1468 * {@link ComponentCallbacks} to the base application. 1469 * 1470 * @param callback The interface to call. This can be either a 1471 * {@link ComponentCallbacks} or {@link ComponentCallbacks2} interface. 1472 * @throws IllegalStateException if this method calls before {@link #attachBaseContext(Context)} 1473 */ 1474 @Override 1475 @android.ravenwood.annotation.RavenwoodThrow registerComponentCallbacks(ComponentCallbacks callback)1476 public void registerComponentCallbacks(ComponentCallbacks callback) { 1477 if (mBase != null) { 1478 mBase.registerComponentCallbacks(callback); 1479 } else if (!CompatChanges.isChangeEnabled(OVERRIDABLE_COMPONENT_CALLBACKS)) { 1480 super.registerComponentCallbacks(callback); 1481 synchronized (mLock) { 1482 // Also register ComponentCallbacks to ContextWrapper, so we can find the correct 1483 // Context to unregister it for compatibility. 1484 if (mCallbacksRegisteredToSuper == null) { 1485 mCallbacksRegisteredToSuper = new ArrayList<>(); 1486 } 1487 mCallbacksRegisteredToSuper.add(callback); 1488 } 1489 } else { 1490 // Throw exception for Application targeting T+ 1491 throw new IllegalStateException("ComponentCallbacks must be registered after " 1492 + "this ContextWrapper is attached to a base Context."); 1493 } 1494 } 1495 1496 /** 1497 * Remove a {@link ComponentCallbacks} object that was previously registered 1498 * with {@link #registerComponentCallbacks(ComponentCallbacks)}. 1499 * <p> 1500 * After {@link Build.VERSION_CODES#TIRAMISU}, the {@link ComponentCallbacks} will be 1501 * unregistered to {@link #getBaseContext() the base Context}, and can be only used after 1502 * {@link #attachBaseContext(Context)} 1503 * </p> 1504 * 1505 * @param callback The interface to call. This can be either a 1506 * {@link ComponentCallbacks} or {@link ComponentCallbacks2} interface. 1507 * @throws IllegalStateException if this method calls before {@link #attachBaseContext(Context)} 1508 */ 1509 @Override 1510 @android.ravenwood.annotation.RavenwoodThrow unregisterComponentCallbacks(ComponentCallbacks callback)1511 public void unregisterComponentCallbacks(ComponentCallbacks callback) { 1512 // It usually means the ComponentCallbacks is registered before this ContextWrapper attaches 1513 // to a base Context and Application is targeting prior to S-v2. We should unregister the 1514 // ComponentCallbacks to the Application Context instead to prevent leak. 1515 synchronized (mLock) { 1516 if (mCallbacksRegisteredToSuper != null 1517 && mCallbacksRegisteredToSuper.contains(callback)) { 1518 super.unregisterComponentCallbacks(callback); 1519 mCallbacksRegisteredToSuper.remove(callback); 1520 } else if (mBase != null) { 1521 mBase.unregisterComponentCallbacks(callback); 1522 } else if (CompatChanges.isChangeEnabled(OVERRIDABLE_COMPONENT_CALLBACKS)) { 1523 // Throw exception for Application that is targeting S-v2+ 1524 throw new IllegalStateException("ComponentCallbacks must be unregistered after " 1525 + "this ContextWrapper is attached to a base Context."); 1526 } 1527 } 1528 // Do nothing if the callback hasn't been registered to Application Context by 1529 // super.unregisterComponentCallbacks() for Application that is targeting prior to T. 1530 } 1531 1532 /** 1533 * Closes temporary system dialogs. Some examples of temporary system dialogs are the 1534 * notification window-shade and the recent tasks dialog. 1535 * 1536 * @hide 1537 */ 1538 @RequiresPermission(android.Manifest.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS) closeSystemDialogs()1539 public void closeSystemDialogs() { 1540 mBase.closeSystemDialogs(); 1541 } 1542 } 1543