From 227dddf91046a3ca8a2dc1b2dceffd7cd89ef289 Mon Sep 17 00:00:00 2001 From: Janis Danisevskis Date: Wed, 22 Jan 2020 15:56:14 -0800 Subject: ConfirmationPrompt: Use default values for UIOptions ConfirmationPrompt passes magnified and inverted options to the keystore service. While gathering the accessibility_display_inversion_enabled setting, the implementation would throw an exception if this setting was never set by the user. This causes the font scaling property to be ignored. This patch uses default values in case the system setting is not set. Test: Run CTSVerifier Protected Confirmation test with increased font size. Merged-In: I03a3ef56209c73ca7d2b2527a5f145f744148e38 Change-Id: I03a3ef56209c73ca7d2b2527a5f145f744148e38 --- core/java/android/security/ConfirmationPrompt.java | 24 +++++++++------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/core/java/android/security/ConfirmationPrompt.java b/core/java/android/security/ConfirmationPrompt.java index 5330cffee3db..f67af85d00e3 100644 --- a/core/java/android/security/ConfirmationPrompt.java +++ b/core/java/android/security/ConfirmationPrompt.java @@ -212,20 +212,16 @@ public class ConfirmationPrompt { private int getUiOptionsAsFlags() { int uiOptionsAsFlags = 0; - try { - ContentResolver contentResolver = mContext.getContentResolver(); - int inversionEnabled = Settings.Secure.getInt(contentResolver, - Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED); - if (inversionEnabled == 1) { - uiOptionsAsFlags |= UI_OPTION_ACCESSIBILITY_INVERTED_FLAG; - } - float fontScale = Settings.System.getFloat(contentResolver, - Settings.System.FONT_SCALE); - if (fontScale > 1.0) { - uiOptionsAsFlags |= UI_OPTION_ACCESSIBILITY_MAGNIFIED_FLAG; - } - } catch (SettingNotFoundException e) { - Log.w(TAG, "Unexpected SettingNotFoundException"); + ContentResolver contentResolver = mContext.getContentResolver(); + int inversionEnabled = Settings.Secure.getInt(contentResolver, + Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, 0); + if (inversionEnabled == 1) { + uiOptionsAsFlags |= UI_OPTION_ACCESSIBILITY_INVERTED_FLAG; + } + float fontScale = Settings.System.getFloat(contentResolver, + Settings.System.FONT_SCALE, (float) 1.0); + if (fontScale > 1.0) { + uiOptionsAsFlags |= UI_OPTION_ACCESSIBILITY_MAGNIFIED_FLAG; } return uiOptionsAsFlags; } -- cgit v1.2.3-59-g8ed1b