From e2a7bddbe10940ad3a9e45a91c7ea34f5c68d92d Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Tue, 21 Mar 2017 16:47:20 -0700 Subject: [PATCH] Set flagForceAscii for device password entries Since the beginning [1], ChooseLockPassword#validatePassword() has never accepted non-ASCII characters [2]. Hence we can safely specify EditorInfo#IME_FLAG_FORCE_ASCII so that IMEs can optimize their UX based on this flag. Note that EditorInfo#IME_FLAG_FORCE_ASCII is just a hint for the IME so there should be no behavior change in the system side. Note also that EditorInfo#IME_FLAG_FORCE_ASCII has been used in KeyGuard (keyguard_password_view.xml) since JB MR-1 [3] so this flag is considered to be well tested. [1]: 00d2476d8fc122b4eef59d6be6f7aa41e9c56fde [2]: Only character c where 32 <= c <= 126 is accepted [3]: Id75286113771ca1407e9db182172b580f870b612 Test: Run `adb shell dumpsys input_method` when the password entry field is focused to make sure that 'imeOptions' parameter has 0x80000000 bit. Tested the following scenarios: - PIN on a direct-boot disabled device - PIN on a direct-boot enabled device - Password on a direct-boot disabled device - Password on a direct-boot enabled device Fixes: 27858858 Change-Id: I3075e24c6dac4d49f4d0e56a0d4d8434a323754d --- res/layout-land/confirm_lock_password.xml | 2 +- res/layout/choose_lock_password.xml | 2 +- res/layout/confirm_lock_password_base.xml | 2 +- res/layout/confirm_lock_password_internal.xml | 2 +- res/layout/crypt_keeper_password_field.xml | 1 + 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/res/layout-land/confirm_lock_password.xml b/res/layout-land/confirm_lock_password.xml index dff4e4d1751..e9b2b0fd056 100644 --- a/res/layout-land/confirm_lock_password.xml +++ b/res/layout-land/confirm_lock_password.xml @@ -74,7 +74,7 @@ android:layout_gravity="center_horizontal|bottom" android:layout_marginBottom="26dp" android:inputType="textPassword" - android:imeOptions="actionNext|flagNoFullscreen" + android:imeOptions="actionNext|flagNoFullscreen|flagForceAscii" android:gravity="center" android:textSize="16sp" style="@style/TextAppearance.PasswordEntry"/> diff --git a/res/layout/choose_lock_password.xml b/res/layout/choose_lock_password.xml index 15fb7db99e2..260db7f73e6 100644 --- a/res/layout/choose_lock_password.xml +++ b/res/layout/choose_lock_password.xml @@ -48,7 +48,7 @@ android:layout_gravity="center" android:gravity="center" android:inputType="textPassword" - android:imeOptions="actionNext|flagNoExtractUi" + android:imeOptions="actionNext|flagNoExtractUi|flagForceAscii" android:textSize="24sp" style="@style/TextAppearance.PasswordEntry"/> diff --git a/res/layout/confirm_lock_password_base.xml b/res/layout/confirm_lock_password_base.xml index 8e9a87b4c48..22726bee06d 100644 --- a/res/layout/confirm_lock_password_base.xml +++ b/res/layout/confirm_lock_password_base.xml @@ -70,7 +70,7 @@ android:layout_gravity="center_horizontal" android:layout_marginTop="-40dp" android:inputType="textPassword" - android:imeOptions="actionNext|flagNoFullscreen" + android:imeOptions="actionNext|flagNoFullscreen|flagForceAscii" android:gravity="center" android:textSize="16sp" style="@style/TextAppearance.PasswordEntry"/> diff --git a/res/layout/confirm_lock_password_internal.xml b/res/layout/confirm_lock_password_internal.xml index e22d76415f9..4f22cfb50f5 100644 --- a/res/layout/confirm_lock_password_internal.xml +++ b/res/layout/confirm_lock_password_internal.xml @@ -67,7 +67,7 @@ android:layout_gravity="center_horizontal" android:layout_marginTop="-40dp" android:inputType="textPassword" - android:imeOptions="actionNext|flagNoFullscreen" + android:imeOptions="actionNext|flagNoFullscreen|flagForceAscii" android:gravity="center" android:textSize="16sp" style="@style/TextAppearance.PasswordEntry"/> diff --git a/res/layout/crypt_keeper_password_field.xml b/res/layout/crypt_keeper_password_field.xml index bf286c0770a..9a06fd31b87 100644 --- a/res/layout/crypt_keeper_password_field.xml +++ b/res/layout/crypt_keeper_password_field.xml @@ -27,6 +27,7 @@ android:layout_width="0dip" android:layout_weight="1" android:inputType="textPassword" + android:imeOptions="flagForceAscii" android:textSize="16sp" android:padding="10sp" android:maxLength="500"