diff options
author | Svetoslav Ganov <svetoslavganov@google.com> | 2012-08-15 22:13:00 -0700 |
---|---|---|
committer | Svetoslav Ganov <svetoslavganov@google.com> | 2012-08-15 22:13:03 -0700 |
commit | 8631701bb770f3a4e3b2a139dc282f2244fe86e6 (patch) | |
tree | ffef399c08cc65408e31acc80c8f5dcbe0a1b2dc /packages/SettingsProvider | |
parent | 2d9063bc705aae7ef4cc90206ece03d4caeefba7 (diff) | |
download | frameworks_base-8631701bb770f3a4e3b2a139dc282f2244fe86e6.zip frameworks_base-8631701bb770f3a4e3b2a139dc282f2244fe86e6.tar.gz frameworks_base-8631701bb770f3a4e3b2a139dc282f2244fe86e6.tar.bz2 |
Allow enabled accessibility service to toggle tocuh exploration after an upgrade to JellyBean.
1. Before JellyBean touch exploration was a global setting controlled by the user via
the UI. However, if the enabled accessibility services do not handle touch exploration
mode, enabling it makes no sense. Therefore, in JellyBean the services request touch
exploration mode and the user is presented with a dialog to allow that and if she
does we store that in the database.
As a result of the above change a user that has enabled accessibility, touch
exploration, and some accessibility services running a pre-JellyBean system
version may lose touch exploration state, thus rendering the device useless unless
sighted help is provided, since the enabled service(s) are not in the list of
services to which the user granted a permission to put the device in touch explore
mode.
The fix is during a database upgrade to allow allow all enabled accessibility
services to toggle touch exploration provided accessibility and touch exploration
are enabled and no services can toggle touch exploration. Note that the user has
already manually enabled the services and touch exploration which means the she
has given consent to have these services work in touch exploration mode
bug:6996354
Change-Id: I0af2dc578cc4fbcc90043341035163b876978ab2
Diffstat (limited to 'packages/SettingsProvider')
-rw-r--r-- | packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java | 66 |
1 files changed, 61 insertions, 5 deletions
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java index 2594167..384e8af 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java @@ -63,7 +63,7 @@ public class DatabaseHelper extends SQLiteOpenHelper { // database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion' // is properly propagated through your change. Not doing so will result in a loss of user // settings. - private static final int DATABASE_VERSION = 79; + private static final int DATABASE_VERSION = 80; private Context mContext; @@ -1071,6 +1071,52 @@ public class DatabaseHelper extends SQLiteOpenHelper { upgradeVersion = 79; } + if (upgradeVersion == 79) { + // Before touch exploration was a global setting controlled by the user + // via the UI. However, if the enabled accessibility services do not + // handle touch exploration mode, enabling it makes no sense. Therefore, + // now the services request touch exploration mode and the user is + // presented with a dialog to allow that and if she does we store that + // in the database. As a result of this change a user that has enabled + // accessibility, touch exploration, and some accessibility services + // may lose touch exploration state, thus rendering the device useless + // unless sighted help is provided, since the enabled service(s) are + // not in the list of services to which the user granted a permission + // to put the device in touch explore mode. Here we are allowing all + // enabled accessibility services to toggle touch exploration provided + // accessibility and touch exploration are enabled and no services can + // toggle touch exploration. Note that the user has already manually + // enabled the services and touch exploration which means the she has + // given consent to have these services work in touch exploration mode. + final boolean accessibilityEnabled = getIntValueFromTable(db, "secure", + Settings.Secure.ACCESSIBILITY_ENABLED, 0) == 1; + final boolean touchExplorationEnabled = getIntValueFromTable(db, "secure", + Settings.Secure.TOUCH_EXPLORATION_ENABLED, 0) == 1; + if (accessibilityEnabled && touchExplorationEnabled) { + String enabledServices = getStringValueFromTable(db, "secure", + Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, ""); + String touchExplorationGrantedServices = getStringValueFromTable(db, "secure", + Settings.Secure.TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES, ""); + if (TextUtils.isEmpty(touchExplorationGrantedServices) + && !TextUtils.isEmpty(enabledServices)) { + SQLiteStatement stmt = null; + try { + db.beginTransaction(); + stmt = db.compileStatement("INSERT OR REPLACE INTO secure(name,value)" + + " VALUES(?,?);"); + loadSetting(stmt, + Settings.Secure.TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES, + enabledServices); + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); + if (stmt != null) stmt.close(); + } + } + } + upgradeVersion = 80; + } + // *** Remember to update DATABASE_VERSION above! if (upgradeVersion != currentVersion) { @@ -1700,18 +1746,28 @@ public class DatabaseHelper extends SQLiteOpenHelper { } private int getIntValueFromSystem(SQLiteDatabase db, String name, int defaultValue) { - int value = defaultValue; + return getIntValueFromTable(db, "system", name, defaultValue); + } + + private int getIntValueFromTable(SQLiteDatabase db, String table, String name, + int defaultValue) { + String value = getStringValueFromTable(db, table, name, null); + return (value != null) ? Integer.parseInt(value) : defaultValue; + } + + private String getStringValueFromTable(SQLiteDatabase db, String table, String name, + String defaultValue) { Cursor c = null; try { - c = db.query("system", new String[] { Settings.System.VALUE }, "name='" + name + "'", + c = db.query(table, new String[] { Settings.System.VALUE }, "name='" + name + "'", null, null, null, null); if (c != null && c.moveToFirst()) { String val = c.getString(0); - value = val == null ? defaultValue : Integer.parseInt(val); + return val == null ? defaultValue : val; } } finally { if (c != null) c.close(); } - return value; + return defaultValue; } } |