am 84f2d7ee: Merge "Remove unsupported visual_lines" into lmp-preview-dev

* commit '84f2d7ee4cf6b1d4258b35ce23b57ac145c951ae':
  Remove unsupported visual_lines
diff --git a/res/layout/trust_agent_settings.xml b/res/layout/advanced_security_settings.xml
similarity index 100%
rename from res/layout/trust_agent_settings.xml
rename to res/layout/advanced_security_settings.xml
diff --git a/res/layout/wifi_dialog.xml b/res/layout/wifi_dialog.xml
index 7275c73..d0ae981 100644
--- a/res/layout/wifi_dialog.xml
+++ b/res/layout/wifi_dialog.xml
@@ -197,11 +197,6 @@
                         android:prompt="@string/proxy_settings_title"
                         android:entries="@array/wifi_proxy_settings" />
 
-                <TextView android:id="@+id/proxy_pac_info"
-                        style="@style/wifi_item_content"
-                        android:textStyle="bold"
-                        android:textAlignment="viewStart"
-                        android:visibility="gone"/>
             </LinearLayout>
 
             <LinearLayout android:id="@+id/proxy_warning_limited_support"
@@ -216,6 +211,21 @@
                         android:text="@string/proxy_warning_limited_support" />
             </LinearLayout>
 
+            <LinearLayout android:id="@+id/proxy_pac_field"
+                    style="@style/wifi_section"
+                    android:visibility="gone">
+                <LinearLayout style="@style/wifi_item">
+                    <TextView
+                            style="@style/wifi_item_label"
+                            android:text="@string/proxy_url_title" />
+
+                    <EditText android:id="@+id/proxy_pac"
+                            style="@style/wifi_item_content"
+                            android:hint="@string/proxy_url_hint"
+                            android:inputType="textNoSuggestions"
+                            android:singleLine="true"/>
+                </LinearLayout>
+            </LinearLayout>
             <LinearLayout android:id="@+id/proxy_fields"
                     style="@style/wifi_section"
                     android:visibility="gone">
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 508e799..3695d3a 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -469,6 +469,8 @@
         <item>None</item>
         <!-- Manual HTTP proxy settings are used for the current wifi network [CHAR LIMIT=25] -->
         <item>Manual</item>
+        <!-- Proxy Auto-Config URL that is used for the current wifi network [CHAR LIMIT=25] -->
+        <item>Proxy Auto-Config</item>
     </string-array>
 
     <!-- Locales in this list are displayed with the corresponding
diff --git a/res/values/strings.xml b/res/values/strings.xml
index c055ddd..11adc77 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -445,8 +445,10 @@
     <!-- HTTP proxy settings. Warning message about limited application support [CHAR LIMIT=100]-->
     <string name="proxy_warning_limited_support">The HTTP proxy is used by the browser but may not be used by the other apps.</string>
 
-    <!-- HTTP proxy settings. Title for Proxy-Auto Config URL.  [CHAR LIMIT=NONE]-->
-    <string name="proxy_url">"PAC URL: "</string>
+    <!-- HTTP proxy settings. Title for Proxy-Auto Config URL.  [CHAR LIMIT=25] -->
+    <string name="proxy_url_title">"PAC URL: "</string>
+    <!-- HTTP proxy settings. Hint for Proxy-Auto Config URL. -->
+    <string name="proxy_url_hint" translatable="false">https://www.example.com/proxy.pac</string>
 
     <!-- Radio Info screen. Label for a status item.  Used for diagnostic info screens, precise translation isn't needed -->
     <string name="radio_info_signal_location_label">Location:</string>
@@ -3151,10 +3153,12 @@
 
     <!-- Setting Checkbox title whether to show options for wireless display certification -->
     <string name="wifi_display_certification">Wireless display certification</string>
-    <!-- Setting Checkbox title whether to show options for WiFi Verbose Logging -->
+    <!-- Setting Checkbox title whether to enable WiFi Verbose Logging. [CHAR LIMIT=40] -->
     <string name="wifi_verbose_logging">Enable WiFi Verbose Logging</string>
     <!-- setting Checkbox summary whether to show options for wireless display certification  -->
     <string name="wifi_display_certification_summary">Show options for wireless display certification</string>
+    <!-- Setting Checkbox title whether to enable Wifi verbose Logging [CHAR LIMIT=80] -->
+    <string name="wifi_verbose_logging_summary">Increase Wifi logging level, show per SSID RSSI in WiFi Picker</string>
     <!-- Setting Checkbox title whether to allow mock locations -->
     <string name="allow_mock_location">Allow mock locations</string>
     <!-- setting Checkbox summary whether to allow mock locations  -->
@@ -3975,6 +3979,8 @@
     <string name="trusted_credentials">Trusted credentials</string>
     <!-- Summary of preference to display trusted credentials (aka CA certificates) [CHAR LIMIT=NONE] -->
     <string name="trusted_credentials_summary">Display trusted CA certificates</string>
+    <!-- Title of preference group for advance security settings [CHAR LIMIT=30] -->
+    <string name="advanced_security_title">Advanced</string>
     <!-- Title of preference of what type of credential storage this device has: hardware or software [CHAR LIMIT=30] -->
     <string name="credential_storage_type">Storage type</string>
     <!-- Summary text for preference showing what type of credential storage this device has when it is stored in a hardware-backed storage (as opposed to "software only") [CHAR LIMIT=NONE] -->
@@ -4207,6 +4213,8 @@
     <string name="accessibility_sync_enabled">Sync enabled</string>
     <!-- Content description of the disabled sync icon for accessibility. [CHAR LIMIT=NONE] -->
     <string name="accessibility_sync_disabled">Sync disabled</string>
