Merge "Show managed profile under accounts rather than users" into lmp-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 0f7e381..2d2f9b4 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -138,6 +138,17 @@
                 android:value="true" />
         </activity>
 
+        <activity android:name="AirplaneModeVoiceActivity"
+                android:label="@string/wireless_networks_settings_title"
+                android:theme="@android:style/Theme.Material.Light.Voice"
+                android:exported="true"
+                android:taskAffinity="">
+            <intent-filter>
+                <action android:name="android.settings.VOICE_CONTROL_AIRPLANE_MODE" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <category android:name="android.intent.category.VOICE" />
+            </intent-filter>
+        </activity>
 
         <!-- Top-level settings -->
 
@@ -1508,7 +1519,7 @@
             </intent-filter>
         </activity>
 
-        <activity android:name="UsageStats" android:label="@string/usage_stats_label"
+        <activity android:name="UsageStatsActivity" android:label="@string/usage_stats_label"
                   android:taskAffinity="com.android.settings"
                   android:parentActivityName="Settings">
             <intent-filter>
diff --git a/res/layout/wifi_assistant_card.xml b/res/layout/wifi_assistant_card.xml
index a1917ba..529f9e9 100644
--- a/res/layout/wifi_assistant_card.xml
+++ b/res/layout/wifi_assistant_card.xml
@@ -21,7 +21,10 @@
     android:layout_height="wrap_content"
     android:gravity="center_vertical"
     android:orientation="vertical"
-    android:padding="@dimen/wifi_assistant_padding">
+    android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+    android:paddingTop="@dimen/wifi_assistant_padding"
+    android:paddingBottom="@dimen/wifi_assistant_padding">
 
     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="fill_parent"
diff --git a/res/values/bools.xml b/res/values/bools.xml
index 137d4ce..0fdc396 100644
--- a/res/values/bools.xml
+++ b/res/values/bools.xml
@@ -19,9 +19,9 @@
     <bool name="has_dock_settings">false</bool>
     <!-- Whether there is a silent mode checkbox  -->
     <bool name="has_silent_mode">true</bool>
-    <!-- Whether the power control widget is enabled for this device. Should be overridden for 
-         specific product builds. -->
-    <bool name="has_powercontrol_widget">true</bool>
+    <!-- Whether the DEPRECATED power control widget is enabled for this
+         device. Should be overridden for specific product builds. -->
+    <bool name="has_powercontrol_widget">false</bool>
 
     <!-- Display additional System Update menu if true -->
     <bool name="config_additional_system_update_setting_enable">false</bool>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d745cb2..d921d46 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -264,9 +264,7 @@
     <!-- Bluetooth settings screen, menu item to scan for nearby bluetooth devices -->
     <string name="bluetooth_scan_for_devices">Scan for devices</string>
     <!-- Bluetooth settings screen, menu item to change this device's Bluetooth name. [CHAR LIMIT=30] -->
-    <string name="bluetooth_rename_device" product="tablet">Rename tablet</string>
-    <!-- Bluetooth settings screen, menu item to change this device's Bluetooth name. [CHAR LIMIT=30] -->
-    <string name="bluetooth_rename_device" product="default">Rename phone</string>
+    <string name="bluetooth_rename_device">Rename this device</string>
     <!-- Bluetooth settings screen, confirmation button for rename device dialog. [CHAR LIMIT=20] -->
     <string name="bluetooth_rename_button">Rename</string>
     <!-- Bluetooth settings.  Dialog title to confirm disconnecting from all profiles of a device. [CHAR LIMIT=30] -->
@@ -899,6 +897,27 @@
       to restore any data that was backed up to your Google Account.
     </string>
 
+    <!-- Title of the encryption screen when decrypting the device failed -->
+    <string name="crypt_keeper_data_corrupt_title">Decryption unsuccessful</string>
+
+    <!-- Informational text when encryption fails -->
+    <string name="crypt_keeper_data_corrupt_summary" product="tablet">
+      The password you entered is correct, but unfortunately your data is
+      corrupt.
+      \n\nTo resume using your tablet, you need to perform a factory reset.
+      When you set up your tablet after the reset, you\'ll have an opportunity
+      to restore any data that was backed up to your Google Account.
+    </string>
+
+    <!-- Informational text when encryption fails -->
+    <string name="crypt_keeper_data_corrupt_summary" product="default">
+      The password you entered is correct, but unfortunately your data is
+      corrupt.
+      \n\nTo resume using your phone, you need to perform a factory reset.
+      When you set up your phone after the reset, you\'ll have an opportunity
+      to restore any data that was backed up to your Google Account.
+    </string>
+
     <!-- Image button description to switch input method -->
     <string name="crypt_keeper_switch_input_method">Switch input method</string>
 
