Skip to content

Commit 27d9183

Browse files
sganovAndroid (Google) Code Review
authored andcommitted
Merge "Core accessibility settings should not be cleared on restore." into jb-mr1-dev
2 parents 3e451fa + 818d204 commit 27d9183

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

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

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@
2020

2121
import android.app.ActivityManagerNative;
2222
import android.app.IActivityManager;
23-
import android.app.backup.BackupDataInput;
2423
import android.app.backup.IBackupManager;
25-
import android.content.ContentResolver;
2624
import android.content.Context;
27-
import android.content.IContentService;
2825
import android.content.res.Configuration;
2926
import android.location.LocationManager;
3027
import android.media.AudioManager;
@@ -33,23 +30,15 @@
3330
import android.os.ServiceManager;
3431
import android.provider.Settings;
3532
import android.text.TextUtils;
36-
import android.util.Log;
3733

3834
public class SettingsHelper {
39-
private static final String TAG = "SettingsHelper";
40-
4135
private Context mContext;
4236
private AudioManager mAudioManager;
43-
private IContentService mContentService;
44-
private IPowerManager mPowerManager;
4537

4638
public SettingsHelper(Context context) {
4739
mContext = context;
4840
mAudioManager = (AudioManager) context
4941
.getSystemService(Context.AUDIO_SERVICE);
50-
mContentService = ContentResolver.getContentService();
51-
mPowerManager = IPowerManager.Stub.asInterface(
52-
ServiceManager.getService("power"));
5342
}
5443

5544
/**
@@ -71,10 +60,31 @@ public boolean restoreValue(String name, String value) {
7160
return false;
7261
} else if (Settings.Secure.BACKUP_AUTO_RESTORE.equals(name)) {
7362
setAutoRestore(Integer.parseInt(value) == 1);
63+
} else if (isAlreadyConfiguredCriticalAccessibilitySetting(name)) {
64+
return false;
7465
}
7566
return true;
7667
}
7768

69+
private boolean isAlreadyConfiguredCriticalAccessibilitySetting(String name) {
70+
// These are the critical accessibility settings that are required for a
71+
// blind user to be able to interact with the device. If these settings are
72+
// already configured, we will not overwrite them. If they are already set,
73+
// it means that the user has performed a global gesture to enable accessibility
74+
// and definitely needs these features working after the restore.
75+
if (Settings.Secure.ACCESSIBILITY_ENABLED.equals(name)
76+
|| Settings.Secure.ACCESSIBILITY_SCRIPT_INJECTION.equals(name)
77+
|| Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD.equals(name)
78+
|| Settings.Secure.TOUCH_EXPLORATION_ENABLED.equals(name)) {
79+
return Settings.Secure.getInt(mContext.getContentResolver(), name, 0) != 0;
80+
} else if (Settings.Secure.TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES.equals(name)
81+
|| Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES.equals(name)) {
82+
return !TextUtils.isEmpty(Settings.Secure.getString(
83+
mContext.getContentResolver(), name));
84+
}
85+
return false;
86+
}
87+
7888
private void setAutoRestore(boolean enabled) {
7989
try {
8090
IBackupManager bm = IBackupManager.Stub.asInterface(

0 commit comments

Comments
 (0)