Merge "Revert "Revert "Enable IMS and its config context to obtain UI component""" into rvc-dev am: 8deb612a14
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12004931 Change-Id: Idb3a5a9ab657006f82cacc977b0eed33395a7432
This commit is contained in:
@@ -1900,11 +1900,13 @@ class ContextImpl extends Context {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getSystemService(String name) {
|
public Object getSystemService(String name) {
|
||||||
|
// We may override this API from outer context.
|
||||||
|
final boolean isUiContext = isUiContext() || getOuterContext().isUiContext();
|
||||||
// Check incorrect Context usage.
|
// Check incorrect Context usage.
|
||||||
if (isUiComponent(name) && !isUiContext() && vmIncorrectContextUseEnabled()) {
|
if (isUiComponent(name) && !isUiContext && vmIncorrectContextUseEnabled()) {
|
||||||
final String errorMessage = "Tried to access visual service "
|
final String errorMessage = "Tried to access visual service "
|
||||||
+ SystemServiceRegistry.getSystemServiceClassName(name)
|
+ SystemServiceRegistry.getSystemServiceClassName(name)
|
||||||
+ " from a non-visual Context. ";
|
+ " from a non-visual Context:" + getOuterContext();
|
||||||
final String message = "Visual services, such as WindowManager, WallpaperService or "
|
final String message = "Visual services, such as WindowManager, WallpaperService or "
|
||||||
+ "LayoutInflater should be accessed from Activity or other visual Context. "
|
+ "LayoutInflater should be accessed from Activity or other visual Context. "
|
||||||
+ "Use an Activity or a Context created with "
|
+ "Use an Activity or a Context created with "
|
||||||
@@ -2369,6 +2371,7 @@ class ContextImpl extends Context {
|
|||||||
context.setResources(createResources(mToken, mPackageInfo, mSplitName, displayId,
|
context.setResources(createResources(mToken, mPackageInfo, mSplitName, displayId,
|
||||||
overrideConfiguration, getDisplayAdjustments(displayId).getCompatibilityInfo(),
|
overrideConfiguration, getDisplayAdjustments(displayId).getCompatibilityInfo(),
|
||||||
mResources.getLoaders()));
|
mResources.getLoaders()));
|
||||||
|
context.mIsUiContext = isUiContext() || getOuterContext().isUiContext();
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -500,12 +500,13 @@ public class ViewConfiguration {
|
|||||||
*/
|
*/
|
||||||
public static ViewConfiguration get(Context context) {
|
public static ViewConfiguration get(Context context) {
|
||||||
if (!context.isUiContext() && vmIncorrectContextUseEnabled()) {
|
if (!context.isUiContext() && vmIncorrectContextUseEnabled()) {
|
||||||
final String errorMessage = "Tried to access UI constants from a non-visual Context.";
|
final String errorMessage = "Tried to access UI constants from a non-visual Context:"
|
||||||
|
+ context;
|
||||||
final String message = "UI constants, such as display metrics or window metrics, "
|
final String message = "UI constants, such as display metrics or window metrics, "
|
||||||
+ "must be accessed from Activity or other visual Context. "
|
+ "must be accessed from Activity or other visual Context. "
|
||||||
+ "Use an Activity or a Context created with "
|
+ "Use an Activity or a Context created with "
|
||||||
+ "Context#createWindowContext(int, Bundle), which are adjusted to the "
|
+ "Context#createWindowContext(int, Bundle), which are adjusted to the "
|
||||||
+ "configuration and visual bounds of an area on screen.";
|
+ "configuration and visual bounds of an area on screen";
|
||||||
final Exception exception = new IllegalArgumentException(errorMessage);
|
final Exception exception = new IllegalArgumentException(errorMessage);
|
||||||
StrictMode.onIncorrectContextUsed(message, exception);
|
StrictMode.onIncorrectContextUsed(message, exception);
|
||||||
Log.e(TAG, errorMessage + message, exception);
|
Log.e(TAG, errorMessage + message, exception);
|
||||||
|
|||||||
Reference in New Issue
Block a user