diff --git a/src/com/android/settings/AirplaneModeVoiceActivity.java b/src/com/android/settings/AirplaneModeVoiceActivity.java
new file mode 100644
index 0000000..3ab0c37
--- /dev/null
+++ b/src/com/android/settings/AirplaneModeVoiceActivity.java
@@ -0,0 +1,40 @@
+/*
+ * 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.Intent;
+import android.provider.Settings;
+import android.util.Log;
+
+/**
+ * Activity for modifying the {@link Settings.Global#AIRPLANE_MODE_ON AIRPLANE_MODE_ON}
+ * setting using the Voice Interaction API.
+ */
+public class AirplaneModeVoiceActivity extends VoiceSettingsActivity {
+    private static final String TAG = "AirplaneModeVoiceActivity";
+
+    protected void onVoiceSettingInteraction(Intent intent) {
+        if (intent.hasExtra(Settings.EXTRA_AIRPLANE_MODE_ENABLED)) {
+            boolean enabled =
+                    intent.getBooleanExtra(Settings.EXTRA_AIRPLANE_MODE_ENABLED, false);
+            Settings.Global.putInt(getContentResolver(),
+                    Settings.Global.AIRPLANE_MODE_ON, enabled ? 1 : 0);
+        } else {
+            Log.v(TAG, "Missing airplane mode extra");
+        }
+    }
+}
diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java
index ec52128..009c758 100644
--- a/src/com/android/settings/DataUsageSummary.java
+++ b/src/com/android/settings/DataUsageSummary.java
@@ -1791,10 +1791,12 @@
         public static void show(DataUsageSummary parent) {
             if (!parent.isAdded()) return;
 
+            final NetworkPolicy policy = parent.mPolicyEditor.getPolicy(parent.mTemplate);
+            if (policy == null) return;
+
             final Resources res = parent.getResources();
             final CharSequence message;
-            final long minLimitBytes = (long) (
-                    parent.mPolicyEditor.getPolicy(parent.mTemplate).warningBytes * 1.2f);
+            final long minLimitBytes = (long) (policy.warningBytes * 1.2f);
             final long limitBytes;
 
             // TODO: customize default limits based on network template
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index bb5ac00..bf0d9a1 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -1042,7 +1042,7 @@
                             }
 
                             // Show the SIM Cards setting if there are more than 2 SIMs installed.