+    <!-- Content description of the in progress sync icon for accessibility. [CHAR LIMIT=NONE] -->
+    <string name="accessibility_sync_in_progress">Syncing now</string>
     <!-- Content description of the disabled sync icon for accessibility. [CHAR LIMIT=NONE] -->
     <string name="accessibility_sync_error">Sync error.</string>
     <!-- Image description for the sync failed icon. -->
diff --git a/res/xml/development_prefs.xml b/res/xml/development_prefs.xml
index 1d7d967..d435371 100644
--- a/res/xml/development_prefs.xml
+++ b/res/xml/development_prefs.xml
@@ -109,6 +109,7 @@
         <CheckBoxPreference
             android:key="wifi_verbose_logging"
             android:title="@string/wifi_verbose_logging" />
+            android:summary="@string/wifi_verbose_logging_summary"/>
 
     </PreferenceCategory>
 
diff --git a/res/xml/security_settings_misc.xml b/res/xml/security_settings_misc.xml
index 84ce96c..c8f3e02 100644
--- a/res/xml/security_settings_misc.xml
+++ b/res/xml/security_settings_misc.xml
@@ -47,12 +47,6 @@
                 android:persistent="false"
                 android:fragment="com.android.settings.DeviceAdminSettings"/>
 
-        <Preference android:key="manage_trust_agents"
-                    android:title="@string/manage_trust_agents"
-                    android:summary="@string/manage_trust_agents_summary"
-                    android:persistent="false"
-                    android:fragment="com.android.settings.TrustAgentSettings"/>
-
         <CheckBoxPreference android:key="toggle_install_applications"
                 android:title="@string/install_applications"
                 android:summaryOff="@string/install_unknown_applications"
@@ -64,7 +58,6 @@
                 android:summaryOff="@string/verify_applications_summary"
                 android:summaryOn="@string/verify_applications_summary"
                 android:persistent="false" />
-
     </PreferenceCategory>
 
     <PreferenceCategory android:key="credentials_management"
@@ -99,4 +92,14 @@
                     android:targetClass="com.android.settings.CredentialStorage"/>
         </Preference>
     </PreferenceCategory>
+
+    <PreferenceCategory android:key="advanced_security"
+            android:title="@string/advanced_security_title"
+            android:persistent="false">
+        <Preference android:key="manage_trust_agents"
+                android:title="@string/manage_trust_agents"
+                android:summary="@string/manage_trust_agents_summary"
+                android:persistent="false"
+                android:fragment="com.android.settings.AdvancedSecuritySettings"/>
+    </PreferenceCategory>
 </PreferenceScreen>
diff --git a/res/xml/security_settings_picker.xml b/res/xml/security_settings_picker.xml
index 6ed7d5f..fda44e1 100644
--- a/res/xml/security_settings_picker.xml
+++ b/res/xml/security_settings_picker.xml
@@ -14,7 +14,9 @@
      limitations under the License.
 -->
 
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+        android:title="@string/lock_settings_picker_title"
+        android:key="lock_settings_picker">
 
     <PreferenceScreen
             android:key="unlock_set_off"
diff --git a/src/com/android/settings/AccountPreference.java b/src/com/android/settings/AccountPreference.java
index 2cc013c..7547721 100644
--- a/src/com/android/settings/AccountPreference.java
+++ b/src/com/android/settings/AccountPreference.java
@@ -140,6 +140,8 @@
                 return getContext().getString(R.string.accessibility_sync_disabled);
             case SYNC_ERROR:
                 return getContext().getString(R.string.accessibility_sync_error);
+            case SYNC_IN_PROGRESS:
+                return getContext().getString(R.string.accessibility_sync_in_progress);
             default:
                 Log.e(TAG, "Unknown sync status: " + status);
                 return getContext().getString(R.string.accessibility_sync_error);
diff --git a/src/com/android/settings/TrustAgentSettings.java b/src/com/android/settings/AdvancedSecuritySettings.java
similarity index 69%
rename from src/com/android/settings/TrustAgentSettings.java
rename to src/com/android/settings/AdvancedSecuritySettings.java
index d31436d..c497ac4 100644
--- a/src/com/android/settings/TrustAgentSettings.java
+++ b/src/com/android/settings/AdvancedSecuritySettings.java
@@ -18,26 +18,17 @@
 
 import com.android.internal.widget.LockPatternUtils;
 
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
 import android.app.ListFragment;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
-import android.content.res.XmlResourceParser;
 import android.graphics.drawable.Drawable;
 import android.os.Bundle;
 import android.service.trust.TrustAgentService;
 import android.util.ArrayMap;
 import android.util.ArraySet;
-import android.util.AttributeSet;
-import android.util.Slog;
-import android.util.Xml;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -46,15 +37,12 @@
 import android.widget.ImageView;
 import android.widget.TextView;
 
-import java.io.IOException;
 import java.util.List;
 
-public class TrustAgentSettings extends ListFragment implements View.OnClickListener {
-    static final String TAG = "TrustAgentSettings";
+public class AdvancedSecuritySettings extends ListFragment implements View.OnClickListener {
+    static final String TAG = "AdvancedSecuritySettings";
 
     private static final String SERVICE_INTERFACE = TrustAgentService.SERVICE_INTERFACE;
-    private static final String TRUST_AGENT_META_DATA = TrustAgentService.TRUST_AGENT_META_DATA;
-
 
     private final ArraySet<ComponentName> mActiveAgents = new ArraySet<ComponentName>();
     private final ArrayMap<ComponentName, AgentInfo> mAvailableAgents
@@ -94,7 +82,7 @@
                     container.getContext().getApplicationContext());
         }
         setListAdapter(new AgentListAdapter());
-        return inflater.inflate(R.layout.trust_agent_settings, container, false);
+        return inflater.inflate(R.layout.advanced_security_settings, container, false);
     }
 
     @Override
