Skip to content
TypeScript

fix(mobile): Android composer no longer accepts autofill (#27489)

Julius Marminge61c76011004d
diff --git a/apps/mobile/modules/t3-composer-editor/android/src/main/java/expo/modules/t3composereditor/T3ComposerEditorView.kt b/apps/mobile/modules/t3-composer-editor/android/src/main/java/expo/modules/t3composereditor/T3ComposerEditorView.kt
index e9a15a07d2f..0fab5b17da8 100644
--- a/apps/mobile/modules/t3-composer-editor/android/src/main/java/expo/modules/t3composereditor/T3ComposerEditorView.kt
+++ b/apps/mobile/modules/t3-composer-editor/android/src/main/java/expo/modules/t3composereditor/T3ComposerEditorView.kt
@@ -23,6 +23,7 @@ import android.view.Gravity
import android.view.GestureDetector
import android.view.MotionEvent
import android.view.KeyEvent
+import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputConnection
@@ -596,6 +597,9 @@ internal class SelectionAwareEditText(
var maxInputChars = Int.MAX_VALUE
var clipboardFragment = ""
+ // Keeps autofill services such as SMS verification codes from writing into the draft.
+ override fun getAutofillType(): Int = View.AUTOFILL_TYPE_NONE
+
/**
* Editable TextView hints do not ellipsize, so long placeholders wrap and grow the composer.
* Truncate the hint to the measured width instead.
diff --git a/apps/mobile/modules/t3-composer-editor/android/src/test/java/expo/modules/t3composereditor/ComposerPasteTest.kt b/apps/mobile/modules/t3-composer-editor/android/src/test/java/expo/modules/t3composereditor/ComposerPasteTest.kt
index 441154f3e1b..22b21676586 100644
--- a/apps/mobile/modules/t3-composer-editor/android/src/test/java/expo/modules/t3composereditor/ComposerPasteTest.kt
+++ b/apps/mobile/modules/t3-composer-editor/android/src/test/java/expo/modules/t3composereditor/ComposerPasteTest.kt
@@ -180,6 +180,15 @@ class ComposerPasteTest {
assertNull(intercepted)
}
+ @Test
+ fun autofillCannotWriteIntoTheDraft() {
+ assertEquals(
+ "Autofill services such as SMS verification codes must not target the composer",
+ View.AUTOFILL_TYPE_NONE,
+ editor.autofillType,
+ )
+ }
+
private fun dropEditor(): SelectionAwareEditText {
val activity = Robolectric.buildActivity(Activity::class.java).setup().get()
return SelectionAwareEditText(activity).apply {