diff options
| -rw-r--r-- | core/java/android/app/ContextImpl.java | 7 | ||||
| -rw-r--r-- | core/java/android/view/ViewConfiguration.java | 5 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt | 24 |
3 files changed, 31 insertions, 5 deletions
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index 86a3579effe1..a828aac78ded 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -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; } diff --git a/core/java/android/view/ViewConfiguration.java b/core/java/android/view/ViewConfiguration.java index 0d2d4d13eb38..ffeeb806ba54 100644 --- a/core/java/android/view/ViewConfiguration.java +++ b/core/java/android/view/ViewConfiguration.java @@ -500,12 +500,13 @@ public class ViewConfiguration { */ public static ViewConfiguration get(Context context) { 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, " + "must be accessed from Activity or other visual Context. " + "Use an Activity or a Context created with " + "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); StrictMode.onIncorrectContextUsed(message, exception); Log.e(TAG, errorMessage + message, exception); diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt b/packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt index 3d2b72d8fd83..fc33391a9ad1 100644 --- a/packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt +++ b/packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt @@ -40,6 +40,28 @@ import javax.inject.Inject import javax.inject.Singleton /** + * Similarly to isShown but also excludes views that have 0 alpha + */ +val View.isShownNotFaded: Boolean + get() { + var current: View = this + while (true) { + if (current.visibility != View.VISIBLE) { + return false + } + if (current.alpha == 0.0f) { + return false + } + val parent = current.parent ?: return false // We are not attached to the view root + if (parent !is View) { + // we reached the viewroot, hurray + return true + } + current = parent + } + } + +/** * This manager is responsible for placement of the unique media view between the different hosts * and animate the positions of the views to achieve seamless transitions. */ @@ -368,7 +390,7 @@ class MediaHierarchyManager @Inject constructor( // non-trivial reattaching logic happening that will make the view not-shown earlier return true } - return mediaFrame.isShown || animator.isRunning || animationPending + return mediaFrame.isShownNotFaded || animator.isRunning || animationPending } private fun adjustAnimatorForTransition(desiredLocation: Int, previousLocation: Int) { |