@@ -121,70 +109,21 @@
 
         for (ResolveInfo resolveInfo : resolveInfos) {
             if (resolveInfo.serviceInfo == null) continue;
-            ComponentName name = getComponentName(resolveInfo);
+            ComponentName name = TrustAgentUtils.getComponentName(resolveInfo);
             if (!mAvailableAgents.containsKey(name)) {
                 AgentInfo agentInfo = new AgentInfo();
                 agentInfo.label = resolveInfo.loadLabel(pm);
                 agentInfo.icon = resolveInfo.loadIcon(pm);
                 agentInfo.component = name;
-                agentInfo.settings = getSettingsComponentName(pm, resolveInfo);
+                TrustAgentUtils.TrustAgentComponentInfo trustAgentComponentInfo =
+                        TrustAgentUtils.getSettingsComponent(pm, resolveInfo);
+                agentInfo.settings = trustAgentComponentInfo.componentName;
                 mAvailableAgents.put(name, agentInfo);
             }
         }
         ((BaseAdapter) getListAdapter()).notifyDataSetChanged();
     }
 
-    private ComponentName getComponentName(ResolveInfo resolveInfo) {
-        if (resolveInfo == null || resolveInfo.serviceInfo == null) return null;
-        return new ComponentName(resolveInfo.serviceInfo.packageName, resolveInfo.serviceInfo.name);
-    }
-
-    private ComponentName getSettingsComponentName(PackageManager pm, ResolveInfo resolveInfo) {
-        if (resolveInfo == null || resolveInfo.serviceInfo == null
-                || resolveInfo.serviceInfo.metaData == null) return null;
-        String cn = null;
-        XmlResourceParser parser = null;
-        Exception caughtException = null;
-        try {
-            parser = resolveInfo.serviceInfo.loadXmlMetaData(pm, TRUST_AGENT_META_DATA);
-            if (parser == null) {
-                Slog.w(TAG, "Can't find " + TRUST_AGENT_META_DATA + " meta-data");
-                return null;
-            }
-            Resources res = pm.getResourcesForApplication(resolveInfo.serviceInfo.applicationInfo);
-            AttributeSet attrs = Xml.asAttributeSet(parser);
-            int type;
-            while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
-                    && type != XmlPullParser.START_TAG) {
-            }
-            String nodeName = parser.getName();
-            if (!"trust-agent".equals(nodeName)) {
-                Slog.w(TAG, "Meta-data does not start with trust-agent tag");
-                return null;
-            }
-            TypedArray sa = res
-                    .obtainAttributes(attrs, com.android.internal.R.styleable.TrustAgent);
-            cn = sa.getString(com.android.internal.R.styleable.TrustAgent_settingsActivity);
-            sa.recycle();
-        } catch (PackageManager.NameNotFoundException e) {
-            caughtException = e;
-        } catch (IOException e) {
-            caughtException = e;
-        } catch (XmlPullParserException e) {
-            caughtException = e;
-        } finally {
-            if (parser != null) parser.close();
-        }
-        if (caughtException != null) {
-            Slog.w(TAG, "Error parsing : " + resolveInfo.serviceInfo.packageName, caughtException);
-            return null;
-        }
-        if (cn != null && cn.indexOf('/') < 0) {
-            cn = resolveInfo.serviceInfo.packageName + "/" + cn;
-        }
-        return cn == null ? null : ComponentName.unflattenFromString(cn);
-    }
-
     @Override
     public void onClick(View view) {
         ViewHolder h = (ViewHolder) view.getTag();
@@ -282,10 +221,10 @@
             h.name = (TextView)v.findViewById(R.id.name);
             h.checkbox = (CheckBox)v.findViewById(R.id.checkbox);
             h.clickable = v.findViewById(R.id.clickable);
-            h.clickable.setOnClickListener(TrustAgentSettings.this);
+            h.clickable.setOnClickListener(AdvancedSecuritySettings.this);
             h.description = (TextView)v.findViewById(R.id.description);
             h.settings = v.findViewById(R.id.settings);
-            h.settings.setOnClickListener(TrustAgentSettings.this);
+            h.settings.setOnClickListener(AdvancedSecuritySettings.this);
             v.setTag(h);
             h.settings.setTag(h);
             h.clickable.setTag(h);
diff --git a/src/com/android/settings/ChooseLockGeneric.java b/src/com/android/settings/ChooseLockGeneric.java
index 0081ad3..30a72ef 100644
--- a/src/com/android/settings/ChooseLockGeneric.java
+++ b/src/com/android/settings/ChooseLockGeneric.java
@@ -23,8 +23,6 @@
 import android.content.Intent;
 import android.content.pm.UserInfo;
 import android.os.Bundle;
-import android.os.Process;
-import android.os.UserHandle;
 import android.os.UserManager;
 import android.preference.Preference;
 import android.preference.PreferenceScreen;
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index 00d1d89..ab03853 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -41,6 +41,7 @@
 import android.provider.SearchIndexableResource;
 import android.provider.Settings;
 import android.security.KeyStore;
+import android.service.trust.TrustAgentService;
 import android.telephony.TelephonyManager;
 import android.util.Log;
 
@@ -58,6 +59,8 @@
 public class SecuritySettings extends RestrictedSettingsFragment
         implements OnPreferenceChangeListener, DialogInterface.OnClickListener, Indexable {
     static final String TAG = "SecuritySettings";
+    private static final Intent TRUST_AGENT_INTENT =
+            new Intent(TrustAgentService.SERVICE_INTERFACE);
 
     // Lock Settings
     private static final String KEY_UNLOCK_SET_OR_CHANGE = "unlock_set_or_change";
@@ -74,6 +77,7 @@
     private static final int SET_OR_CHANGE_LOCK_METHOD_REQUEST = 123;
     private static final int CONFIRM_EXISTING_FOR_BIOMETRIC_WEAK_IMPROVE_REQUEST = 124;
     private static final int CONFIRM_EXISTING_FOR_BIOMETRIC_WEAK_LIVELINESS_OFF = 125;
+    private static final int CHANGE_TRUST_AGENT_SETTINGS = 126;
 
     // Misc Settings
     private static final String KEY_SIM_LOCK = "sim_lock";
@@ -86,6 +90,7 @@
     private static final String KEY_POWER_INSTANTLY_LOCKS = "power_button_instantly_locks";
     private static final String KEY_CREDENTIALS_MANAGER = "credentials_management";
     private static final String PACKAGE_MIME_TYPE = "application/vnd.android.package-archive";
+    private static final String KEY_TRUST_AGENT = "trust_agent";
 
     private DevicePolicyManager mDPM;
 
@@ -161,7 +166,7 @@
     /**
      * Important!
      *
-     * Dont forget to update the SecuritySearchIndexProvider if you are doing any change in the
+     * Don't forget to update the SecuritySearchIndexProvider if you are doing any change in the
      * logic or adding/removing preferences here.
      */
     private PreferenceScreen createPreferenceHierarchy() {
@@ -270,7 +275,7 @@
         }
 
         // Application install
-        PreferenceGroup deviceAdminCategory= (PreferenceGroup)
+        PreferenceGroup deviceAdminCategory = (PreferenceGroup)
                 root.findPreference(KEY_DEVICE_ADMIN_CATEGORY);
         mToggleAppInstallation = (CheckBoxPreference) findPreference(
                 KEY_TOGGLE_INSTALL_APPLICATIONS);
@@ -303,6 +308,36 @@
             protectByRestrictions(root.findPreference(KEY_CREDENTIALS_INSTALL));
         }
 
+        // Trust Agent preferences
+        PreferenceGroup securityCategory = (PreferenceGroup)
+                root.findPreference(KEY_SECURITY_CATEGORY);
+        if (securityCategory != null) {
+            PackageManager pm = getPackageManager();
+            List<ResolveInfo> resolveInfos = pm.queryIntentServices(TRUST_AGENT_INTENT,
+                    PackageManager.GET_META_DATA);
+            for (ResolveInfo resolveInfo : resolveInfos) {
+                if (resolveInfo.serviceInfo == null) continue;
+                TrustAgentUtils.TrustAgentComponentInfo trustAgentComponentInfo =
+                        TrustAgentUtils.getSettingsComponent(pm, resolveInfo);
+                if (trustAgentComponentInfo.componentName == null ||
+                        trustAgentComponentInfo.title == null ||
+                        trustAgentComponentInfo.title == "") continue;
+                Preference trustAgentPreference =
+                        new Preference(securityCategory.getContext());
+                trustAgentPreference.setKey(KEY_TRUST_AGENT);
+                trustAgentPreference.setTitle(trustAgentComponentInfo.title);
+                trustAgentPreference.setSummary(trustAgentComponentInfo.summary);
+                // Create intent for this preference.
+                Intent intent = new Intent();
+                intent.setComponent(trustAgentComponentInfo.componentName);
+                intent.setAction(Intent.ACTION_MAIN);
+                trustAgentPreference.setIntent(intent);
+                // Add preference to the settings menu.
+                securityCategory.addPreference(trustAgentPreference);
+                break; // Only render the first one.
+            }
+        }
+
         return root;
     }
 
