Skip to content

Commit ea25ea7

Browse files
sganovAndroid (Google) Code Review
authored andcommitted
Merge "Adding a system preference whether to speak passwords in accessibility mode." into ics-mr1
2 parents 4079702 + 55f937a commit ea25ea7

File tree

5 files changed

+38
-3
lines changed

5 files changed

+38
-3
lines changed

api/current.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17433,6 +17433,7 @@ package android.provider {
1743317433
method public static boolean putString(android.content.ContentResolver, java.lang.String, java.lang.String);
1743417434
method public static final void setLocationProviderEnabled(android.content.ContentResolver, java.lang.String, boolean);
1743517435
field public static final java.lang.String ACCESSIBILITY_ENABLED = "accessibility_enabled";
17436+
field public static final java.lang.String ACCESSIBILITY_SPEAK_PASSWORD = "speak_password";
1743617437
field public static final java.lang.String ADB_ENABLED = "adb_enabled";
1743717438
field public static final java.lang.String ALLOWED_GEOLOCATION_ORIGINS = "allowed_geolocation_origins";
1743817439
field public static final java.lang.String ALLOW_MOCK_LOCATION = "mock_location";

core/java/android/inputmethodservice/KeyboardView.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import android.media.AudioManager;
3232
import android.os.Handler;
3333
import android.os.Message;
34+
import android.provider.Settings;
3435
import android.util.AttributeSet;
3536
import android.util.TypedValue;
3637
import android.view.GestureDetector;
@@ -967,8 +968,13 @@ private void sendAccessibilityEventForUnicodeCharacter(int eventType, int code)
967968
AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
968969
onInitializeAccessibilityEvent(event);
969970
String text = null;
970-
// Add text only if headset is used to avoid leaking passwords.
971-
if (mAudioManager.isBluetoothA2dpOn() || mAudioManager.isWiredHeadsetOn()) {
971+
// This is very efficient since the properties are cached.
972+
final boolean speakPassword = Settings.Secure.getInt(mContext.getContentResolver(),
973+
Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD, 0) != 0;
974+
// Add text only if password announcement is enabled or if headset is
975+
// used to avoid leaking passwords.
976+
if (speakPassword || mAudioManager.isBluetoothA2dpOn()
977+
|| mAudioManager.isWiredHeadsetOn()) {
972978
switch (code) {
973979
case Keyboard.KEYCODE_ALT:
974980
text = mContext.getString(R.string.keyboardview_keycode_alt);

core/java/android/provider/Settings.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2753,6 +2753,11 @@ public static final String getBluetoothInputDevicePriorityKey(String address) {
27532753
public static final String ENABLED_ACCESSIBILITY_SERVICES =
27542754
"enabled_accessibility_services";
27552755

2756+
/**
2757+
* Whether to speak passwords while in accessibility mode.
2758+
*/
2759+
public static final String ACCESSIBILITY_SPEAK_PASSWORD = "speak_password";
2760+
27562761
/**
27572762
* If injection of accessibility enhancing JavaScript scripts
27582763
* is enabled.
@@ -4079,6 +4084,7 @@ public static final String getBluetoothInputDevicePriorityKey(String address) {
40794084
ENABLED_ACCESSIBILITY_SERVICES,
40804085
TOUCH_EXPLORATION_ENABLED,
40814086
ACCESSIBILITY_ENABLED,
4087+
ACCESSIBILITY_SPEAK_PASSWORD,
40824088
TTS_USE_DEFAULTS,
40834089
TTS_DEFAULT_RATE,
40844090
TTS_DEFAULT_PITCH,

packages/SettingsProvider/res/values/defaults.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@
8080
<!-- Default for Settings.Secure.ACCESSIBILITY_SCRIPT_INJECTION -->
8181
<bool name="def_accessibility_script_injection">false</bool>
8282

83+
<!-- Default for Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD -->
84+
<bool name="def_accessibility_speak_password">false</bool>
85+
8386
<!-- Default for Settings.Secure.ACCESSIBILITY_WEB_CONTENT_KEY_BINDINGS -->
8487
<string name="def_accessibility_web_content_key_bindings" translatable="false">
8588
<!-- DPAD/Trackball UP - traverse previous on current axis and send an event. -->

packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
6363
// database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion'
6464
// is properly propagated through your change. Not doing so will result in a loss of user
6565
// settings.
66-
private static final int DATABASE_VERSION = 71;
66+
private static final int DATABASE_VERSION = 72;
6767

6868
private Context mContext;
6969

@@ -952,6 +952,22 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int currentVersion) {
952952
upgradeVersion = 71;
953953
}
954954

955+
if (upgradeVersion == 71) {
956+
// New setting to specify whether to speak passwords in accessibility mode.
957+
db.beginTransaction();
958+
SQLiteStatement stmt = null;
959+
try {
960+
stmt = db.compileStatement("INSERT INTO secure(name,value)"
961+
+ " VALUES(?,?);");
962+
loadBooleanSetting(stmt, Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD,
963+
R.bool.def_accessibility_speak_password);
964+
} finally {
965+
db.endTransaction();
966+
if (stmt != null) stmt.close();
967+
}
968+
upgradeVersion = 72;
969+
}
970+
955971
// *** Remember to update DATABASE_VERSION above!
956972

957973
if (upgradeVersion != currentVersion) {
@@ -1489,6 +1505,9 @@ private void loadSecureSettings(SQLiteDatabase db) {
14891505

14901506
loadBooleanSetting(stmt, Settings.Secure.TOUCH_EXPLORATION_ENABLED,
14911507
R.bool.def_touch_exploration_enabled);
1508+
1509+
loadBooleanSetting(stmt, Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD,
1510+
R.bool.def_accessibility_speak_password);
14921511
} finally {
14931512
if (stmt != null) stmt.close();
14941513
}

0 commit comments

Comments
 (0)