Skip to content

Commit ca34bcf

Browse files
committed
resolved conflicts for merge of 80c904d to jb-mr1-dev
Change-Id: Ic2f8d64cd716d04a533ca0685d1fb0d5e2a21933
2 parents 14250cc + 80c904d commit ca34bcf

File tree

1 file changed

+63
-9
lines changed

1 file changed

+63
-9
lines changed

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

Lines changed: 63 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import android.util.Log;
3939

4040
import com.android.internal.content.PackageHelper;
41-
import com.android.internal.telephony.BaseCommands;
4241
import com.android.internal.telephony.Phone;
4342
import com.android.internal.telephony.PhoneConstants;
4443
import com.android.internal.telephony.RILConstants;
@@ -65,7 +64,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
6564
// database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion'
6665
// is properly propagated through your change. Not doing so will result in a loss of user
6766
// settings.
68-
private static final int DATABASE_VERSION = 80;
67+
private static final int DATABASE_VERSION = 81;
6968

7069
private Context mContext;
7170

@@ -1073,9 +1072,55 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int currentVersion) {
10731072
upgradeVersion = 79;
10741073
}
10751074

1075+
if (upgradeVersion == 79) {
1076+
// Before touch exploration was a global setting controlled by the user
1077+
// via the UI. However, if the enabled accessibility services do not
1078+
// handle touch exploration mode, enabling it makes no sense. Therefore,
1079+
// now the services request touch exploration mode and the user is
1080+
// presented with a dialog to allow that and if she does we store that
1081+
// in the database. As a result of this change a user that has enabled
1082+
// accessibility, touch exploration, and some accessibility services
1083+
// may lose touch exploration state, thus rendering the device useless
1084+
// unless sighted help is provided, since the enabled service(s) are
1085+
// not in the list of services to which the user granted a permission
1086+
// to put the device in touch explore mode. Here we are allowing all
1087+
// enabled accessibility services to toggle touch exploration provided
1088+
// accessibility and touch exploration are enabled and no services can
1089+
// toggle touch exploration. Note that the user has already manually
1090+
// enabled the services and touch exploration which means the she has
1091+
// given consent to have these services work in touch exploration mode.
1092+
final boolean accessibilityEnabled = getIntValueFromTable(db, "secure",
1093+
Settings.Secure.ACCESSIBILITY_ENABLED, 0) == 1;
1094+
final boolean touchExplorationEnabled = getIntValueFromTable(db, "secure",
1095+
Settings.Secure.TOUCH_EXPLORATION_ENABLED, 0) == 1;
1096+
if (accessibilityEnabled && touchExplorationEnabled) {
1097+
String enabledServices = getStringValueFromTable(db, "secure",
1098+
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, "");
1099+
String touchExplorationGrantedServices = getStringValueFromTable(db, "secure",
1100+
Settings.Secure.TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES, "");
1101+
if (TextUtils.isEmpty(touchExplorationGrantedServices)
1102+
&& !TextUtils.isEmpty(enabledServices)) {
1103+
SQLiteStatement stmt = null;
1104+
try {
1105+
db.beginTransaction();
1106+
stmt = db.compileStatement("INSERT OR REPLACE INTO secure(name,value)"
1107+
+ " VALUES(?,?);");
1108+
loadSetting(stmt,
1109+
Settings.Secure.TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES,
1110+
enabledServices);
1111+
db.setTransactionSuccessful();
1112+
} finally {
1113+
db.endTransaction();
1114+
if (stmt != null) stmt.close();
1115+
}
1116+
}
1117+
}
1118+
upgradeVersion = 80;
1119+
}
1120+
10761121
// vvv Jelly Bean MR1 changes begin here vvv
10771122

1078-
if (upgradeVersion == 79) {
1123+
if (upgradeVersion == 80) {
10791124
// update screensaver settings
10801125
db.beginTransaction();
10811126
SQLiteStatement stmt = null;
@@ -1093,10 +1138,9 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int currentVersion) {
10931138
db.endTransaction();
10941139
if (stmt != null) stmt.close();
10951140
}
1096-
upgradeVersion = 80;
1141+
upgradeVersion = 81;
10971142
}
10981143

1099-
11001144
// *** Remember to update DATABASE_VERSION above!
11011145

11021146
if (upgradeVersion != currentVersion) {
@@ -1743,18 +1787,28 @@ private void loadFractionSetting(SQLiteStatement stmt, String key, int resid, in
17431787
}
17441788

17451789
private int getIntValueFromSystem(SQLiteDatabase db, String name, int defaultValue) {
1746-
int value = defaultValue;
1790+
return getIntValueFromTable(db, "system", name, defaultValue);
1791+
}
1792+
1793+
private int getIntValueFromTable(SQLiteDatabase db, String table, String name,
1794+
int defaultValue) {
1795+
String value = getStringValueFromTable(db, table, name, null);
1796+
return (value != null) ? Integer.parseInt(value) : defaultValue;
1797+
}
1798+
1799+
private String getStringValueFromTable(SQLiteDatabase db, String table, String name,
1800+
String defaultValue) {
17471801
Cursor c = null;
17481802
try {
1749-
c = db.query("system", new String[] { Settings.System.VALUE }, "name='" + name + "'",
1803+
c = db.query(table, new String[] { Settings.System.VALUE }, "name='" + name + "'",
17501804
null, null, null, null);
17511805
if (c != null && c.moveToFirst()) {
17521806
String val = c.getString(0);
1753-
value = val == null ? defaultValue : Integer.parseInt(val);
1807+
return val == null ? defaultValue : val;
17541808
}
17551809
} finally {
17561810
if (c != null) c.close();
17571811
}
1758-
return value;
1812+
return defaultValue;
17591813
}
17601814
}

0 commit comments

Comments
 (0)