summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/settings')
-rw-r--r--src/com/android/settings/AccessibilitySettings.java62
-rw-r--r--src/com/android/settings/bluetooth/CachedBluetoothDevice.java21
2 files changed, 65 insertions, 18 deletions
diff --git a/src/com/android/settings/AccessibilitySettings.java b/src/com/android/settings/AccessibilitySettings.java
index 321e956..104ee9e 100644
--- a/src/com/android/settings/AccessibilitySettings.java
+++ b/src/com/android/settings/AccessibilitySettings.java
@@ -56,6 +56,9 @@ public class AccessibilitySettings extends SettingsPreferenceFragment {
private static final String ACCESSIBILITY_SERVICES_CATEGORY =
"accessibility_services_category";
+ private static final String TOGGLE_ACCESSIBILITY_SCRIPT_INJECTION_CHECKBOX =
+ "toggle_accessibility_script_injection_checkbox";
+
private static final String POWER_BUTTON_CATEGORY =
"power_button_category";
@@ -64,6 +67,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment {
private CheckBoxPreference mToggleCheckBox;
+ private CheckBoxPreference mToggleScriptInjectionCheckBox;
+
private PreferenceCategory mPowerButtonCategory;
private CheckBoxPreference mPowerButtonEndsCallCheckBox;
@@ -81,18 +86,16 @@ public class AccessibilitySettings extends SettingsPreferenceFragment {
addPreferencesFromResource(R.xml.accessibility_settings);
mToggleCheckBox = (CheckBoxPreference) findPreference(
- TOGGLE_ACCESSIBILITY_SERVICE_CHECKBOX);
+ TOGGLE_ACCESSIBILITY_SERVICE_CHECKBOX);
+
+ mToggleScriptInjectionCheckBox = (CheckBoxPreference) findPreference(
+ TOGGLE_ACCESSIBILITY_SCRIPT_INJECTION_CHECKBOX);
mPowerButtonCategory = (PreferenceCategory) findPreference(POWER_BUTTON_CATEGORY);
mPowerButtonEndsCallCheckBox = (CheckBoxPreference) findPreference(
- POWER_BUTTON_ENDS_CALL_CHECKBOX);
+ POWER_BUTTON_ENDS_CALL_CHECKBOX);
addAccessibilitServicePreferences();
- }
-
- @Override
- public void onResume() {
- super.onResume();
final HashSet<String> enabled = new HashSet<String>();
String settingValue = Settings.Secure.getString(getContentResolver(),
@@ -136,6 +139,12 @@ public class AccessibilitySettings extends SettingsPreferenceFragment {
displayNoAppsAlert();
}
+ // set the accessibility script injection category
+ boolean scriptInjectionEnabled = (Settings.Secure.getInt(getContentResolver(),
+ Settings.Secure.ACCESSIBILITY_SCRIPT_INJECTION, 0) == 1);
+ mToggleScriptInjectionCheckBox.setChecked(scriptInjectionEnabled);
+ mToggleScriptInjectionCheckBox.setEnabled(true);
+
if (KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POWER)
&& Utils.isVoiceCapable(getActivity())) {
int incallPowerBehavior = Settings.Secure.getInt(getContentResolver(),
@@ -185,7 +194,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment {
final String key = preference.getKey();
if (TOGGLE_ACCESSIBILITY_SERVICE_CHECKBOX.equals(key)) {
- boolean isChecked = ((CheckBoxPreference) preference).isChecked();
handleEnableAccessibilityStateChange((CheckBoxPreference) preference);
} else if (POWER_BUTTON_ENDS_CALL_CHECKBOX.equals(key)) {
boolean isChecked = ((CheckBoxPreference) preference).isChecked();
@@ -196,6 +204,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment {
Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR,
(isChecked ? Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP
: Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF));
+ } else if (TOGGLE_ACCESSIBILITY_SCRIPT_INJECTION_CHECKBOX.equals(key)) {
+ handleToggleAccessibilityScriptInjection((CheckBoxPreference) preference);
} else if (preference instanceof CheckBoxPreference) {
handleEnableAccessibilityServiceStateChange((CheckBoxPreference) preference);
}
@@ -242,6 +252,42 @@ public class AccessibilitySettings extends SettingsPreferenceFragment {
}
/**
+ * Handles the change of the accessibility script injection setting state.
+ *
+ * @param preference The preference for enabling/disabling accessibility script injection.
+ */
+ private void handleToggleAccessibilityScriptInjection(CheckBoxPreference preference) {
+ if (preference.isChecked()) {
+ final CheckBoxPreference checkBoxPreference = preference;
+ // TODO: DialogFragment?
+ AlertDialog dialog = (new AlertDialog.Builder(getActivity()))
+ .setTitle(android.R.string.dialog_alert_title)
+ .setIcon(android.R.drawable.ic_dialog_alert)
+ .setMessage(getActivity().getString(
+ R.string.accessibility_script_injection_security_warning))
+ .setCancelable(true)
+ .setPositiveButton(android.R.string.ok,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ Settings.Secure.putInt(getContentResolver(),
+ Settings.Secure.ACCESSIBILITY_SCRIPT_INJECTION, 1);
+ }
+ })
+ .setNegativeButton(android.R.string.cancel,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ checkBoxPreference.setChecked(false);
+ }
+ })
+ .create();
+ dialog.show();
+ } else {
+ Settings.Secure.putInt(getContentResolver(),
+ Settings.Secure.ACCESSIBILITY_SCRIPT_INJECTION, 0);
+ }
+ }
+
+ /**
* Handles the change of the preference for enabling/disabling an AccessibilityService.
*
* @param preference The preference.
diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
index 5f374a5..d655f90 100644
--- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
+++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
@@ -91,10 +91,10 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
// See mConnectAttempted
private static final long MAX_UUID_DELAY_FOR_AUTO_CONNECT = 5000;
-
+
/**
* Describes the current device and profile for logging.
- *
+ *
* @param profile Profile to describe
* @return Description of the device and profile
*/
@@ -107,7 +107,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
return sb.toString();
}
-
+
private String describe(Profile profile) {
return describe(this, profile);
}
@@ -264,7 +264,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
.getProfileManager(mLocalManager, profile);
if (profileManager.isPreferred(mDevice)) {
++preferredProfiles;
- disconnectConnected(profile);
+ disconnectConnected(this, profile);
connectInt(this, profile);
}
}
@@ -287,7 +287,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
LocalBluetoothProfileManager profileManager = LocalBluetoothProfileManager
.getProfileManager(mLocalManager, profile);
profileManager.setPreferred(mDevice, false);
- disconnectConnected(profile);
+ disconnectConnected(this, profile);
connectInt(this, profile);
}
}
@@ -297,19 +297,20 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
mConnectAttempted = SystemClock.elapsedRealtime();
// Reset the only-show-one-error-dialog tracking variable
mIsConnectingErrorPossible = true;
- disconnectConnected(profile);
+ disconnectConnected(this, profile);
connectInt(this, profile);
}
- private void disconnectConnected(Profile profile) {
+ private void disconnectConnected(CachedBluetoothDevice device, Profile profile) {
LocalBluetoothProfileManager profileManager =
LocalBluetoothProfileManager.getProfileManager(mLocalManager, profile);
CachedBluetoothDeviceManager cachedDeviceManager = mLocalManager.getCachedDeviceManager();
Set<BluetoothDevice> devices = profileManager.getConnectedDevices();
if (devices == null) return;
- for (BluetoothDevice device : devices) {
- CachedBluetoothDevice cachedDevice = cachedDeviceManager.findDevice(device);
- if (cachedDevice != null) {
+ for (BluetoothDevice btDevice : devices) {
+ CachedBluetoothDevice cachedDevice = cachedDeviceManager.findDevice(btDevice);
+
+ if (cachedDevice != null && !cachedDevice.equals(device)) {
disconnectInt(cachedDevice, profile);
}
}