@@ -522,6 +557,13 @@
         } else if (KEY_TOGGLE_VERIFY_APPLICATIONS.equals(key)) {
             Settings.Global.putInt(getContentResolver(), Settings.Global.PACKAGE_VERIFIER_ENABLE,
                     mToggleVerifyApps.isChecked() ? 1 : 0);
+        } else if (KEY_TRUST_AGENT.equals(key)) {
+            ChooseLockSettingsHelper helper =
+                    new ChooseLockSettingsHelper(this.getActivity(), this);
+            if (!helper.launchConfirmationActivity(CHANGE_TRUST_AGENT_SETTINGS, null, null)) {
+                // If this returns false, it means no password confirmation is required.
+                startActivity(preference.getIntent());
+            }
         } else {
             // If we didn't handle it, let preferences handle it.
             return super.onPreferenceTreeClick(preferenceScreen, preference);
@@ -552,6 +594,14 @@
             // is called by grabbing the value from lockPatternUtils.  We can't set it here
             // because mBiometricWeakLiveliness could be null
             return;
+        } else if (requestCode == CHANGE_TRUST_AGENT_SETTINGS && resultCode == Activity.RESULT_OK) {
+            Preference preference = getPreferenceScreen().findPreference(KEY_TRUST_AGENT);
+            if (preference != null) {
+                Intent intent = preference.getIntent();
+                if (intent != null) {
+                    startActivity(intent);
+                }
+            }
         }
         createPreferenceHierarchy();
     }
