From d62a03ee81ad7727a8fa396a652ce69264385c31 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Wed, 29 Mar 2023 19:23:57 -0400 Subject: [PATCH] Fix autofill for android --- .../io/flutter/embedding/android/FlutterView.java | 2 +- .../io/flutter/embedding/android/FlutterViewTest.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterView.java b/shell/platform/android/io/flutter/embedding/android/FlutterView.java index 0c26f7d8dc20c..9bd0022fe356f 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterView.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterView.java @@ -388,7 +388,7 @@ private void init() { setFocusable(true); setFocusableInTouchMode(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS); + setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_YES); } } diff --git a/shell/platform/android/test/io/flutter/embedding/android/FlutterViewTest.java b/shell/platform/android/test/io/flutter/embedding/android/FlutterViewTest.java index beb05cc29e83f..41337f0c30b3d 100644 --- a/shell/platform/android/test/io/flutter/embedding/android/FlutterViewTest.java +++ b/shell/platform/android/test/io/flutter/embedding/android/FlutterViewTest.java @@ -92,6 +92,15 @@ public void attachToFlutterEngine_alertsPlatformViews() { verify(platformViewsController, times(1)).attachToView(flutterView); } + @Test + public void flutterView_importantForAutofillDoesNotExcludeDescendants() { + FlutterView flutterView = new FlutterView(Robolectric.setupActivity(Activity.class)); + + // Value should not exclude descendants because platform views are added as child views and + // can be eligible for autofill (e.g. a WebView). + assertEquals(View.IMPORTANT_FOR_AUTOFILL_YES, flutterView.getImportantForAutofill()); + } + @Test public void detachFromFlutterEngine_alertsPlatformViews() { FlutterView flutterView = new FlutterView(Robolectric.setupActivity(Activity.class));