-                            if(tile.id != R.id.sim_settings || SimSettings.showSimCardScreen(this)){
+                            if(tile.id != R.id.sim_settings || Utils.showSimCardTile(this)){
                                 category.addTile(tile);
                             }
 
diff --git a/src/com/android/settings/UsageStats.java b/src/com/android/settings/UsageStatsActivity.java
similarity index 83%
rename from src/com/android/settings/UsageStats.java
rename to src/com/android/settings/UsageStatsActivity.java
index 08c272e..90aec5b 100755
--- a/src/com/android/settings/UsageStats.java
+++ b/src/com/android/settings/UsageStatsActivity.java
@@ -17,7 +17,7 @@
 package com.android.settings;
 
 import android.app.Activity;
-import android.app.usage.PackageUsageStats;
+import android.app.usage.UsageStats;
 import android.app.usage.UsageStatsManager;
 import android.content.Context;
 import android.content.pm.ApplicationInfo;
@@ -30,6 +30,7 @@
 import java.util.Calendar;
 import java.util.Collections;
 import java.util.Comparator;
+import java.util.List;
 import java.util.Map;
 
 import android.text.format.DateUtils;
@@ -48,15 +49,15 @@
 /**
  * Activity to display package usage statistics.
  */
-public class UsageStats extends Activity implements OnItemSelectedListener {
+public class UsageStatsActivity extends Activity implements OnItemSelectedListener {
     private static final String TAG = "UsageStatsActivity";
     private static final boolean localLOGV = false;
     private UsageStatsManager mUsageStatsManager;
     private LayoutInflater mInflater;
     private UsageStatsAdapter mAdapter;
     private PackageManager mPm;
-    
-    public static class AppNameComparator implements Comparator<PackageUsageStats> {
+
+    public static class AppNameComparator implements Comparator<UsageStats> {
         private Map<String, String> mAppLabelList;
 
         AppNameComparator(Map<String, String> appList) {
@@ -64,76 +65,87 @@
         }
 
         @Override
-        public final int compare(PackageUsageStats a, PackageUsageStats b) {
+        public final int compare(UsageStats a, UsageStats b) {
             String alabel = mAppLabelList.get(a.getPackageName());
             String blabel = mAppLabelList.get(b.getPackageName());
             return alabel.compareTo(blabel);
         }
     }
 
-    public static class LastTimeUsedComparator implements Comparator<PackageUsageStats> {
+    public static class LastTimeUsedComparator implements Comparator<UsageStats> {
         @Override
-        public final int compare(PackageUsageStats a, PackageUsageStats b) {
+        public final int compare(UsageStats a, UsageStats b) {
             // return by descending order
             return (int)(b.getLastTimeUsed() - a.getLastTimeUsed());
         }
     }
-    
-    public static class UsageTimeComparator implements Comparator<PackageUsageStats> {
+
+    public static class UsageTimeComparator implements Comparator<UsageStats> {
         @Override
-        public final int compare(PackageUsageStats a, PackageUsageStats b) {
-            return (int)(b.getTotalTimeSpent() - a.getTotalTimeSpent());
+        public final int compare(UsageStats a, UsageStats b) {
+            return (int)(b.getTotalTimeInForeground() - a.getTotalTimeInForeground());
         }
     }
-    
+
     // View Holder used when displaying views
     static class AppViewHolder {
         TextView pkgName;
         TextView lastTimeUsed;
         TextView usageTime;
     }
-    
+
     class UsageStatsAdapter extends BaseAdapter {
          // Constants defining order for display order
         private static final int _DISPLAY_ORDER_USAGE_TIME = 0;
         private static final int _DISPLAY_ORDER_LAST_TIME_USED = 1;
         private static final int _DISPLAY_ORDER_APP_NAME = 2;
-        
+
         private int mDisplayOrder = _DISPLAY_ORDER_USAGE_TIME;
         private LastTimeUsedComparator mLastTimeUsedComparator = new LastTimeUsedComparator();
         private UsageTimeComparator mUsageTimeComparator = new UsageTimeComparator();
         private AppNameComparator mAppLabelComparator;
         private final ArrayMap<String, String> mAppLabelMap = new ArrayMap<>();
-        private final ArrayList<PackageUsageStats> mPackageStats = new ArrayList<>();
+        private final ArrayList<UsageStats> mPackageStats = new ArrayList<>();
 
         UsageStatsAdapter() {
             Calendar cal = Calendar.getInstance();
             cal.add(Calendar.DAY_OF_YEAR, -5);
 
-            final android.app.usage.UsageStats stats =
-                    mUsageStatsManager.getRecentStatsSince(cal.getTimeInMillis());
+            final List<UsageStats> stats =
+                    mUsageStatsManager.queryUsageStats(UsageStatsManager.INTERVAL_BEST,
+                            cal.getTimeInMillis(), System.currentTimeMillis());
             if (stats == null) {
                 return;
             }
 
-            final int pkgCount = stats.getPackageCount();
-            for (int i = 0; i < pkgCount; i++) {
-                final PackageUsageStats pkgStats = stats.getPackage(i);
+            ArrayMap<String, UsageStats> map = new ArrayMap<>();
+            final int statCount = stats.size();
+            for (int i = 0; i < statCount; i++) {
+                final android.app.usage.UsageStats pkgStats = stats.get(i);
 
                 // load application labels for each application
                 try {
                     ApplicationInfo appInfo = mPm.getApplicationInfo(pkgStats.getPackageName(), 0);
                     String label = appInfo.loadLabel(mPm).toString();
                     mAppLabelMap.put(pkgStats.getPackageName(), label);
-                    mPackageStats.add(pkgStats);
+
+                    UsageStats existingStats =
+                            map.get(pkgStats.getPackageName());
+                    if (existingStats == null) {
+                        map.put(pkgStats.getPackageName(), pkgStats);
+                    } else {
+                        existingStats.add(pkgStats);
+                    }
+
                 } catch (NameNotFoundException e) {
                     // This package may be gone.
                 }
-           }
+            }
+            mPackageStats.addAll(map.values());
 
-           // Sort list
-           mAppLabelComparator = new AppNameComparator(mAppLabelMap);
-           sortList();
+            // Sort list
+            mAppLabelComparator = new AppNameComparator(mAppLabelMap);
+            sortList();
         }
 
         @Override
@@ -177,20 +189,20 @@
             }
 
             // Bind the data efficiently with the holder
-            PackageUsageStats pkgStats = mPackageStats.get(position);
+            UsageStats pkgStats = mPackageStats.get(position);
             if (pkgStats != null) {
                 String label = mAppLabelMap.get(pkgStats.getPackageName());
                 holder.pkgName.setText(label);
                 holder.lastTimeUsed.setText(DateUtils.formatSameDayTime(pkgStats.getLastTimeUsed(),
                         System.currentTimeMillis(), DateFormat.MEDIUM, DateFormat.MEDIUM));
                 holder.usageTime.setText(
-                        DateUtils.formatElapsedTime(pkgStats.getTotalTimeSpent() / 1000));
+                        DateUtils.formatElapsedTime(pkgStats.getTotalTimeInForeground() / 1000));
             } else {
                 Log.w(TAG, "No usage stats info for package:" + position);
             }
             return convertView;
         }
-        
+
         void sortList(int sortOrder) {
             if (mDisplayOrder == sortOrder) {
                 // do nothing
@@ -226,7 +238,7 @@
 
         Spinner typeSpinner = (Spinner) findViewById(R.id.typeSpinner);
         typeSpinner.setOnItemSelectedListener(this);
-        
+
         ListView listView = (ListView) findViewById(R.id.pkg_list);
         mAdapter = new UsageStatsAdapter();
         listView.setAdapter(mAdapter);
@@ -242,4 +254,3 @@
         // do nothing
     }
 }
-
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 255ab58..e88c0fc 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -820,4 +820,16 @@
         if (icon == null) return null;
         return CircleFramedDrawable.getInstance(context, icon);
     }
+
+    /**
+     * Return whether or not the user should have a SIM Cards option in Settings.
+     * TODO: Change back to returning true if count is greater than one after testing.
+     * TODO: See bug 16533525.
+     */
+    public static boolean showSimCardTile(Context context) {
+        final TelephonyManager tm =
+                (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+
+        return tm.getSimCount() > 0;
+    }
 }
diff --git a/src/com/android/settings/VoiceSettingsActivity.java b/src/com/android/settings/VoiceSettingsActivity.java
new file mode 100644
index 0000000..b5e8ede
--- /dev/null
+++ b/src/com/android/settings/VoiceSettingsActivity.java
@@ -0,0 +1,51 @@
+/*
+ * 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.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+
+/**
+ * Activity for modifying a setting using the Voice Interaction API. This activity
+ * MUST only modify the setting if the intent was sent using
+ * {@link android.service.voice.VoiceInteractionSession#startVoiceActivity startVoiceActivity}.
+ */
+abstract public class VoiceSettingsActivity extends Activity {
+
+    private static final String TAG = "VoiceSettingsActivity";
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        if (isVoiceInteraction()) {
+            // Only permit if this is a voice interaction.
+            onVoiceSettingInteraction(getIntent());
+        } else {
+            Log.v(TAG, "Cannot modify settings without voice interaction");
+        }
+        finish();
+    }
+
+    /**
+     * Modify the setting as a voice interaction. The activity will finish
+     * after this method is called.
+     */
+    abstract protected void onVoiceSettingInteraction(Intent intent);
+}
diff --git a/src/com/android/settings/accounts/ManageAccountsSettings.java b/src/com/android/settings/accounts/ManageAccountsSettings.java
index b69bf3f..8787bced 100644
--- a/src/com/android/settings/accounts/ManageAccountsSettings.java
+++ b/src/com/android/settings/accounts/ManageAccountsSettings.java
@@ -97,6 +97,8 @@
     public void onStart() {
         super.onStart();
         mAuthenticatorHelper.listenToAccountUpdates();
+        updateAuthDescriptions();
+        showAccountsIfNeeded();
     }
 
     @Override
@@ -124,8 +126,6 @@
         if (args != null && args.containsKey(KEY_ACCOUNT_LABEL)) {
             getActivity().setTitle(args.getString(KEY_ACCOUNT_LABEL));
         }
-        updateAuthDescriptions();
-        showAccountsIfNeeded();
     }
 
     @Override
diff --git a/src/com/android/settings/applications/ManageApplications.java b/src/com/android/settings/applications/ManageApplications.java
index 1889634..ac5a78a 100644
--- a/src/com/android/settings/applications/ManageApplications.java
+++ b/src/com/android/settings/applications/ManageApplications.java
@@ -74,7 +74,6 @@
 import com.android.settings.UserSpinnerAdapter;
 import com.android.settings.Settings.RunningServicesActivity;
 import com.android.settings.Settings.StorageUseActivity;
-import com.android.settings.UserSpinnerAdapter.UserDetails;
 import com.android.settings.applications.ApplicationsState.AppEntry;
 import com.android.settings.deviceinfo.StorageMeasurement;
 import com.android.settings.Utils;
@@ -142,6 +141,7 @@
     static final String TAG = "ManageApplications";
     static final boolean DEBUG = false;
 
+    private static final String EXTRA_LIST_TYPE = "currentListType";
     private static final String EXTRA_SORT_ORDER = "sortOrder";
     private static final String EXTRA_SHOW_BACKGROUND = "showBackground";
     private static final String EXTRA_DEFAULT_LIST_TYPE = "defaultListType";
@@ -467,7 +467,8 @@
 
     // These are for keeping track of activity and spinner switch state.
     private boolean mActivityResumed;
-    
+
+    private static final int LIST_TYPE_MISSING = -1;
     static final int LIST_TYPE_DOWNLOADED = 0;
     static final int LIST_TYPE_RUNNING = 1;
     static final int LIST_TYPE_SDCARD = 2;
@@ -954,9 +955,13 @@
 
         if (savedInstanceState == null) {
             // First time init: make sure view pager is showing the correct tab.
-            for (int i = 0; i < mTabs.size(); i++) {
+            int extraCurrentListType = getActivity().getIntent().getIntExtra(EXTRA_LIST_TYPE,
+                    LIST_TYPE_MISSING);
+            int currentListType = (extraCurrentListType != LIST_TYPE_MISSING)
+                    ? extraCurrentListType : mDefaultListType;
+            for (int i = 0; i < mNumTabs; i++) {
                 TabInfo tab = mTabs.get(i);
-                if (tab.mListType == mDefaultListType) {
+                if (tab.mListType == currentListType) {
                     mViewPager.setCurrentItem(i);
                     break;
                 }
@@ -1036,6 +1041,8 @@
         if (selectedUser.getIdentifier() != UserHandle.myUserId()) {
             Intent intent = new Intent(Settings.ACTION_APPLICATION_SETTINGS);
             intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+            int currentTab = mViewPager.getCurrentItem();
+            intent.putExtra(EXTRA_LIST_TYPE, mTabs.get(currentTab).mListType);
             mContext.startActivityAsUser(intent, selectedUser);
             getActivity().finish();
         }
diff --git a/src/com/android/settings/bluetooth/BluetoothNameDialogFragment.java b/src/com/android/settings/bluetooth/BluetoothNameDialogFragment.java
index bf0356c..b80e42a 100644
--- a/src/com/android/settings/bluetooth/BluetoothNameDialogFragment.java
+++ b/src/com/android/settings/bluetooth/BluetoothNameDialogFragment.java
@@ -178,7 +178,6 @@
             mDeviceNameUpdated = true;
             mDeviceNameEdited = false;
             mDeviceNameView.setText(mLocalAdapter.getName());
-            getActivity().setTitle(mLocalAdapter.getName());
         }
     }
 
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index 7441c8c..4b278ac 100755
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -99,13 +99,14 @@
         public void onReceive(Context context, Intent intent) {
             String action = intent.getAction();
             if (action.equals(BluetoothAdapter.ACTION_LOCAL_NAME_CHANGED)) {
-                updateDeviceName();
+                updateDeviceName(context);
             }
         }
 
-        private void updateDeviceName() {
+        private void updateDeviceName(Context context) {
             if (mLocalAdapter.isEnabled() && mMyDevicePreference != null) {
-                mMyDevicePreference.setTitle(mLocalAdapter.getName());
+                mMyDevicePreference.setSummary(context.getResources().getString(
+                            R.string.bluetooth_is_visible_message, mLocalAdapter.getName()));
             }
         }
     };
diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java
index a3d2b8d..e0e09a8 100644
--- a/src/com/android/settings/search/SearchIndexableResources.java
+++ b/src/com/android/settings/search/SearchIndexableResources.java
@@ -92,7 +92,7 @@
         sResMap.put(SimSettings.class.getName(),
                 new SearchIndexableResource(
                         Ranking.getRankForClassName(SimSettings.class.getName()),
-                        R.xml.sim_settings,
+                        NO_DATA_RES_ID,
                         SimSettings.class.getName(),
                         R.drawable.ic_sim_sd));
 
diff --git a/src/com/android/settings/sim/SimSettings.java b/src/com/android/settings/sim/SimSettings.java
index 15c5548..9762c51 100644
--- a/src/com/android/settings/sim/SimSettings.java
+++ b/src/com/android/settings/sim/SimSettings.java
@@ -16,6 +16,7 @@
 
 package com.android.settings.sim;
 
+import android.provider.SearchIndexableResource;
 import com.android.settings.R;
 
 import android.app.AlertDialog;
@@ -55,6 +56,7 @@
 import com.android.internal.telephony.TelephonyIntents;
 import com.android.settings.RestrictedSettingsFragment;
 import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.Utils;
 import com.android.settings.notification.DropDownPreference;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settings.search.Indexable;
@@ -86,18 +88,6 @@
     private SubInfoRecord mCalls = null;
     private SubInfoRecord mSMS = null;
 
-    /**
-     * Return whether or not the user should have a SIM Cards option in Settings.
-     * TODO: Change back to returning true if count is greater than one after testing.
-     * TODO: See bug 16533525.
-     */
-    public static boolean showSimCardScreen(Context context) {
-        final TelephonyManager tm =
-            (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
-
-        return tm.getSimCount() > 0;
-    }
-
     public SimSettings() {
         super(DISALLOW_CONFIG_SIM);
     }
@@ -369,4 +359,26 @@
             builder.create().show();
         }
     }
+
+    /**
+     * For search
+     */
+    public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+            new BaseSearchIndexProvider() {
+                @Override
+                public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
+                        boolean enabled) {
+                    ArrayList<SearchIndexableResource> result =
+                            new ArrayList<SearchIndexableResource>();
+
+                    if (Utils.showSimCardTile(context)) {
+                        SearchIndexableResource sir = new SearchIndexableResource(context);
+                        sir.xmlResId = R.xml.sim_settings;
+                        result.add(sir);
+                    }
+
+                    return result;
+                }
+            };
+
 }
diff --git a/src/com/android/settings/wifi/AccessPoint.java b/src/com/android/settings/wifi/AccessPoint.java
index b3fafa4..0ec1f13 100644
--- a/src/com/android/settings/wifi/AccessPoint.java
+++ b/src/com/android/settings/wifi/AccessPoint.java
@@ -520,6 +520,10 @@
         final Context context = getContext();
         updateIcon(getLevel(), context);
 
+        // Force new summary
+        setSummary(null);
+
+        // Update to new summary
         StringBuilder summary = new StringBuilder();
 
         if (mState != null) { // This is the active connection
@@ -551,22 +555,18 @@
                 summary.append(context.getString(R.string.wifi_remembered));
             }
 
-            if (security != SECURITY_NONE) {
-                String securityStrFormat;
-                if (summary.length() == 0) {
-                    securityStrFormat = context.getString(R.string.wifi_secured_first_item);
-                } else {
-                    securityStrFormat = context.getString(R.string.wifi_secured_second_item);
-                }
-            }
+// TODO: Wi-Fi team needs to decide what to do with this code.
+//            if (security != SECURITY_NONE) {
+//                String securityStrFormat;
+//                if (summary.length() == 0) {
+//                    securityStrFormat = context.getString(R.string.wifi_secured_first_item);
+//                } else {
+//                    securityStrFormat = context.getString(R.string.wifi_secured_second_item);
+//                }
+//            }
 
         }
 
-        // This is a workaround, see bug report...
-        if (summary.length() < 1) {
-            summary.append("   ");
-        }
-
         if (WifiSettings.mVerboseLogging > 0) {
             //add RSSI/band information for this config, what was seen up to 6 seconds ago
             //verbose WiFi Logging is only turned on thru developers settings
@@ -591,7 +591,11 @@
             }
         }
 
-        setSummary(summary.toString());
+        if (summary.length() > 0) {
+            setSummary(summary.toString());
+        } else {
+            showSummary = false;
+        }
     }
 
     /**