diff --git a/src/com/android/settings/TrustAgentUtils.java b/src/com/android/settings/TrustAgentUtils.java
new file mode 100644
index 0000000..64829a2
--- /dev/null
+++ b/src/com/android/settings/TrustAgentUtils.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.settings;
+
+import android.content.ComponentName;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.content.res.Resources;
+import android.content.res.TypedArray;
+import android.content.res.XmlResourceParser;
+import android.service.trust.TrustAgentService;
+import android.util.AttributeSet;
+import android.util.Slog;
+import android.util.Xml;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
+import java.io.IOException;
+
+public class TrustAgentUtils {
+    static final String TAG = "TrustAgentUtils";
+
+    private static final String TRUST_AGENT_META_DATA = TrustAgentService.TRUST_AGENT_META_DATA;
+
+    public static class TrustAgentComponentInfo {
+        ComponentName componentName;
+        String title;
+        String summary;
+    }
+
+    public static ComponentName getComponentName(ResolveInfo resolveInfo) {
+        if (resolveInfo == null || resolveInfo.serviceInfo == null) return null;
+        return new ComponentName(resolveInfo.serviceInfo.packageName, resolveInfo.serviceInfo.name);
+    }
+
+    public static TrustAgentComponentInfo getSettingsComponent(
+            PackageManager pm, ResolveInfo resolveInfo) {
+        if (resolveInfo == null || resolveInfo.serviceInfo == null
+                || resolveInfo.serviceInfo.metaData == null) return null;
+        String cn = null;
+        TrustAgentComponentInfo trustAgentComponentInfo = new TrustAgentComponentInfo();
+        XmlResourceParser parser = null;
+        Exception caughtException = null;
+        try {
+            parser = resolveInfo.serviceInfo.loadXmlMetaData(pm, TRUST_AGENT_META_DATA);
+            if (parser == null) {
+                Slog.w(TAG, "Can't find " + TRUST_AGENT_META_DATA + " meta-data");
+                return null;
+            }
+            Resources res = pm.getResourcesForApplication(resolveInfo.serviceInfo.applicationInfo);
+            AttributeSet attrs = Xml.asAttributeSet(parser);
+            int type;
+            while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
+                    && type != XmlPullParser.START_TAG) {
+            }
+            String nodeName = parser.getName();
+            if (!"trust-agent".equals(nodeName)) {
+                Slog.w(TAG, "Meta-data does not start with trust-agent tag");
+                return null;
+            }
+            TypedArray sa =
+                    res.obtainAttributes(attrs, com.android.internal.R.styleable.TrustAgent);
+            trustAgentComponentInfo.summary =
+                    sa.getString(com.android.internal.R.styleable.TrustAgent_summary);
+            trustAgentComponentInfo.title =
+                    sa.getString(com.android.internal.R.styleable.TrustAgent_title);
+            cn = sa.getString(com.android.internal.R.styleable.TrustAgent_settingsActivity);
+            sa.recycle();
+        } catch (PackageManager.NameNotFoundException e) {
+            caughtException = e;
+        } catch (IOException e) {
+            caughtException = e;
+        } catch (XmlPullParserException e) {
+            caughtException = e;
+        } finally {
+            if (parser != null) parser.close();
+        }
+        if (caughtException != null) {
+            Slog.w(TAG, "Error parsing : " + resolveInfo.serviceInfo.packageName, caughtException);
+            return null;
+        }
+        if (cn != null && cn.indexOf('/') < 0) {
+            cn = resolveInfo.serviceInfo.packageName + "/" + cn;
+        }
+        trustAgentComponentInfo.componentName = (cn == null) ? null : ComponentName.unflattenFromString(cn);
+        return trustAgentComponentInfo;
+    }
+}
diff --git a/src/com/android/settings/search/Index.java b/src/com/android/settings/search/Index.java
index adddb39..b1d21af 100644
--- a/src/com/android/settings/search/Index.java
+++ b/src/com/android/settings/search/Index.java
@@ -45,6 +45,7 @@
 
 import java.io.IOException;
 import java.lang.reflect.Field;
+import java.text.Normalizer;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Date;
@@ -54,6 +55,7 @@
 import java.util.Map;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.regex.Pattern;
 
 import static android.provider.SearchIndexablesContract.COLUMN_INDEX_NON_INDEXABLE_KEYS_KEY_VALUE;
 import static android.provider.SearchIndexablesContract.COLUMN_INDEX_RAW_RANK;
@@ -150,8 +152,11 @@
 
     private static final List<String> EMPTY_LIST = Collections.<String>emptyList();
 
-
     private static Index sInstance;
+
+    private static final Pattern REMOVE_DIACRITICALS_PATTERN
+            = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
+
     private final AtomicBoolean mIsAvailable = new AtomicBoolean(false);
     private final UpdateData mDataToProcess = new UpdateData();
     private Context mContext;
@@ -914,31 +919,13 @@
             String intentAction, String intentTargetPackage, String intentTargetClass,
             boolean enabled, String key) {
 
-        String updatedTitle;
-        if (title != null) {
-            updatedTitle = title.replaceAll(NON_BREAKING_HYPHEN, HYPHEN);
-        }
-        else {
-            updatedTitle = EMPTY;
-        }
+        final String updatedTitle = normalizeHyphen(title);
+        final String updatedSummaryOn = normalizeHyphen(summaryOn);
+        final String updatedSummaryOff = normalizeHyphen(summaryOff);
 
-        String updatedSummaryOn;
-        if (summaryOn != null) {
-            updatedSummaryOn = summaryOn.replaceAll(NON_BREAKING_HYPHEN, HYPHEN);
-        } else {
-            updatedSummaryOn = EMPTY;
-        }
-
-        String updatedSummaryOff;
-        if (summaryOff != null) {
-            updatedSummaryOff = summaryOff.replaceAll(NON_BREAKING_HYPHEN, HYPHEN);
-        } else {
-            updatedSummaryOff = EMPTY;
-        }
-
-        String normalizedTitle = updatedTitle.replaceAll(HYPHEN, EMPTY);
-        String normalizedSummaryOn = updatedSummaryOn.replaceAll(HYPHEN, EMPTY);
-        String normalizedSummaryOff = updatedSummaryOff.replaceAll(HYPHEN, EMPTY);
+        final String normalizedTitle = normalizeString(updatedTitle);
+        final String normalizedSummaryOn = normalizeString(updatedSummaryOn);
+        final String normalizedSummaryOff = normalizeString(updatedSummaryOff);
 
         updateOneRow(database, locale,
                 updatedTitle, normalizedTitle, updatedSummaryOn, normalizedSummaryOn,
@@ -947,6 +934,17 @@
                 rank, keywords, intentAction, intentTargetPackage, intentTargetClass, enabled, key);
     }
 
