diff --git a/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformViewWrapper.java b/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformViewWrapper.java index d7ebe184a6..ba0205a7b7 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformViewWrapper.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformViewWrapper.java @@ -11,11 +11,13 @@ import android.graphics.BlendMode; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Matrix; +import android.graphics.Rect; import android.graphics.SurfaceTexture; import android.os.Build; import android.view.MotionEvent; import android.view.Surface; import android.view.View; +import android.view.ViewParent; import android.view.ViewTreeObserver; import android.widget.FrameLayout; import androidx.annotation.NonNull; @@ -175,12 +177,20 @@ class PlatformViewWrapper extends FrameLayout { return true; } + /** Used on Android O+, {@link invalidateChildInParent} used for previous versions. */ + @SuppressLint("NewApi") @Override public void onDescendantInvalidated(@NonNull View child, @NonNull View target) { super.onDescendantInvalidated(child, target); invalidate(); } + @Override + public ViewParent invalidateChildInParent(int[] location, Rect dirty) { + invalidate(); + return super.invalidateChildInParent(location, dirty); + } + @Override @SuppressLint("NewApi") public void draw(Canvas canvas) { diff --git a/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/platform/PlatformViewWrapperTest.java b/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/platform/PlatformViewWrapperTest.java index 1c2d4f5168..5ed19a7383 100644 --- a/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/platform/PlatformViewWrapperTest.java +++ b/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/platform/PlatformViewWrapperTest.java @@ -25,6 +25,18 @@ import org.robolectric.RuntimeEnvironment; @TargetApi(31) @RunWith(AndroidJUnit4.class) public class PlatformViewWrapperTest { + @Test + public void invalidateChildInParent_callsInvalidate() { + final Context ctx = ApplicationProvider.getApplicationContext(); + final PlatformViewWrapper wrapper = spy(new PlatformViewWrapper(ctx)); + + // Mock Android framework calls. + wrapper.invalidateChildInParent(null, null); + + // Verify. + verify(wrapper, times(1)).invalidate(); + } + @Test public void setTexture_writesToBuffer() { final Surface surface = mock(Surface.class);