Accessibility: filter touches to Enable button

To prevent tap-jacking, filter touches to the enable button if there is
another window obscuring the screen.

Bug: 11242907
Change-Id: I0228cd480faf8e7ebf70394d9bb60fa2e4138fb4
This commit is contained in:
Kenny Root
2013-10-16 10:10:45 -07:00
parent f88e5442f5
commit 94d4f23dcc

View File

@@ -154,41 +154,44 @@ public class ToggleAccessibilityServicePreferenceFragment
public Dialog onCreateDialog(int dialogId) { public Dialog onCreateDialog(int dialogId) {
switch (dialogId) { switch (dialogId) {
case DIALOG_ID_ENABLE_WARNING: { case DIALOG_ID_ENABLE_WARNING: {
mShownDialogId = DIALOG_ID_ENABLE_WARNING; mShownDialogId = DIALOG_ID_ENABLE_WARNING;
AccessibilityServiceInfo info = getAccessibilityServiceInfo(); AccessibilityServiceInfo info = getAccessibilityServiceInfo();
if (info == null) { if (info == null) {
return null; return null;
}
AlertDialog ad = new AlertDialog.Builder(getActivity())
.setTitle(getString(R.string.enable_service_title,
info.getResolveInfo().loadLabel(getPackageManager())))
.setIconAttribute(android.R.attr.alertDialogIcon)
.setView(createEnableDialogContentView(info))
.setCancelable(true)
.setPositiveButton(android.R.string.ok, this)
.setNegativeButton(android.R.string.cancel, this)
.create();
ad.getButton(AlertDialog.BUTTON_POSITIVE)
.setFilterTouchesWhenObscured(true);
return ad;
} }
return new AlertDialog.Builder(getActivity())
.setTitle(getString(R.string.enable_service_title,
info.getResolveInfo().loadLabel(getPackageManager())))
.setIconAttribute(android.R.attr.alertDialogIcon)
.setView(createEnableDialogContentView(info))
.setCancelable(true)
.setPositiveButton(android.R.string.ok, this)
.setNegativeButton(android.R.string.cancel, this)
.create();
}
case DIALOG_ID_DISABLE_WARNING: { case DIALOG_ID_DISABLE_WARNING: {
mShownDialogId = DIALOG_ID_DISABLE_WARNING; mShownDialogId = DIALOG_ID_DISABLE_WARNING;
AccessibilityServiceInfo info = getAccessibilityServiceInfo(); AccessibilityServiceInfo info = getAccessibilityServiceInfo();
if (info == null) { if (info == null) {
return null; return null;
}
return new AlertDialog.Builder(getActivity())
.setTitle(getString(R.string.disable_service_title,
info.getResolveInfo().loadLabel(getPackageManager())))
.setIconAttribute(android.R.attr.alertDialogIcon)
.setMessage(getString(R.string.disable_service_message,
info.getResolveInfo().loadLabel(getPackageManager())))
.setCancelable(true)
.setPositiveButton(android.R.string.ok, this)
.setNegativeButton(android.R.string.cancel, this)
.create();
} }
return new AlertDialog.Builder(getActivity())
.setTitle(getString(R.string.disable_service_title,
info.getResolveInfo().loadLabel(getPackageManager())))
.setIconAttribute(android.R.attr.alertDialogIcon)
.setMessage(getString(R.string.disable_service_message,
info.getResolveInfo().loadLabel(getPackageManager())))
.setCancelable(true)
.setPositiveButton(android.R.string.ok, this)
.setNegativeButton(android.R.string.cancel, this)
.create();
}
default: { default: {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
} }
} }