Merge "Enable IMS and its config context to obtain UI component" into rvc-dev am: 8655743001 am: e3138eca89

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11818544

Change-Id: I2e820a5300bb6fb4e7d0f4444c09cad4a2d0a9c5
This commit is contained in:
Charles Chen
2020-06-24 03:51:10 +00:00
committed by Automerger Merge Worker
2 changed files with 8 additions and 4 deletions

View File

@@ -1900,11 +1900,13 @@ class ContextImpl extends Context {
@Override
public Object getSystemService(String name) {
// We may override this API from outer context.
final boolean isUiContext = isUiContext() || getOuterContext().isUiContext();
// Check incorrect Context usage.
if (isUiComponent(name) && !isUiContext() && vmIncorrectContextUseEnabled()) {
if (isUiComponent(name) && !isUiContext && vmIncorrectContextUseEnabled()) {
final String errorMessage = "Tried to access visual service "
+ SystemServiceRegistry.getSystemServiceClassName(name)
+ " from a non-visual Context. ";
+ " from a non-visual Context:" + getOuterContext();
final String message = "Visual services, such as WindowManager, WallpaperService or "
+ "LayoutInflater should be accessed from Activity or other visual Context. "
+ "Use an Activity or a Context created with "
@@ -2369,6 +2371,7 @@ class ContextImpl extends Context {
context.setResources(createResources(mToken, mPackageInfo, mSplitName, displayId,
overrideConfiguration, getDisplayAdjustments(displayId).getCompatibilityInfo(),
mResources.getLoaders()));
context.mIsUiContext = isUiContext() || getOuterContext().isUiContext();
return context;
}