Settings crash if android:settingsActivity AccessibilityServiceInfo XML is incorrect.

1. The code was not checking whether the settings activity exists
   before passing in to the SettingCheckboxClass.

bug:5038386

Change-Id: Iba4f5e2e5f6f3ed9c0fed5a5103d2e9a34399d97
diff --git a/src/com/android/settings/SettingsCheckBoxPreference.java b/src/com/android/settings/SettingsCheckBoxPreference.java
index 026e4e6..70b5ac1 100644
--- a/src/com/android/settings/SettingsCheckBoxPreference.java
+++ b/src/com/android/settings/SettingsCheckBoxPreference.java
@@ -38,14 +38,15 @@
     private final Intent mSettingsIntent;
 
     /**
-     * Creates a new instance.
+     * Creates a new instance. The constructor is checking whether the
+     * settings intent is resolved to an activity and acts accordingly.
      *
      * @param context Context for accessing resources.
-     * @param settingsIntent Intent to use as settings for the item represented by
+     * @param intent Intent to use as settings for the item represented by
      *        this preference. Pass <code>null</code> if there is no associated 
      *        settings activity.
      */
-    public SettingsCheckBoxPreference(Context context, Intent settingsIntent) {
+    public SettingsCheckBoxPreference(Context context, Intent intent) {
         super(context);
 
         if (sDimAlpha == Integer.MIN_VALUE) {
@@ -54,7 +55,13 @@
             sDimAlpha = (int) (outValue.getFloat() * 255);
         }
 
-        mSettingsIntent = settingsIntent;
+        if (intent != null
+                && !context.getPackageManager().queryIntentActivities(intent, 0).isEmpty()) {
+            mSettingsIntent = intent;
+        } else {
+            mSettingsIntent = null;
+        }
+
         setWidgetLayoutResource(R.layout.preference_settings_checkbox_widget);
     }