+    private static String normalizeHyphen(String input) {
+        return (input != null) ? input.replaceAll(NON_BREAKING_HYPHEN, HYPHEN) : EMPTY;
+    }
+
+    private static String normalizeString(String input) {
+        final String nohyphen = (input != null) ? input.replaceAll(HYPHEN, EMPTY) : EMPTY;
+        final String normalized = Normalizer.normalize(nohyphen, Normalizer.Form.NFD);
+
+        return REMOVE_DIACRITICALS_PATTERN.matcher(normalized).replaceAll("").toLowerCase();
+    }
+
     private void updateOneRow(SQLiteDatabase database, String locale,
             String updatedTitle, String normalizedTitle,
             String updatedSummaryOn, String normalizedSummaryOn,
diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java
index 7b90406..2d6388f 100644
--- a/src/com/android/settings/search/SearchIndexableResources.java
+++ b/src/com/android/settings/search/SearchIndexableResources.java
@@ -18,6 +18,7 @@
 
 import android.provider.SearchIndexableResource;
 
+import com.android.settings.ChooseLockGeneric;
 import com.android.settings.DataUsageSummary;
 import com.android.settings.DateTimeSettings;
 import com.android.settings.DevelopmentSettings;
@@ -179,6 +180,12 @@
                         SecuritySettings.class.getName(),
                         R.drawable.ic_settings_security));
 
+        sResMap.put(ChooseLockGeneric.ChooseLockGenericFragment.class.getName(),
+                new SearchIndexableResource(RANK_SECURITY,
+                        R.xml.security_settings_picker,
+                        ChooseLockGeneric.ChooseLockGenericFragment.class.getName(),
+                        R.drawable.ic_settings_security));
+
         sResMap.put(InputMethodAndLanguageSettings.class.getName(),
                 new SearchIndexableResource(RANK_IME,
                         NO_DATA_RES_ID,
diff --git a/src/com/android/settings/tts/TextToSpeechSettings.java b/src/com/android/settings/tts/TextToSpeechSettings.java
index 1d4fe71..4a98661 100644
--- a/src/com/android/settings/tts/TextToSpeechSettings.java
+++ b/src/com/android/settings/tts/TextToSpeechSettings.java
@@ -28,6 +28,7 @@
 import android.content.ActivityNotFoundException;
 import android.content.ContentResolver;
 import android.content.Intent;
+import android.os.AsyncTask;
 import android.os.Bundle;
 import android.preference.ListPreference;
 import android.preference.Preference;
@@ -164,6 +165,9 @@
 
         setTtsUtteranceProgressListener();
         initSettings();
+
+        // Prevent restarting the TTS connection on rotation
+        setRetainInstance(true);
     }
 
     @Override
diff --git a/src/com/android/settings/wifi/AccessPoint.java b/src/com/android/settings/wifi/AccessPoint.java
index 688fc63..4ac9112 100644
--- a/src/com/android/settings/wifi/AccessPoint.java
+++ b/src/com/android/settings/wifi/AccessPoint.java
@@ -28,9 +28,13 @@
 import android.os.Bundle;
 import android.preference.Preference;
 import android.util.Log;
+import android.util.LruCache;
 import android.view.View;
 import android.widget.ImageView;
 
+import java.util.Map;
+
+
 class AccessPoint extends Preference {
     static final String TAG = "Settings.AccessPoint";
 
@@ -74,6 +78,21 @@
     private WifiInfo mInfo;
     private DetailedState mState;
 
+    private static final int VISIBILITY_MAX_AGE_IN_MILLI = 1000000;
+    private static final int VISIBILITY_OUTDATED_AGE_IN_MILLI = 20000;
+    private static final int LOWER_FREQ_24GHZ = 2400;
+    private static final int HIGHER_FREQ_24GHZ = 2500;
+    private static final int LOWER_FREQ_5GHZ = 4900;
+    private static final int HIGHER_FREQ_5GHZ = 5900;
+    private static final int SECOND_TO_MILLI = 1000;
+
+    /** Experiemental: we should be able to show the user the list of BSSIDs and bands
+     *  for that SSID.
+     *  For now this data is used only with Verbose Logging so as to show the band and number
+     *  of BSSIDs on which that network is seen.
+     */
+    public LruCache<String, ScanResult> scanResultCache;
+
     static int getSecurity(WifiConfiguration config) {
         if (config.allowedKeyManagement.get(KeyMgmt.WPA_PSK)) {
             return SECURITY_PSK;
@@ -201,6 +220,9 @@
             pskType = getPskType(result);
         mRssi = result.level;
         mScanResult = result;
+        if (result.seen > mSeen) {
+            mSeen = result.seen;
+        }
     }
 
     @Override
@@ -267,6 +289,13 @@
         if (result.seen > mSeen) {
             mSeen = result.seen;
         }
+        if (WifiSettings.mVerboseLogging > 0) {
+            if (scanResultCache == null) {
+                scanResultCache = new LruCache<String, ScanResult>(32);
+            }
+            scanResultCache.put(result.BSSID, result);
+        }
+
         if (ssid.equals(result.SSID) && security == getSecurity(result)) {
             if (WifiManager.compareSignalLevel(result.level, mRssi) > 0) {
                 int oldLevel = getLevel();
@@ -340,25 +369,84 @@
 
     /** visibility status of the WifiConfiguration
      * @return RSSI and update indicator
-     * TODO: indicate both 2.4 and 5GHz RSSI as well as number of results
+     * TODO: use a string formatter
      * ["rssi 5Ghz", "num results on 5GHz" / "rssi 5Ghz", "num results on 5GHz"]
      * For instance [-40,5/-30,2]
      */
     private String getVisibilityStatus() {
-        String visibility ;
+        StringBuilder visibility = new StringBuilder();
+
         long now = System.currentTimeMillis();
         long age = (now - mSeen);
-        if (age < 1000000) {
+        if (age < VISIBILITY_MAX_AGE_IN_MILLI) {
             //show age in seconds, in the form xx
-            visibility = Long.toString((age / 1000) % 1000);
+            visibility.append(Long.toString((age / SECOND_TO_MILLI) % SECOND_TO_MILLI));
         } else {
             //not seen for more than 1000 seconds
-            visibility = "!";
+            visibility.append("!");
         }
-        if (mRssi != Integer.MAX_VALUE) {
-            visibility = visibility + ", " + Integer.toString(mRssi);
+
+        if (scanResultCache != null) {
+            int rssi5 = WifiConfiguration.INVALID_RSSI;
+            int rssi24 = WifiConfiguration.INVALID_RSSI;
+            int num5 = 0;
+            int num24 = 0;
+            Map<String, ScanResult> list = scanResultCache.snapshot();
+            for (ScanResult result : list.values()) {
+                if (result.seen == 0)
+                    continue;
+
+                if (result.frequency > LOWER_FREQ_5GHZ
+                        && result.frequency < HIGHER_FREQ_5GHZ) {
+                    //strictly speaking: [4915, 5825]
+                    //number of known BSSID on 5GHz band
+                    num5 = num5 + 1;
+                } else if (result.frequency > LOWER_FREQ_24GHZ
+                        && result.frequency < HIGHER_FREQ_24GHZ) {
+                    //strictly speaking: [2412, 2482]
+                    //number of known BSSID on 2.4Ghz band
+                    num24 = num24 + 1;
+                }
+
+                //ignore results seen, older than 20 seconds
+                if (now - result.seen > VISIBILITY_OUTDATED_AGE_IN_MILLI) continue;
+
+                if (result.frequency > LOWER_FREQ_5GHZ
+                        &&result.frequency < HIGHER_FREQ_5GHZ) {
+                    if (result.level > rssi5) {
+                        rssi5 = result.level;
+                    }
+                } else if (result.frequency > LOWER_FREQ_24GHZ
+                        && result.frequency < HIGHER_FREQ_24GHZ) {
+                    if (result.level > rssi24) {
+                        rssi24 = result.level;
+                    }
+                }
+            }
+            visibility.append(" [");
+            if (num24 > 0 || rssi24 > WifiConfiguration.INVALID_RSSI) {
+                visibility.append(Integer.toString(rssi24));
+                visibility.append(",");
+                visibility.append(Integer.toString(num24));
+            }
+            visibility.append(";");
+            if (num5 > 0 || rssi5 > WifiConfiguration.INVALID_RSSI) {
+                visibility.append(Integer.toString(rssi5));
+                visibility.append(",");
+                visibility.append(Integer.toString(num5));
+            }
+            visibility.append("]");
+        } else {
+            if (mRssi != Integer.MAX_VALUE) {
+                visibility.append(", ");
+                visibility.append(Integer.toString(mRssi));
+                if (mScanResult != null) {
+                    visibility.append(", ");
+                    visibility.append(Integer.toString(mScanResult.frequency));
+                }
+            }
         }
-        return visibility;
+        return visibility.toString();
     }
 
     /** Updates the title and summary; may indirectly call notifyChanged()  */
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index 7ccfc6b..8779798 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -29,6 +29,7 @@
 import android.net.NetworkUtils;
 import android.net.ProxyInfo;
 import android.net.RouteInfo;
+import android.net.Uri;
 import android.net.wifi.WifiConfiguration;
 import android.net.wifi.WifiConfiguration.AuthAlgorithm;
 import android.net.wifi.WifiConfiguration.KeyMgmt;
@@ -105,6 +106,7 @@
     /* These values come from "wifi_proxy_settings" resource array */
     public static final int PROXY_NONE = 0;
     public static final int PROXY_STATIC = 1;
+    public static final int PROXY_PAC = 2;
 
     /* These values come from "wifi_eap_method" resource array */
     public static final int WIFI_EAP_METHOD_PEAP = 0;
@@ -130,6 +132,7 @@
     private TextView mProxyHostView;
     private TextView mProxyPortView;
     private TextView mProxyExclusionListView;
+    private TextView mProxyPacView;
 
     private IpAssignment mIpAssignment = IpAssignment.UNASSIGNED;
     private ProxySettings mProxySettings = ProxySettings.UNASSIGNED;
@@ -257,11 +260,7 @@
                     mProxySettingsSpinner.setSelection(PROXY_STATIC);
                     showAdvancedFields = true;
                 } else if (config.getProxySettings() == ProxySettings.PAC) {
-                    mProxySettingsSpinner.setVisibility(View.GONE);
-                    TextView textView = (TextView)mView.findViewById(R.id.proxy_pac_info);
-                    textView.setVisibility(View.VISIBLE);
-                    textView.setText(context.getString(R.string.proxy_url) +
-                            config.getLinkProperties().getHttpProxy().getPacFileUrl());
+                    mProxySettingsSpinner.setSelection(PROXY_PAC);
                     showAdvancedFields = true;
                 } else {
                     mProxySettingsSpinner.setSelection(PROXY_NONE);
@@ -466,11 +465,10 @@
             }
         }
 
-        mProxySettings = (mProxySettingsSpinner != null &&
-                mProxySettingsSpinner.getSelectedItemPosition() == PROXY_STATIC) ?
-                ProxySettings.STATIC : ProxySettings.NONE;
-
-        if (mProxySettings == ProxySettings.STATIC && mProxyHostView != null) {
+        final int selectedPosition = mProxySettingsSpinner.getSelectedItemPosition();
+        mProxySettings = ProxySettings.NONE;
+        if (selectedPosition == PROXY_STATIC && mProxyHostView != null) {
+            mProxySettings = ProxySettings.STATIC;
             String host = mProxyHostView.getText().toString();
             String portStr = mProxyPortView.getText().toString();
             String exclusionList = mProxyExclusionListView.getText().toString();
@@ -488,6 +486,18 @@
             } else {
                 return false;
             }
+        } else if (selectedPosition == PROXY_PAC && mProxyPacView != null) {
+            mProxySettings = ProxySettings.PAC;
+            CharSequence uriSequence = mProxyPacView.getText();
+            if (TextUtils.isEmpty(uriSequence)) {
+                return false;
+            }
+            Uri uri = Uri.parse(uriSequence.toString());
+            if (uri == null) {
+                return false;
+            }
+            ProxyInfo proxyInfo = new ProxyInfo(uri);
+            mLinkProperties.setHttpProxy(proxyInfo);
         }
         return true;
     }
@@ -811,8 +821,9 @@
         }
 
         if (mProxySettingsSpinner.getSelectedItemPosition() == PROXY_STATIC) {
-            mView.findViewById(R.id.proxy_warning_limited_support).setVisibility(View.VISIBLE);
-            mView.findViewById(R.id.proxy_fields).setVisibility(View.VISIBLE);
+            setVisibility(R.id.proxy_warning_limited_support, View.VISIBLE);
+            setVisibility(R.id.proxy_fields, View.VISIBLE);
+            setVisibility(R.id.proxy_pac_field, View.GONE);
             if (mProxyHostView == null) {
                 mProxyHostView = (TextView) mView.findViewById(R.id.proxy_hostname);
                 mProxyHostView.addTextChangedListener(this);
@@ -829,13 +840,34 @@
                     mProxyExclusionListView.setText(proxyProperties.getExclusionListAsString());
                 }
             }
+        } else if (mProxySettingsSpinner.getSelectedItemPosition() == PROXY_PAC) {
+            setVisibility(R.id.proxy_warning_limited_support, View.GONE);
+            setVisibility(R.id.proxy_fields, View.GONE);
+            setVisibility(R.id.proxy_pac_field, View.VISIBLE);
+
+            if (mProxyPacView == null) {
+                mProxyPacView = (TextView) mView.findViewById(R.id.proxy_pac);
+                mProxyPacView.addTextChangedListener(this);
+            }
+            if (config != null) {
+                ProxyInfo proxyInfo = config.getLinkProperties().getHttpProxy();
+                if (proxyInfo != null) {
+                    mProxyPacView.setText(proxyInfo.getPacFileUrl().toString());
+                }
+            }
         } else {
-            mView.findViewById(R.id.proxy_warning_limited_support).setVisibility(View.GONE);
-            mView.findViewById(R.id.proxy_fields).setVisibility(View.GONE);
+            setVisibility(R.id.proxy_warning_limited_support, View.GONE);
+            setVisibility(R.id.proxy_fields, View.GONE);
+            setVisibility(R.id.proxy_pac_field, View.GONE);
         }
     }
 
-
+    private void setVisibility(int id, int visibility) {
+        final View v = mView.findViewById(id);
+        if (v != null) {
+            v.setVisibility(visibility);
+        }
+    }
 
     private void loadCertificates(Spinner spinner, String prefix) {
         final Context context = mConfigUi.getContext();
diff --git a/src/com/android/settings/wifi/WifiEnabler.java b/src/com/android/settings/wifi/WifiEnabler.java
index 9f0b6fa..d190045 100644
--- a/src/com/android/settings/wifi/WifiEnabler.java
+++ b/src/com/android/settings/wifi/WifiEnabler.java
@@ -27,6 +27,7 @@
 import android.os.Handler;
 import android.os.Message;
 import android.provider.Settings;
+import android.view.View;
 import android.widget.CompoundButton;
 import android.widget.Switch;
 import android.widget.Toast;
@@ -88,6 +89,11 @@
         mContext = context;
         mSwitchBar = switchBar;
         mSwitch = switchBar.getSwitch();
+        // This is a trick: as the Wi-Fi initial state is asynchronously coming from the
+        // BroadcastReceiver we cannot have the Switch visible at first otherwise you will notice
+        // its state change later on. So start it as VIEW.GONE and make it View.VISIBLE later
+        // when its state is defined.
+        mSwitch.setVisibility(View.GONE);
 
         mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
         mIntentFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
@@ -133,6 +139,7 @@
                 mSwitch.setEnabled(true);
                 updateSearchIndex(false);
         }
+        mSwitch.setVisibility(View.VISIBLE);
     }
 
     private void updateSearchIndex(boolean isWiFiOn) {
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 604275a..a653910 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -178,6 +178,10 @@
 
     private SwitchBar mSwitchBar;
 
+    /** verbose logging flag. this flag is set thru developer debugging options
+     * and used so as to assist with in-the-field WiFi connectivity debugging  */
+    public static int mVerboseLogging = 0;
+
     /* End of "used in Wifi Setup context" */
 
     public WifiSettings() {
@@ -712,8 +716,6 @@
         return super.onCreateDialog(dialogId);
     }
 
-    /** verbose logging flag is set only thru developer debugging options */
-    public static int mVerboseLogging = 0;
     /**
      * Shows the latest access points available with supplimental information like
      * the strength of network and the security for it.
@@ -728,7 +730,7 @@
         }
         final int wifiState = mWifiManager.getWifiState();
 
-        //check if verbose logging has been turned on or off
+        //when we update the screen, check if verbose logging has been turned on or off
         mVerboseLogging = mWifiManager.getVerboseLoggingLevel();
 
         switch (wifiState) {