Merge "Don't show owner as a secondary user."
diff --git a/res/drawable/no_search_results.xml b/res/drawable/no_search_results.xml
new file mode 100644
index 0000000..a75a443
--- /dev/null
+++ b/res/drawable/no_search_results.xml
@@ -0,0 +1,59 @@
+<!--
+  Copyright (C) 2017 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.
+
+  -->
+
+<vector android:height="24dp" android:viewportHeight="267.9"
+    android:viewportWidth="236.3" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+    <path android:fillAlpha="0.9" android:fillColor="#00000000"
+        android:pathData="M18,-19c0,-0.4 0,-0.5 -0.3,-0.3l-12,7c-0.3,0.2 -0.2,0.5 0.1,0.6l11.9,7C18,-4.5 18,-4.7 18,-5V-19z"
+        android:strokeColor="#FFFFFF" android:strokeWidth="2"/>
+    <path android:fillAlpha="0.9" android:fillColor="#00000000"
+        android:pathData="M18.9,-12c0,-3.8 -3.1,-6.9 -6.9,-6.9c-3.8,0 -6.9,3.1 -6.9,6.9c0,3.8 3.1,6.9 6.9,6.9C15.8,-5.1 18.9,-8.2 18.9,-12z"
+        android:strokeColor="#FFFFFF" android:strokeWidth="1.8033"/>
+    <path android:fillAlpha="0.9" android:fillColor="#00000000"
+        android:pathData="M19,-5.7C19,-5.4 18.6,-5 18.2,-5H5.8C5.4,-5 5,-5.4 5,-5.7v-12.6C5,-18.6 5.4,-19 5.8,-19h12.4c0.4,0 0.8,0.4 0.8,0.7V-5.7z"
+        android:strokeColor="#FFFFFF" android:strokeWidth="2"/>
+    <path android:fillColor="#FAFAFA" android:pathData="M118.2,134.4m-118.2,0a118.2,118.2 0,1 1,236.4 0a118.2,118.2 0,1 1,-236.4 0"/>
+    <path android:fillColor="#F5F5F5" android:pathData="M22.8,239L96,206.2c0.2,-0.1 0.3,-0.1 0.5,-0.1l117.3,23c0.7,0.2 0.9,1.2 0.2,1.5l-75.9,37.2c-0.2,0.1 -0.3,0.1 -0.5,0.1L23,240.5C22.2,240.3 22.1,239.3 22.8,239z"/>
+    <path android:fillColor="#E8E8E8" android:pathData="M35.6,76.5l102,17.3l0,167.4l-102,-23.2z"/>
+    <path android:fillColor="#E8E8E8" android:pathData="M35.7,19.6l102,17.3l0,79.2l-102,-23.2z"/>
+    <path android:fillColor="#EFEFEF" android:pathData="M35.7,19.6l66.6,-19.6l100.5,19.1l-65.1,18.5z"/>
+    <path android:fillColor="#00000000"
+        android:pathData="M37.6,131.9L135.2,150"
+        android:strokeColor="#E0E0E0" android:strokeWidth="0.1816"/>
+    <path android:fillAlpha="0.5" android:fillColor="#00000000"
+        android:pathData="M39.1,185.3L132.3,204.8"
+        android:strokeColor="#C1C1C1" android:strokeWidth="0.1816"/>
+    <path android:fillColor="#00000000"
+        android:pathData="M137.7,147.6L116.5,154.5"
+        android:strokeColor="#E0E0E0" android:strokeWidth="0.1816"/>
+    <path android:fillColor="#00000000" android:pathData="M35.7,142.2"
+        android:strokeColor="#E0E0E0" android:strokeWidth="0.1816"/>
+    <path android:fillAlpha="5.000000e-02" android:fillColor="#FF000000" android:pathData="M35.7,140.9l101.7,9.2l0,33.1l-101.8,-21.3z"/>
+    <path android:fillColor="#CECECE" android:pathData="M71,36.9l28.8,5l0,5.8l-28.8,-5.3z"/>
+    <path android:fillAlpha="0.1" android:fillColor="#1F1F1F" android:pathData="M71,36.9l28.8,5l0,1.7l-28.8,-5.3z"/>
+    <path android:fillAlpha="0.5" android:fillColor="#CECECE" android:pathData="M68.4,147.3l28.8,5.1l0,5.8l-28.8,-5.4z"/>
+    <path android:fillAlpha="0.1" android:fillColor="#1F1F1F" android:pathData="M68.4,147.3l28.8,5.1l0,1.7l-28.8,-5.4z"/>
+    <path android:fillAlpha="0.7" android:fillColor="#CECECE" android:pathData="M68.4,201.2l28.8,5.4l0,5.8l-28.8,-5.7z"/>
+    <path android:fillAlpha="0.1" android:fillColor="#1F1F1F" android:pathData="M68.4,201.2l28.8,5.4l0,1.6l-28.8,-5.6z"/>
+    <path android:fillColor="#EAEAEA" android:pathData="M16.2,80.3l100.3,18.1l0,58.5l-100.3,-20.2z"/>
+    <path android:fillColor="#EFEFEF" android:pathData="M137.7,37.6l0,53.9l-21.2,6.9l0,58.5l21.2,-6.9l0,111.1l65.1,-30l0,-212z"/>
+    <path android:fillColor="#E57373" android:pathData="M16.2,80.3l19.5,-8.2l0,11.7z"/>
+    <path android:fillAlpha="0.6" android:fillColor="#E57373" android:pathData="M137.7,91.5l-102,-19.4l0,11.7l80.8,14.6z"/>
+    <path android:fillColor="#CECECE" android:pathData="M47.2,95.5l28.8,5l0,5.8l-28.8,-5.2z"/>
+    <path android:fillAlpha="0.1" android:fillColor="#1F1F1F" android:pathData="M47.2,95.5l28.8,5l0,1.7l-28.8,-5.2z"/>
+    <path android:fillColor="#EAEAEA" android:pathData="M35.7,72.1L35.7,72.1l-19.6,8.1l0,0.1l0,0l100.3,18.1l0,0l0,0l21.6,-7L35.7,72.1zM116.5,97.5L19.4,80l16.4,-6.8L134,91.8L116.5,97.5z"/>
+</vector>
diff --git a/res/layout/admin_support_details_dialog.xml b/res/layout/admin_support_details_dialog.xml
index 51e31b9..c83add3 100644
--- a/res/layout/admin_support_details_dialog.xml
+++ b/res/layout/admin_support_details_dialog.xml
@@ -30,7 +30,7 @@
                 android:src="@drawable/ic_info"
                 android:scaleType="fitCenter"
                 android:contentDescription="@null" />
-        <TextView
+        <TextView android:id="@+id/admin_support_dialog_title"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:paddingStart="@dimen/admin_details_dialog_padding"
diff --git a/res/layout/preference_master_switch.xml b/res/layout/preference_master_switch.xml
index 9f46d76..c7dd6d6 100644
--- a/res/layout/preference_master_switch.xml
+++ b/res/layout/preference_master_switch.xml
@@ -21,7 +21,6 @@
     android:layout_height="wrap_content"
     android:minHeight="?android:attr/listPreferredItemHeight"
     android:gravity="center_vertical"
-    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
     android:background="@android:color/transparent"
     android:clipToPadding="false">
 
@@ -85,6 +84,7 @@
         android:layout_width="wrap_content"
         android:layout_height="match_parent"
         android:gravity="end|center_vertical"
-        android:orientation="vertical"/>
+        android:orientation="vertical"
+        android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"/>
 
 </LinearLayout>
diff --git a/res/layout/preference_widget_master_switch.xml b/res/layout/preference_widget_master_switch.xml
index bc1cafd..ee335f1 100644
--- a/res/layout/preference_widget_master_switch.xml
+++ b/res/layout/preference_widget_master_switch.xml
@@ -36,6 +36,7 @@
     <Switch android:id="@+id/switchWidget"
       android:layout_width="wrap_content"
       android:layout_height="match_parent"
-      android:gravity="center_vertical" />
+      android:gravity="center_vertical"
+      android:clickable="false"/>
 
 </LinearLayout>
diff --git a/res/layout/search_feedback.xml b/res/layout/search_feedback.xml
new file mode 100644
index 0000000..cdb0545
--- /dev/null
+++ b/res/layout/search_feedback.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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.
+-->
+
+<View
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/feedback_popup"
+    android:layout_width="0dp"
+    android:layout_height="0dp"
+    android:visibility="gone">
+</View>
diff --git a/res/layout/search_panel_2.xml b/res/layout/search_panel_2.xml
index 671c19c..8f72847 100644
--- a/res/layout/search_panel_2.xml
+++ b/res/layout/search_panel_2.xml
@@ -13,18 +13,19 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-              android:id="@+id/search_panel"
-              android:layout_width="match_parent"
-              android:layout_height="match_parent"
-              android:layout_gravity="center"
-              android:orientation="vertical">
+<RelativeLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/search_panel"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@drawable/search_panel_list_background">
 
     <LinearLayout android:id="@+id/layout_recent_searches"
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:layout_gravity="center"
-                  android:orientation="vertical">
+                  android:orientation="vertical"
+                  android:layout_alignParentTop="true">
 
         <!-- Padding is included in the background -->
         <android.support.v7.widget.RecyclerView android:id="@+id/list_recent_searches"
@@ -36,27 +37,47 @@
                   android:paddingBottom="@dimen/dashboard_padding_bottom"
                   android:scrollbarStyle="outsideOverlay"
                   android:headerDividersEnabled="false"
-                  android:background="@drawable/search_panel_list_background"
                   android:elevation="@dimen/search_panel_elevation"/>
     </LinearLayout>
 
     <LinearLayout android:id="@+id/layout_results"
                   android:layout_width="match_parent"
-                  android:layout_height="match_parent"
-                  android:layout_gravity="center"
+                  android:layout_height="fill_parent"
+                  android:layout_above="@id/feedback_popup"
                   android:orientation="vertical">
 
         <!-- Padding is included in the background -->
         <android.support.v7.widget.RecyclerView android:id="@+id/list_results"
                   android:layout_width="match_parent"
-                  android:layout_height="match_parent"
+                  android:layout_height="wrap_content"
                   android:paddingStart="@dimen/dashboard_padding_start"
                   android:paddingEnd="@dimen/dashboard_padding_end"
                   android:paddingTop="@dimen/dashboard_padding_top"
                   android:paddingBottom="@dimen/dashboard_padding_bottom"
                   android:scrollbarStyle="outsideOverlay"
-                  android:scrollbars="vertical"
-                  android:background="@drawable/search_panel_list_background"/>
+                  android:scrollbars="vertical"/>
+
+        <LinearLayout
+            android:id="@+id/no_results_layout"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:gravity="center"
+            android:orientation="vertical"
+            android:visibility="gone">
+
+            <ImageView
+            android:layout_height="112dp"
+            android:layout_width="112dp"
+            android:src="@drawable/no_search_results"/>
+
+            <TextView
+            android:layout_height="wrap_content"
+            android:layout_width="match_parent"
+            android:textSize="18sp"
+            android:text="@string/search_settings_no_results"
+            android:gravity="center"/>
+        </LinearLayout>
     </LinearLayout>
 
-</LinearLayout>
\ No newline at end of file
+    <include layout="@layout/search_feedback"/>
+</RelativeLayout>
diff --git a/res/values/config.xml b/res/values/config.xml
index f81bf9b..0fa2b71 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -67,36 +67,4 @@
     <!-- If the support features are enabled. -->
     <bool name="config_support_enabled">false</bool>
 
-    <!-- List containing the component names of pre-installed screen reader services. -->
-    <string-array name="config_preinstalled_screen_reader_services" translatable="false">
-        <!--
-        <item>com.example.package.first/com.example.class.FirstService</item>
-        <item>com.example.package.second/com.example.class.SecondService</item>
-        -->
-    </string-array>
-
-    <!-- List containing the component names of pre-installed audio and captioning services. -->
-    <string-array name="config_preinstalled_audio_and_caption_services" translatable="false">
-        <!--
-        <item>com.example.package.first/com.example.class.FirstService</item>
-        <item>com.example.package.second/com.example.class.SecondService</item>
-        -->
-    </string-array>
-
-    <!-- List containing the component names of pre-installed display services. -->
-    <string-array name="config_preinstalled_display_services" translatable="false">
-        <!--
-        <item>com.example.package.first/com.example.class.FirstService</item>
-        <item>com.example.package.second/com.example.class.SecondService</item>
-        -->
-    </string-array>
-
-    <!-- List containing the component names of pre-installed interaction control services. -->
-    <string-array name="config_preinstalled_interaction_control_services" translatable="false">
-        <!--
-        <item>com.example.package.first/com.example.class.FirstService</item>
-        <item>com.example.package.second/com.example.class.SecondService</item>
-        -->
-    </string-array>
-
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d64018d..bbdaf59 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2167,6 +2167,8 @@
     <string name="search_settings">Search</string>
     <!-- Main Settings screen, setting option summary to go into search settings -->
     <string name="search_settings_summary">Manage search settings and history</string>
+    <!-- There are no search results for the user's search [CHAR LIMIT=NONE]-->
+    <string name="search_settings_no_results">No results</string>
 
     <!-- Display settings --><skip/>
     <!-- Sound & display settings screen, section header for settings related to display -->
@@ -3984,22 +3986,18 @@
     <string name="vision_settings_title">Vision Settings</string>
     <!-- Settings description for a brief version of Vision-Related Accessibility Settings. Tells the user that they can adjust these settings now to help them through the remainder of the Setup Wizard and that they can later be changed in Settings. Displayed in Setup Wizard only. [CHAR LIMIT=none] -->
     <string name="vision_settings_description">You can customize this device to fit your needs. These accessibility features can be changed later in Settings.</string>
-    <!-- Title for the accessibility preference category of screen reader services and settings. [CHAR LIMIT=50] -->
-    <string name="screen_reader_category_title">Screen readers</string>
-    <!-- Title for the accessibility preference category of audio services and settings. [CHAR LIMIT=50] -->
-    <string name="audio_and_captions_category_title">Audio &amp; on-screen text</string>
-    <!-- Title for the accessibility preference category of display services and settings. [CHAR LIMIT=50] -->
-    <string name="display_category_title">Display</string>
-    <!-- Title for the accessibility preference category of interaction control services and settings. [CHAR LIMIT=50] -->
-    <string name="interaction_control_category_title">Interaction controls</string>
-    <!-- Title for the accessibility preference category of services downloaded by the user. [CHAR LIMIT=50] -->
-    <string name="user_installed_services_category_title">Downloaded services</string>
+    <!-- Title for the accessibility preference category of accessibility services. [CHAR LIMIT=25] -->
+    <string name="accessibility_services_title">Services</string>
     <!-- Title for the Talkback Accessibility Service. Displayed on the Accessibility Settings screen in Setup Wizard. [CHAR_LIMIT=25] -->
     <string name="talkback_title">Talkback</string>
     <!-- Summary for the Talkback Accessibility Service. Lets the user know that Talkback is a screenreader and that it is usually most helpful to blind and low vision users and whether the service is on. [CHAR_LIMIT=none] -->
     <string name="talkback_summary">Screen reader primarily for people with blindness and low vision</string>
     <!-- Summary for the Select to Speak Accessibility Service. [CHAR_LIMIT=none] -->
     <string name="select_to_speak_summary">Tap items on your screen to hear them read aloud</string>
+    <!-- Title for the accessibility preference category of system related preferences. [CHAR LIMIT=25] -->
+    <string name="accessibility_system_title">System</string>
+    <!-- Title for the accessibility preference category of display related preferences. [CHAR LIMIT=25] -->
+    <string name="accessibility_display_title">Display</string>
     <!-- Title for the accessibility preference screen to enable video captioning. [CHAR LIMIT=35] -->
     <string name="accessibility_captioning_title">Captions</string>
     <!-- Title for the accessibility preference screen to enable screen magnification. [CHAR LIMIT=35] -->
@@ -4190,10 +4188,10 @@
     <string name="disable_service_message">Tapping OK will
         stop <xliff:g id="service" example="TalkBack">%1$s</xliff:g>.</string>
 
-    <!-- Title for the prompt shown as a placeholder if no accessibility services are installed. [CHAR LIMIT=50] -->
+    <!-- Title for the prompt shown as a placeholder if no accessibility serivices are installed. [CHAR LIMIT=50] -->
     <string name="accessibility_no_services_installed">No services installed</string>
 
-    <!-- Default description for an accessibility service if the latter doesn't provide one. [CHAR LIMIT=NONE] -->
+    <!-- Default description for an accessibility serivice if the latter doesn't provide one. [CHAR LIMIT=NONE] -->
     <string name="accessibility_service_default_description">No description provided.</string>
 
     <!-- Accessibility settings: button for lauching settings for an accessibility service -->
@@ -4214,7 +4212,7 @@
     <!-- Title for print service settings screen [CHAR LIMIT=25] -->
     <string name="print_settings_title">Print services</string>
 
-    <!-- Title for the prompt shown as a placeholder if no print services are installed. [CHAR LIMIT=50] -->
+    <!-- Title for the prompt shown as a placeholder if no print serivices are installed. [CHAR LIMIT=50] -->
     <string name="print_no_services_installed">No services installed</string>
 
     <!-- Title for the prompt shown as a placeholder if no printers are found while searching. [CHAR LIMIT=50] -->
@@ -4554,6 +4552,11 @@
     <!-- [CHAR_LIMIT=40] Battery saver: Value for automatic entry option: pct% battery -->
     <string name="battery_saver_turn_on_automatically_pct">at <xliff:g id="percent">%1$s</xliff:g> battery</string>
 
+    <!-- [CHAR_LIMIT=40] Battery percentage: Title -->
+    <string name="battery_percentage">Battery percentage</string>
+    <!-- [CHAR_LIMIT=NONE] Battery percentage: Description for preference -->
+    <string name="battery_percentage_description">Show battery percentage in status bar</string>
+
     <!-- Process Stats strings -->
     <skip />
 
@@ -7489,9 +7492,18 @@
     <!-- Summary of device info page [CHAR LIMIT=NONE] -->
     <string name="about_summary">Android <xliff:g id="version" example="6.0">%1$s</xliff:g></string>
 
-    <!-- TODO: Update these strings with the finalized ones. -->
     <!-- Title for dialog displayed when user clicks on a setting locked by an admin [CHAR LIMIT=30] -->
     <string name="disabled_by_policy_title">Action not allowed</string>
+    <!-- Title for dialog displayed to tell user that changing volume was disallowed by an admin [CHAR LIMIT=50] -->
+    <string name="disabled_by_policy_title_adjust_volume">Can\'t change volume</string>
+    <!-- Title for dialog displayed to tell user that outgoing calls were disabled by an admin [CHAR LIMIT=50] -->
+    <string name="disabled_by_policy_title_outgoing_calls">Calling not allowed</string>
+    <!-- Title for dialog displayed to tell user that sending SMS were disabled by an admin [CHAR LIMIT=50] -->
+    <string name="disabled_by_policy_title_sms">SMS not allowed</string>
+    <!-- Title for dialog displayed to tell user that the camera was disabled by an admin [CHAR LIMIT=50] -->
+    <string name="disabled_by_policy_title_camera">Camera not allowed</string>
+    <!-- Title for dialog displayed to tell user that screenshots are disabled by an admin [CHAR LIMIT=50] -->
+    <string name="disabled_by_policy_title_screen_capture">Screenshot not allowed</string>
     <!-- Shown when the user tries to change a settings locked by an admin [CHAR LIMIT=200] -->
     <string name="default_admin_support_msg">This action is disabled. Contact your organization\'s administrator to learn more.</string>
     <!-- Shown in dialog to allow user to see more information about the device admin [CHAR LIMIT=30] -->
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index 478dfe5..ee21017 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -18,42 +18,38 @@
         android:title="@string/accessibility_settings"
         android:persistent="true">
 
-    <ListPreference
-            android:key="accessibility_shortcut_preference"
-            android:title="@string/accessibility_global_gesture_preference_title"/>
-
     <PreferenceCategory
-            android:key="user_installed_services_category"
-            android:title="@string/user_installed_services_category_title">
+            android:key="services_category"
+            android:title="@string/accessibility_services_title">
     </PreferenceCategory>
 
     <PreferenceCategory
-            android:key="screen_reader_category"
-            android:title="@string/screen_reader_category_title">
+            android:key="system_category"
+            android:title="@string/accessibility_system_title">
 
         <Preference
-                android:key="tts_settings_preference"
-                android:fragment="com.android.settings.tts.TextToSpeechSettings"
-                android:title="@string/tts_settings_title"/>
-    </PreferenceCategory>
-
-    <PreferenceCategory
-            android:key="display_category"
-            android:title="@string/display_category_title">
+            android:fragment="com.android.settings.accessibility.CaptionPropertiesFragment"
+            android:key="captioning_preference_screen"
+            android:title="@string/accessibility_captioning_title" />
 
         <Preference
-                android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment"
-                android:key="font_size_preference_screen"
-                android:title="@string/title_font_size"/>
+            android:fragment="com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment"
+            android:key="screen_magnification_preference_screen"
+            android:title="@string/accessibility_screen_magnification_title"/>
+
+        <Preference
+            android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment"
+            android:key="font_size_preference_screen"
+            android:title="@string/title_font_size"/>
 
         <com.android.settings.display.ScreenZoomPreference
-                android:key="screen_zoom"
-                android:title="@string/screen_zoom_title"/>
+            android:key="screen_zoom"
+            android:title="@string/screen_zoom_title"/>
 
         <Preference
-                android:fragment="com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment"
-                android:key="screen_magnification_preference_screen"
-                android:title="@string/accessibility_screen_magnification_title"/>
+            android:fragment="com.android.settings.accessibility.ToggleAutoclickPreferenceFragment"
+            android:key="autoclick_preference_screen"
+            android:title="@string/accessibility_autoclick_preference_title"/>
 
         <SwitchPreference
                 android:key="toggle_high_text_contrast_preference"
@@ -61,31 +57,6 @@
                 android:summary="@string/experimental_preference"/>
 
         <SwitchPreference
-                android:key="toggle_inversion_preference"
-                android:title="@string/accessibility_display_inversion_preference_title"
-                android:summary="@string/accessibility_display_inversion_preference_subtitle"
-                android:persistent="false" />
-
-        <Preference
-                android:fragment="com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment"
-                android:key="daltonizer_preference_screen"
-                android:title="@string/accessibility_display_daltonizer_preference_title" />
-
-        <SwitchPreference
-                android:key="toggle_large_pointer_icon"
-                android:title="@string/accessibility_toggle_large_pointer_icon_title" />
-    </PreferenceCategory>
-
-    <PreferenceCategory
-            android:key="interaction_control_category"
-            android:title="@string/interaction_control_category_title">
-
-        <Preference
-                android:fragment="com.android.settings.accessibility.ToggleAutoclickPreferenceFragment"
-                android:key="autoclick_preference_screen"
-                android:title="@string/accessibility_autoclick_preference_title"/>
-
-        <SwitchPreference
                 android:key="toggle_power_button_ends_call_preference"
                 android:title="@string/accessibility_power_button_ends_call_prerefence_title"
                 android:persistent="false"/>
@@ -95,17 +66,9 @@
                 android:title="@string/accelerometer_title"
                 android:persistent="false"/>
 
-        <ListPreference
-                android:key="select_long_press_timeout_preference"
-                android:title="@string/accessibility_long_press_timeout_preference_title"
-                android:entries="@array/long_press_timeout_selector_titles"
-                android:entryValues="@array/long_press_timeout_selector_values"
-                android:persistent="false"/>
-    </PreferenceCategory>
-
-    <PreferenceCategory
-            android:key="audio_and_captions_category"
-            android:title="@string/audio_and_captions_category_title">
+        <SwitchPreference
+                android:key="toggle_large_pointer_icon"
+                android:title="@string/accessibility_toggle_large_pointer_icon_title" />
 
         <SwitchPreference
                 android:key="toggle_master_mono"
@@ -113,9 +76,35 @@
                 android:summary="@string/accessibility_toggle_master_mono_summary"
                 android:persistent="false"/>
 
+        <ListPreference
+                android:key="accessibility_shortcut_preference"
+                android:title="@string/accessibility_global_gesture_preference_title"/>
+
         <Preference
-                android:fragment="com.android.settings.accessibility.CaptionPropertiesFragment"
-                android:key="captioning_preference_screen"
-                android:title="@string/accessibility_captioning_title" />
+                android:key="tts_settings_preference"
+                android:fragment="com.android.settings.tts.TextToSpeechSettings"
+                android:title="@string/tts_settings_title"/>
+
+        <ListPreference android:key="select_long_press_timeout_preference"
+                android:title="@string/accessibility_long_press_timeout_preference_title"
+                android:entries="@array/long_press_timeout_selector_titles"
+                android:entryValues="@array/long_press_timeout_selector_values"
+                android:persistent="false"/>
+
     </PreferenceCategory>
+
+    <PreferenceCategory
+        android:key="display_category"
+        android:title="@string/accessibility_display_title" >
+        <SwitchPreference
+            android:key="toggle_inversion_preference"
+            android:title="@string/accessibility_display_inversion_preference_title"
+            android:summary="@string/accessibility_display_inversion_preference_subtitle"
+            android:persistent="false" />
+        <Preference
+            android:fragment="com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment"
+            android:key="daltonizer_preference_screen"
+            android:title="@string/accessibility_display_daltonizer_preference_title" />
+    </PreferenceCategory>
+
 </PreferenceScreen>
diff --git a/res/xml/power_usage_summary.xml b/res/xml/power_usage_summary.xml
index 58cab77..aecb6f1 100644
--- a/res/xml/power_usage_summary.xml
+++ b/res/xml/power_usage_summary.xml
@@ -34,6 +34,11 @@
             android:title="@string/battery_saver"
             android:fragment="com.android.settings.fuelgauge.BatterySaverSettings"/>
 
+        <SwitchPreference
+            android:key="battery_percentage"
+            android:title="@string/battery_percentage"
+            android:summary="@string/battery_percentage_description"/>
+
         <!-- Cross-listed item, if you change this, also change it in ia_display_settings.xml -->
         <SwitchPreference
             android:key="auto_brightness"
diff --git a/src/com/android/settings/ShowAdminSupportDetailsDialog.java b/src/com/android/settings/ShowAdminSupportDetailsDialog.java
index 2f65bb5..c1cd6f5 100644
--- a/src/com/android/settings/ShowAdminSupportDetailsDialog.java
+++ b/src/com/android/settings/ShowAdminSupportDetailsDialog.java
@@ -30,6 +30,7 @@
 import android.os.Process;
 import android.os.RemoteException;
 import android.os.UserHandle;
+import android.os.UserManager;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -39,6 +40,8 @@
 import com.android.settingslib.RestrictedLockUtils;
 import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
 
+import java.util.Objects;
+
 public class ShowAdminSupportDetailsDialog extends Activity
         implements DialogInterface.OnDismissListener {
 
@@ -46,17 +49,20 @@
 
     private EnforcedAdmin mEnforcedAdmin;
     private View mDialogView;
+    private String mRestriction = null;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mEnforcedAdmin = getAdminDetailsFromIntent(getIntent());
+        mRestriction = getRestrictionFromIntent(getIntent());
 
         AlertDialog.Builder builder = new AlertDialog.Builder(this);
         mDialogView = LayoutInflater.from(builder.getContext()).inflate(
                 R.layout.admin_support_details_dialog, null);
-        initializeDialogViews(mDialogView, mEnforcedAdmin.component, mEnforcedAdmin.userId);
+        initializeDialogViews(mDialogView, mEnforcedAdmin.component, mEnforcedAdmin.userId,
+                mRestriction);
         builder.setOnDismissListener(this)
                 .setPositiveButton(R.string.okay, null)
                 .setView(mDialogView)
@@ -67,9 +73,12 @@
     public void onNewIntent(Intent intent) {
         super.onNewIntent(intent);
         EnforcedAdmin admin = getAdminDetailsFromIntent(intent);
-        if (!mEnforcedAdmin.equals(admin)) {
+        String restriction = getRestrictionFromIntent(intent);
+        if (!mEnforcedAdmin.equals(admin) || !Objects.equals(mRestriction, restriction)) {
             mEnforcedAdmin = admin;
-            initializeDialogViews(mDialogView, mEnforcedAdmin.component, mEnforcedAdmin.userId);
+            mRestriction = restriction;
+            initializeDialogViews(mDialogView, mEnforcedAdmin.component, mEnforcedAdmin.userId,
+                    mRestriction);
         }
     }
 
@@ -83,7 +92,13 @@
         return admin;
     }
 
-    private void initializeDialogViews(View root, ComponentName admin, int userId) {
+    private String getRestrictionFromIntent(Intent intent) {
+        if (intent == null) return null;
+        return intent.getStringExtra(DevicePolicyManager.EXTRA_RESTRICTION);
+    }
+
+    private void initializeDialogViews(View root, ComponentName admin, int userId,
+                                               String restriction) {
         if (admin != null) {
             if (!RestrictedLockUtils.isAdminInCurrentUserOrProfile(this, admin)
                     || !RestrictedLockUtils.isCurrentUserOrProfile(this, userId)) {
@@ -106,9 +121,41 @@
             }
         }
 
+        setAdminSupportTitle(root, restriction);
         setAdminSupportDetails(this, root, new EnforcedAdmin(admin, userId), true);
     }
 
+    private void setAdminSupportTitle(View root, String restriction) {
+        final TextView titleView = (TextView) root.findViewById(R.id.admin_support_dialog_title);
+        if (titleView == null) {
+            return;
+        }
+        if (restriction == null) {
+            titleView.setText(R.string.disabled_by_policy_title);
+            return;
+        }
+        switch(restriction) {
+            case UserManager.DISALLOW_ADJUST_VOLUME:
+                titleView.setText(R.string.disabled_by_policy_title_adjust_volume);
+                break;
+            case UserManager.DISALLOW_OUTGOING_CALLS:
+                titleView.setText(R.string.disabled_by_policy_title_outgoing_calls);
+                break;
+            case UserManager.DISALLOW_SMS:
+                titleView.setText(R.string.disabled_by_policy_title_sms);
+                break;
+            case DevicePolicyManager.POLICY_DISABLE_CAMERA:
+                titleView.setText(R.string.disabled_by_policy_title_camera);
+                break;
+            case DevicePolicyManager.POLICY_DISABLE_SCREEN_CAPTURE:
+                titleView.setText(R.string.disabled_by_policy_title_screen_capture);
+                break;
+            default:
+                // Use general text if no specialized title applies
+                titleView.setText(R.string.disabled_by_policy_title);
+        }
+    }
+
     public static void setAdminSupportDetails(final Activity activity, View root,
             final EnforcedAdmin enforcedAdmin, final boolean finishActivity) {
         if (enforcedAdmin == null) {
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 672f4ed..807371e 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -25,7 +25,6 @@
 import android.content.pm.PackageManager;
 import android.content.pm.ServiceInfo;
 import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
 import android.net.Uri;
 import android.os.Bundle;
 import android.os.Handler;
@@ -36,9 +35,7 @@
 import android.support.v7.preference.ListPreference;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceCategory;
-import android.support.v7.preference.PreferenceScreen;
 import android.text.TextUtils;
-import android.util.ArrayMap;
 import android.view.KeyCharacterMap;
 import android.view.KeyEvent;
 import android.view.accessibility.AccessibilityManager;
@@ -49,17 +46,18 @@
 import com.android.internal.view.RotationPolicy.RotationPolicyListener;
 import com.android.settings.R;
 import com.android.settings.SettingsPreferenceFragment;
-import com.android.settings.SingleLineSummaryPreference;
 import com.android.settings.Utils;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settings.search.Indexable;
 import com.android.settings.search.SearchIndexableRaw;
 import com.android.settingslib.RestrictedLockUtils;
 import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+import com.android.settingslib.RestrictedPreference;
 import com.android.settingslib.accessibility.AccessibilityUtils;
 
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -70,20 +68,9 @@
 public class AccessibilitySettings extends SettingsPreferenceFragment implements
         Preference.OnPreferenceChangeListener, Indexable {
 
-    // Index of the first preference in a preference category.
-    private static final int FIRST_PREFERENCE_IN_CATEGORY_INDEX = 0;
-
     // Preference categories
-    private static final String CATEGORY_SCREEN_READER = "screen_reader_category";
-    private static final String CATEGORY_AUDIO_AND_CAPTIONS = "audio_and_captions_category";
-    private static final String CATEGORY_DISPLAY = "display_category";
-    private static final String CATEGORY_INTERACTION_CONTROL = "interaction_control_category";
-    private static final String CATEGORY_DOWNLOADED_SERVICES = "user_installed_services_category";
-
-    private static final String[] CATEGORIES = new String[] {
-        CATEGORY_SCREEN_READER, CATEGORY_AUDIO_AND_CAPTIONS, CATEGORY_DISPLAY,
-        CATEGORY_INTERACTION_CONTROL, CATEGORY_DOWNLOADED_SERVICES
-    };
+    private static final String SERVICES_CATEGORY = "services_category";
+    private static final String SYSTEM_CATEGORY = "system_category";
 
     // Preferences
     private static final String TOGGLE_HIGH_TEXT_CONTRAST_PREFERENCE =
@@ -131,7 +118,10 @@
     // ID for dialog that confirms shortcut capabilities
     private static final int DIALOG_ID_ADD_SHORTCUT_WARNING = 1;
 
-    private final Map<String, String> mLongPressTimeoutValueToTitleMap = new HashMap<>();
+    // Auxiliary members.
+    static final Set<ComponentName> sInstalledServices = new HashSet<>();
+
+    private final Map<String, String> mLongPressTimeoutValuetoTitleMap = new HashMap<>();
 
     private final Handler mHandler = new Handler();
 
@@ -139,7 +129,7 @@
         @Override
         public void run() {
             if (getActivity() != null) {
-                updateServicePreferences();
+                updateServicesPreferences();
             }
         }
     };
@@ -174,7 +164,7 @@
             new SettingsContentObserver(mHandler) {
                 @Override
                 public void onChange(boolean selfChange, Uri uri) {
-                    updateServicePreferences();
+                    updateServicesPreferences();
                 }
             };
 
@@ -185,12 +175,9 @@
         }
     };
 
-    private final Map<String, PreferenceCategory> mCategoryToPrefCategoryMap =
-            new ArrayMap<>();
-    private final Map<Preference, PreferenceCategory> mServicePreferenceToPreferenceCategoryMap =
-            new ArrayMap<>();
-    private final Map<ComponentName, PreferenceCategory> mPreBundledServiceComponentToCategoryMap =
-            new ArrayMap<>();
+    // Preference controls.
+    private PreferenceCategory mServicesCategory;
+    private PreferenceCategory mSystemsCategory;
 
     private SwitchPreference mToggleHighTextContrastPreference;
     private SwitchPreference mTogglePowerButtonEndsCallPreference;
@@ -273,7 +260,7 @@
         Settings.Secure.putInt(getContentResolver(),
                 Settings.Secure.LONG_PRESS_TIMEOUT, Integer.parseInt(stringValue));
         mSelectLongPressTimeoutPreference.setSummary(
-                mLongPressTimeoutValueToTitleMap.get(stringValue));
+                mLongPressTimeoutValuetoTitleMap.get(stringValue));
     }
 
     private void handleToggleInversionPreferenceChange(boolean checked) {
@@ -399,10 +386,8 @@
     }
 
     private void initializeAllPreferences() {
-        for (int i = 0; i < CATEGORIES.length; i++) {
-            PreferenceCategory prefCategory = (PreferenceCategory) findPreference(CATEGORIES[i]);
-            mCategoryToPrefCategoryMap.put(CATEGORIES[i], prefCategory);
-        }
+        mServicesCategory = (PreferenceCategory) findPreference(SERVICES_CATEGORY);
+        mSystemsCategory = (PreferenceCategory) findPreference(SYSTEM_CATEGORY);
 
         // Text contrast.
         mToggleHighTextContrastPreference =
@@ -417,16 +402,14 @@
                 (SwitchPreference) findPreference(TOGGLE_POWER_BUTTON_ENDS_CALL_PREFERENCE);
         if (!KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POWER)
                 || !Utils.isVoiceCapable(getActivity())) {
-            mCategoryToPrefCategoryMap.get(CATEGORY_INTERACTION_CONTROL)
-                    .removePreference(mTogglePowerButtonEndsCallPreference);
+            mSystemsCategory.removePreference(mTogglePowerButtonEndsCallPreference);
         }
 
         // Lock screen rotation.
         mToggleLockScreenRotationPreference =
                 (SwitchPreference) findPreference(TOGGLE_LOCK_SCREEN_ROTATION_PREFERENCE);
         if (!RotationPolicy.isRotationSupported(getActivity())) {
-            mCategoryToPrefCategoryMap.get(CATEGORY_INTERACTION_CONTROL)
-                    .removePreference(mToggleLockScreenRotationPreference);
+            mSystemsCategory.removePreference(mToggleLockScreenRotationPreference);
         }
 
         // Large pointer icon.
@@ -441,7 +424,7 @@
         mSelectLongPressTimeoutPreference =
                 (ListPreference) findPreference(SELECT_LONG_PRESS_TIMEOUT_PREFERENCE);
         mSelectLongPressTimeoutPreference.setOnPreferenceChangeListener(this);
-        if (mLongPressTimeoutValueToTitleMap.size() == 0) {
+        if (mLongPressTimeoutValuetoTitleMap.size() == 0) {
             String[] timeoutValues = getResources().getStringArray(
                     R.array.long_press_timeout_selector_values);
             mLongPressTimeoutDefault = Integer.parseInt(timeoutValues[0]);
@@ -449,7 +432,7 @@
                     R.array.long_press_timeout_selector_titles);
             final int timeoutValueCount = timeoutValues.length;
             for (int i = 0; i < timeoutValueCount; i++) {
-                mLongPressTimeoutValueToTitleMap.put(timeoutValues[i], timeoutTitles[i]);
+                mLongPressTimeoutValuetoTitleMap.put(timeoutValues[i], timeoutTitles[i]);
             }
         }
 
@@ -476,32 +459,17 @@
     }
 
     private void updateAllPreferences() {
+        updateServicesPreferences();
         updateSystemPreferences();
-        updateServicePreferences();
     }
 
-    private void updateServicePreferences() {
+    private void updateServicesPreferences() {
         // Since services category is auto generated we have to do a pass
         // to generate it since services can come and go and then based on
         // the global accessibility state to decided whether it is enabled.
 
         // Generate.
-        ArrayList<Preference> servicePreferences =
-                new ArrayList<>(mServicePreferenceToPreferenceCategoryMap.keySet());
-        for (int i = 0; i < servicePreferences.size(); i++) {
-            Preference service = servicePreferences.get(i);
-            PreferenceCategory category = mServicePreferenceToPreferenceCategoryMap.get(service);
-            category.removePreference(service);
-        }
-
-        initializePreBundledServicesMapFromArray(CATEGORY_SCREEN_READER,
-                R.array.config_preinstalled_screen_reader_services);
-        initializePreBundledServicesMapFromArray(CATEGORY_AUDIO_AND_CAPTIONS,
-                R.array.config_preinstalled_audio_and_caption_services);
-        initializePreBundledServicesMapFromArray(CATEGORY_DISPLAY,
-                R.array.config_preinstalled_display_services);
-        initializePreBundledServicesMapFromArray(CATEGORY_INTERACTION_CONTROL,
-                R.array.config_preinstalled_interaction_control_services);
+        mServicesCategory.removeAll();
 
         AccessibilityManager accessibilityManager = AccessibilityManager.getInstance(getActivity());
 
@@ -514,49 +482,36 @@
         final boolean accessibilityEnabled = Settings.Secure.getInt(getContentResolver(),
                 Settings.Secure.ACCESSIBILITY_ENABLED, 0) == 1;
 
-        PreferenceCategory downloadedServicesCategory =
-                mCategoryToPrefCategoryMap.get(CATEGORY_DOWNLOADED_SERVICES);
-        // Temporarily add the downloaded services category back if it was previously removed.
-        if (findPreference(CATEGORY_DOWNLOADED_SERVICES) == null) {
-            getPreferenceScreen().addPreference(downloadedServicesCategory);
-        }
-
         for (int i = 0, count = installedServices.size(); i < count; ++i) {
             AccessibilityServiceInfo info = installedServices.get(i);
 
-            SingleLineSummaryPreference preference =
-                    new SingleLineSummaryPreference(downloadedServicesCategory.getContext(), null);
+            RestrictedPreference preference =
+                    new RestrictedPreference(mServicesCategory.getContext());
             String title = info.getResolveInfo().loadLabel(getPackageManager()).toString();
 
-            Drawable icon = info.getResolveInfo().loadIcon(getPackageManager());
-            if (icon == null) {
-                // todo (saigem): add a default
-            }
-
             ServiceInfo serviceInfo = info.getResolveInfo().serviceInfo;
-            String packageName = serviceInfo.packageName;
-            ComponentName componentName = new ComponentName(packageName, serviceInfo.name);
-            String componentNameKey = componentName.flattenToString();
+            ComponentName componentName = new ComponentName(serviceInfo.packageName,
+                    serviceInfo.name);
 
             preference.setKey(componentName.flattenToString());
 
             preference.setTitle(title);
-            preference.setIcon(icon);
             final boolean serviceEnabled = accessibilityEnabled
                     && enabledServices.contains(componentName);
-            String serviceState = serviceEnabled ?
-                    getString(R.string.accessibility_feature_state_on) :
-                    getString(R.string.accessibility_feature_state_off);
-            String serviceSummary = info.loadSummary(getPackageManager());
-            serviceSummary = (TextUtils.isEmpty(serviceSummary)) ? serviceState.toUpperCase() :
-                    serviceState.toUpperCase() + " / " + serviceSummary;
+            String serviceEnabledString;
+            if (serviceEnabled) {
+                serviceEnabledString = getString(R.string.accessibility_feature_state_on);
+            } else {
+                serviceEnabledString = getString(R.string.accessibility_feature_state_off);
+            }
 
             // Disable all accessibility services that are not permitted.
+            String packageName = serviceInfo.packageName;
             boolean serviceAllowed =
                     permittedServices == null || permittedServices.contains(packageName);
             if (!serviceAllowed && !serviceEnabled) {
                 EnforcedAdmin admin = RestrictedLockUtils.checkIfAccessibilityServiceDisallowed(
-                        getActivity(), packageName, UserHandle.myUserId());
+                        getActivity(), serviceInfo.packageName, UserHandle.myUserId());
                 if (admin != null) {
                     preference.setDisabledByAdmin(admin);
                 } else {
@@ -566,7 +521,9 @@
                 preference.setEnabled(true);
             }
 
-            preference.setSummary(serviceSummary);
+            preference.setSummary(serviceEnabledString);
+
+            preference.setOrder(i);
             preference.setFragment(ToggleAccessibilityServicePreferenceFragment.class.getName());
             preference.setPersistent(true);
 
@@ -586,33 +543,26 @@
                 extras.putString(EXTRA_SETTINGS_TITLE,
                         getString(R.string.accessibility_menu_item_settings));
                 extras.putString(EXTRA_SETTINGS_COMPONENT_NAME,
-                        new ComponentName(packageName, settingsClassName).flattenToString());
+                        new ComponentName(info.getResolveInfo().serviceInfo.packageName,
+                                settingsClassName).flattenToString());
             }
+
             extras.putParcelable(EXTRA_COMPONENT_NAME, componentName);
 
-            PreferenceCategory prefCategory = downloadedServicesCategory;
-            // Set the appropriate category if the service comes pre-installed.
-            if (mPreBundledServiceComponentToCategoryMap.containsKey(componentName)) {
-                prefCategory = mPreBundledServiceComponentToCategoryMap.get(componentName);
+            mServicesCategory.addPreference(preference);
+        }
+
+        if (mServicesCategory.getPreferenceCount() == 0) {
+            if (mNoServicesMessagePreference == null) {
+                mNoServicesMessagePreference = new Preference(getPrefContext());
+                mNoServicesMessagePreference.setPersistent(false);
+                mNoServicesMessagePreference.setLayoutResource(
+                        R.layout.text_description_preference);
+                mNoServicesMessagePreference.setSelectable(false);
+                mNoServicesMessagePreference.setSummary(
+                        getString(R.string.accessibility_no_services_installed));
             }
-            preference.setOrder(FIRST_PREFERENCE_IN_CATEGORY_INDEX);
-            prefCategory.addPreference(preference);
-            mServicePreferenceToPreferenceCategoryMap.put(preference, prefCategory);
-        }
-
-        // If the user has not installed any additional services, hide the category.
-        if (downloadedServicesCategory.getPreferenceCount() == 0) {
-            PreferenceScreen screen = getPreferenceScreen();
-            screen.removePreference(downloadedServicesCategory);
-        }
-    }
-
-    private void initializePreBundledServicesMapFromArray(String categoryKey, int key) {
-        String[] services = getResources().getStringArray(key);
-        PreferenceCategory category = mCategoryToPrefCategoryMap.get(categoryKey);
-        for (int i = 0; i < services.length; i++) {
-            ComponentName component = ComponentName.unflattenFromString(services[i]);
-            mPreBundledServiceComponentToCategoryMap.put(component, category);
+            mServicesCategory.addPreference(mNoServicesMessagePreference);
         }
     }
 
@@ -652,7 +602,7 @@
                 Settings.Secure.LONG_PRESS_TIMEOUT, mLongPressTimeoutDefault);
         String value = String.valueOf(longPressTimeout);
         mSelectLongPressTimeoutPreference.setValue(value);
-        mSelectLongPressTimeoutPreference.setSummary(mLongPressTimeoutValueToTitleMap.get(value));
+        mSelectLongPressTimeoutPreference.setSummary(mLongPressTimeoutValuetoTitleMap.get(value));
 
         updateFeatureSummary(Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED,
                 mCaptioningPreferenceScreen);
diff --git a/src/com/android/settings/display/BatteryPercentagePreferenceController.java b/src/com/android/settings/display/BatteryPercentagePreferenceController.java
new file mode 100644
index 0000000..4968957
--- /dev/null
+++ b/src/com/android/settings/display/BatteryPercentagePreferenceController.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2016 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.display;
+
+import android.content.Context;
+import android.provider.Settings;
+import android.support.v7.preference.Preference;
+import android.support.v14.preference.SwitchPreference;
+
+import com.android.settings.core.PreferenceController;
+
+import static android.provider.Settings.System.SHOW_BATTERY_PERCENT;
+
+/**
+ * A controller to manage the switch for showing battery percentage in the status bar.
+ */
+
+public class BatteryPercentagePreferenceController extends PreferenceController
+        implements Preference.OnPreferenceChangeListener {
+
+    private static final String KEY_BATTERY_PERCENTAGE = "battery_percentage";
+
+    public BatteryPercentagePreferenceController(Context context) {
+        super(context);
+    }
+
+    @Override
+    public boolean isAvailable() {
+        return true;
+    }
+
+    @Override
+    public String getPreferenceKey() {
+        return KEY_BATTERY_PERCENTAGE;
+    }
+
+    @Override
+    public void updateState(Preference preference) {
+        int setting = Settings.System.getInt(mContext.getContentResolver(),
+                SHOW_BATTERY_PERCENT, 0);
+
+        ((SwitchPreference) preference).setChecked(setting == 1);
+    }
+
+    @Override
+    public boolean onPreferenceChange(Preference preference, Object newValue) {
+        boolean showPercentage = (Boolean) newValue;
+        Settings.System.putInt(mContext.getContentResolver(), SHOW_BATTERY_PERCENT,
+                showPercentage ? 1 : 0);
+        return true;
+    }
+}
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index 44f61c1..1ffc594 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -56,6 +56,7 @@
 import com.android.settings.core.instrumentation.MetricsFeatureProvider;
 import com.android.settings.dashboard.SummaryLoader;
 import com.android.settings.display.AutoBrightnessPreferenceController;
+import com.android.settings.display.BatteryPercentagePreferenceController;
 import com.android.settings.display.TimeoutPreferenceController;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settings.search.BaseSearchIndexProvider;
@@ -185,6 +186,7 @@
         controllers.add(new AutoBrightnessPreferenceController(context));
         controllers.add(new TimeoutPreferenceController(context));
         controllers.add(new BatterySaverController(context, getLifecycle()));
+        controllers.add(new BatteryPercentagePreferenceController(context));
         return controllers;
     }
 
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index a451786..d12842c 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -218,7 +218,7 @@
     }
 
     private void setupBlock() {
-        if (mAppRow.systemApp) {
+        if (mAppRow.systemApp && !mAppRow.banned) {
             setVisible(mBlock, false);
         } else {
             mBlock.setDisabledByAdmin(mSuspendedAppsAdmin);
@@ -243,6 +243,9 @@
             setVisible(category, !banned);
         }
         setVisible(mBadge, !banned);
+        if (mAppRow.systemApp && !mAppRow.banned) {
+            setVisible(mBlock, false);
+        }
     }
 
     private Comparator<NotificationChannel> mChannelComparator =
diff --git a/src/com/android/settings/notification/ChannelNotificationSettings.java b/src/com/android/settings/notification/ChannelNotificationSettings.java
index 1cb2154..18e00f8 100644
--- a/src/com/android/settings/notification/ChannelNotificationSettings.java
+++ b/src/com/android/settings/notification/ChannelNotificationSettings.java
@@ -134,7 +134,9 @@
         }
         mLights.setDisabledByAdmin(mSuspendedAppsAdmin);
         mVibrate.setDisabledByAdmin(mSuspendedAppsAdmin);
-        mImportance.setDisabledByAdmin(mSuspendedAppsAdmin);
+        if (mImportance.isEnabled()) {
+            mImportance.setDisabledByAdmin(mSuspendedAppsAdmin);
+        }
         mPriority.setDisabledByAdmin(mSuspendedAppsAdmin);
         mVisibilityOverride.setDisabledByAdmin(mSuspendedAppsAdmin);
     }
@@ -185,21 +187,26 @@
     }
 
     protected void setupBlockAndImportance() {
-        mBlock.setDisabledByAdmin(mSuspendedAppsAdmin);
-        mBlock.setChecked(mChannel.getImportance() == NotificationManager.IMPORTANCE_NONE);
-        mBlock.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
-            @Override
-            public boolean onPreferenceChange(Preference preference, Object newValue) {
-                final boolean value = (Boolean) newValue;
-                int importance = value ?  IMPORTANCE_NONE : IMPORTANCE_LOW;
-                mImportance.setValue(String.valueOf(importance));
-                mChannel.setImportance(importance);
-                mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
-                mBackend.updateChannel(mPkg, mUid, mChannel);
-                updateDependents();
-                return true;
-            }
-        });
+        if (mAppRow.systemApp && mChannel.getImportance() != NotificationManager.IMPORTANCE_NONE) {
+            setVisible(mBlock, false);
+        } else {
+            mBlock.setEnabled(mAppRow.systemApp);
+            mBlock.setDisabledByAdmin(mSuspendedAppsAdmin);
+            mBlock.setChecked(mChannel.getImportance() == NotificationManager.IMPORTANCE_NONE);
+            mBlock.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+                @Override
+                public boolean onPreferenceChange(Preference preference, Object newValue) {
+                    final boolean value = (Boolean) newValue;
+                    int importance = value ? IMPORTANCE_NONE : IMPORTANCE_LOW;
+                    mImportance.setValue(String.valueOf(importance));
+                    mChannel.setImportance(importance);
+                    mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
+                    mBackend.updateChannel(mPkg, mUid, mChannel);
+                    updateDependents();
+                    return true;
+                }
+            });
+        }
         mBadge.setDisabledByAdmin(mSuspendedAppsAdmin);
         mBadge.setEnabled(mAppRow.showBadge);
         mBadge.setChecked(mChannel.canShowBadge());
@@ -217,7 +224,8 @@
         mImportance.setDisabledByAdmin(mSuspendedAppsAdmin);
         final int numImportances = IMPORTANCE_HIGH - IMPORTANCE_MIN + 1;
         List<String> summaries = new ArrayList<>();
-        List<String> values = new ArrayList<>();;
+        List<String> values = new ArrayList<>();
+        ;
         for (int i = 0; i < numImportances; i++) {
             int importance = i + 1;
             summaries.add(getImportanceSummary(importance));
@@ -232,18 +240,21 @@
         mImportance.setEntries(summaries.toArray(new String[0]));
         mImportance.setValue(String.valueOf(mChannel.getImportance()));
         mImportance.setSummary("%s");
-
-        mImportance.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
-            @Override
-            public boolean onPreferenceChange(Preference preference, Object newValue) {
-                int importance = Integer.parseInt((String) newValue);
-                mChannel.setImportance(importance);
-                mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
-                mBackend.updateChannel(mPkg, mUid, mChannel);
-                updateDependents();
-                return true;
-            }
-        });
+        if (mAppRow.lockedImportance) {
+            mImportance.setEnabled(false);
+        } else {
+            mImportance.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+                @Override
+                public boolean onPreferenceChange(Preference preference, Object newValue) {
+                    int importance = Integer.parseInt((String) newValue);
+                    mChannel.setImportance(importance);
+                    mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
+                    mBackend.updateChannel(mPkg, mUid, mChannel);
+                    updateDependents();
+                    return true;
+                }
+            });
+        }
     }
 
     protected void setupPriorityPref(boolean priority) {
diff --git a/src/com/android/settings/notification/NotificationBackend.java b/src/com/android/settings/notification/NotificationBackend.java
index d201d60..0881eb7 100644
--- a/src/com/android/settings/notification/NotificationBackend.java
+++ b/src/com/android/settings/notification/NotificationBackend.java
@@ -64,7 +64,7 @@
             int N = nonBlockablePkgs.length;
             for (int i = 0; i < N; i++) {
                 if (app.packageName.equals(nonBlockablePkgs[i])) {
-                    row.systemApp = true;
+                    row.systemApp = row.lockedImportance = true;
                 }
             }
         }
@@ -152,6 +152,7 @@
         public boolean banned;
         public boolean first;  // first app in section
         public boolean systemApp;
+        public boolean lockedImportance;
         public boolean showBadge;
         public int userId;
     }
diff --git a/src/com/android/settings/notification/NotificationSettingsBase.java b/src/com/android/settings/notification/NotificationSettingsBase.java
index 38de27e..6a40ea5 100644
--- a/src/com/android/settings/notification/NotificationSettingsBase.java
+++ b/src/com/android/settings/notification/NotificationSettingsBase.java
@@ -148,7 +148,9 @@
         }
         mSuspendedAppsAdmin = RestrictedLockUtils.checkIfApplicationIsSuspended(
                 mContext, mPkg, mUserId);
-        mBlock.setDisabledByAdmin(mSuspendedAppsAdmin);
+        if (mBlock.isEnabled()) {
+            mBlock.setDisabledByAdmin(mSuspendedAppsAdmin);
+        }
         mBadge.setDisabledByAdmin(mSuspendedAppsAdmin);
     }
 
diff --git a/src/com/android/settings/search2/SearchActivity.java b/src/com/android/settings/search2/SearchActivity.java
index 25a54cf..5a8455b 100644
--- a/src/com/android/settings/search2/SearchActivity.java
+++ b/src/com/android/settings/search2/SearchActivity.java
@@ -21,6 +21,7 @@
 import android.app.FragmentManager;
 import android.os.Bundle;
 
+import android.view.WindowManager;
 import com.android.settings.R;
 
 public class SearchActivity extends Activity {
@@ -29,6 +30,8 @@
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.search_main);
+        // Keeps layouts in-place when keyboard opens.
+        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
 
         FragmentManager fragmentManager = getFragmentManager();
         Fragment fragment = fragmentManager.findFragmentById(R.id.main_content);
diff --git a/src/com/android/settings/search2/SearchFeatureProvider.java b/src/com/android/settings/search2/SearchFeatureProvider.java
index a9be5a1..d3dc24b 100644
--- a/src/com/android/settings/search2/SearchFeatureProvider.java
+++ b/src/com/android/settings/search2/SearchFeatureProvider.java
@@ -19,6 +19,7 @@
 import android.content.Context;
 import android.view.Menu;
 
+import android.view.View;
 import com.android.settings.dashboard.SiteMapManager;
 
 /**
@@ -68,4 +69,25 @@
      * Updates the Settings indexes
      */
     void updateIndex(Context context);
+
+    /**
+     * Initializes the feedback button in case it was dismissed.
+     */
+    default void initFeedbackButton() {
+    }
+
+    /**
+     * Show a button users can click to submit feedback on the quality of the search results.
+     */
+    default void showFeedbackButton(SearchFragment fragment, View view) {
+    }
+
+    /**
+     * Hide the feedback button shown by
+     * {@link #showFeedbackButton(SearchFragment fragment, View view) showFeedbackButton}
+     */
+    default void hideFeedbackButton() {
+    }
+
+
 }
diff --git a/src/com/android/settings/search2/SearchFragment.java b/src/com/android/settings/search2/SearchFragment.java
index 24f7015..957713b 100644
--- a/src/com/android/settings/search2/SearchFragment.java
+++ b/src/com/android/settings/search2/SearchFragment.java
@@ -31,6 +31,7 @@
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.inputmethod.InputMethodManager;
+import android.widget.LinearLayout;
 import android.widget.LinearLayout.LayoutParams;
 import android.widget.SearchView;
 
@@ -71,7 +72,7 @@
     @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
     static final String RESULT_CLICK_COUNT = "settings_search_result_click_count";
 
-    @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
+    @VisibleForTesting
     String mQuery;
 
     private final SaveQueryRecorderCallback mSaveQueryRecorderCallback =
@@ -89,6 +90,7 @@
     @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
     RecyclerView mResultsRecyclerView;
     private SearchView mSearchView;
+    private LinearLayout mNoResultsView;
 
     @VisibleForTesting
     final RecyclerView.OnScrollListener mScrollListener =
@@ -118,6 +120,8 @@
         super.onCreate(savedInstanceState);
         setHasOptionsMenu(true);
         mSearchAdapter = new SearchResultsAdapter(this);
+        
+        mSearchFeatureProvider.initFeedbackButton();
 
         final LoaderManager loaderManager = getLoaderManager();
 
@@ -155,6 +159,8 @@
         mResultsRecyclerView.setAdapter(mSearchAdapter);
         mResultsRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
         mResultsRecyclerView.addOnScrollListener(mScrollListener);
+
+        mNoResultsView = (LinearLayout) view.findViewById(R.id.no_results_layout);
         return view;
     }
 
@@ -184,16 +190,26 @@
         if (TextUtils.equals(query, mQuery)) {
             return true;
         }
+
+        final boolean isEmptyQuery = TextUtils.isEmpty(query);
+
+        // Hide no-results-view when the new query is not a super-string of the previous
+        if ((mQuery != null) && (mNoResultsView.getVisibility() == View.VISIBLE)
+                && (query.length() < mQuery.length())) {
+            mNoResultsView.setVisibility(View.GONE);
+        }
+
         mResultClickCount = 0;
         mNeverEnteredQuery = false;
         mQuery = query;
         mSearchAdapter.clearResults();
 
-        if (TextUtils.isEmpty(mQuery)) {
+        if (isEmptyQuery) {
             final LoaderManager loaderManager = getLoaderManager();
             loaderManager.destroyLoader(LOADER_ID_DATABASE);
             loaderManager.destroyLoader(LOADER_ID_INSTALLED_APPS);
             loaderManager.restartLoader(LOADER_ID_RECENTS, null /* args */, this /* callback */);
+            mSearchFeatureProvider.hideFeedbackButton();
         } else {
             restartLoaders();
         }
@@ -232,7 +248,12 @@
         mSearchAdapter.addResultsToMap(data, loader.getClass().getName());
 
         if (mUnfinishedLoadersCount.decrementAndGet() == 0) {
-            mSearchAdapter.mergeResults();
+            final int resultCount = mSearchAdapter.mergeResults();
+            mSearchFeatureProvider.showFeedbackButton(this, getView());
+
+            if (resultCount == 0) {
+                mNoResultsView.setVisibility(View.VISIBLE);
+            }
         }
     }
 
@@ -257,6 +278,14 @@
         loaderManager.restartLoader(LOADER_ID_INSTALLED_APPS, null /* args */, this /* callback */);
     }
 
+    public String getQuery() {
+        return mQuery;
+    }
+
+    public List<SearchResult> getSearchResults() {
+        return mSearchAdapter.getSearchResults();
+    }
+
     @VisibleForTesting (otherwise = VisibleForTesting.PRIVATE)
     SearchView makeSearchView(ActionBar actionBar, String query) {
         final SearchView searchView = new SearchView(actionBar.getThemedContext());
@@ -304,4 +333,4 @@
 
         }
     }
-}
+}
\ No newline at end of file
diff --git a/src/com/android/settings/search2/SearchResultsAdapter.java b/src/com/android/settings/search2/SearchResultsAdapter.java
index 5151b64..b76958a 100644
--- a/src/com/android/settings/search2/SearchResultsAdapter.java
+++ b/src/com/android/settings/search2/SearchResultsAdapter.java
@@ -106,8 +106,10 @@
     /**
      * Merge the results from each of the loaders into one list for the adapter.
      * Prioritizes results from the local database over installed apps.
+     *
+     * @return Number of matched results
      */
-    public void mergeResults() {
+    public int mergeResults() {
         final List<? extends SearchResult> databaseResults = mResultsMap
                 .get(DatabaseResultLoader.class.getName());
         final List<? extends SearchResult> installedAppResults = mResultsMap
@@ -139,6 +141,8 @@
 
         mSearchResults.addAll(results);
         notifyDataSetChanged();
+
+        return mSearchResults.size();
     }
 
     public void clearResults() {
diff --git a/src/com/android/settings/widget/MasterSwitchPreference.java b/src/com/android/settings/widget/MasterSwitchPreference.java
index ba3458a..84f1532 100644
--- a/src/com/android/settings/widget/MasterSwitchPreference.java
+++ b/src/com/android/settings/widget/MasterSwitchPreference.java
@@ -20,7 +20,8 @@
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceViewHolder;
 import android.util.AttributeSet;
-import android.widget.CompoundButton;
+import android.view.View;
+import android.view.View.OnClickListener;
 import android.widget.Switch;
 import android.widget.TextView;
 
@@ -61,21 +62,24 @@
     @Override
     public void onBindViewHolder(PreferenceViewHolder holder) {
         super.onBindViewHolder(holder);
-        mSwitch = (Switch) holder.itemView.findViewById(R.id.switchWidget);
-        if (mSwitch != null) {
-            mSwitch.setChecked(mChecked);
-            mSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+        final View widgetView = holder.itemView.findViewById(android.R.id.widget_frame);
+        if (widgetView != null) {
+            widgetView.setOnClickListener(new OnClickListener() {
                 @Override
-                public void onCheckedChanged(CompoundButton button, boolean isChecked) {
-                    if (!callChangeListener(isChecked)) {
-                        button.setChecked(!isChecked);
+                public void onClick(View v) {
+                    setChecked(!mChecked);
+                    if (!callChangeListener(mChecked)) {
+                        setChecked(!mChecked);
                     } else {
-                        persistBoolean(isChecked);
-                        mChecked = isChecked;
+                        persistBoolean(mChecked);
                     }
                 }
             });
         }
+        mSwitch = (Switch) holder.itemView.findViewById(R.id.switchWidget);
+        if (mSwitch != null) {
+            mSwitch.setChecked(mChecked);
+        }
         if (mMultiLine) {
             TextView textView = (TextView)holder.findViewById(android.R.id.title);
             if (textView != null) {
diff --git a/tests/robotests/src/com/android/settings/display/BatteryPercentagePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/BatteryPercentagePreferenceControllerTest.java
new file mode 100644
index 0000000..792b853
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/display/BatteryPercentagePreferenceControllerTest.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2016 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.display;
+
+import static android.provider.Settings.System.SHOW_BATTERY_PERCENT;
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.provider.Settings;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class BatteryPercentagePreferenceControllerTest {
+    @Mock private Context mContext;
+    private BatteryPercentagePreferenceController mController;
+
+    @Before
+    public void setup() {
+        MockitoAnnotations.initMocks(this);
+        mController = new BatteryPercentagePreferenceController(mContext);
+    }
+
+    private int getPercentageSetting() {
+        return Settings.System.getInt(mContext.getContentResolver(), SHOW_BATTERY_PERCENT, 0);
+    }
+
+    @Test
+    public void testOnPreferenceChange_TurnOnPercentage_PercentageOn() {
+        mController.onPreferenceChange(null, true);
+        final int isOn = getPercentageSetting();
+        assertThat(isOn).isEqualTo(1);
+    }
+
+    @Test
+    public void testOnPreferenceChange_TurnOffPercentage_PercentageOff() {
+        mController.onPreferenceChange(null, false);
+        final int isOn = getPercentageSetting();
+        assertThat(isOn).isEqualTo(0);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/search/SearchAdapterTest.java b/tests/robotests/src/com/android/settings/search/SearchResultsAdapterTest.java
similarity index 97%
rename from tests/robotests/src/com/android/settings/search/SearchAdapterTest.java
rename to tests/robotests/src/com/android/settings/search/SearchResultsAdapterTest.java
index fdcea6f..6100050 100644
--- a/tests/robotests/src/com/android/settings/search/SearchAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/search/SearchResultsAdapterTest.java
@@ -60,7 +60,7 @@
 
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class SearchAdapterTest {
+public class SearchResultsAdapterTest {
 
     @Mock
     private SearchFragment mFragment;
@@ -114,7 +114,7 @@
                 InstalledAppResultLoader.class.getName());
         mAdapter.addResultsToMap(getDummyDbResults(),
                 DatabaseResultLoader.class.getName());
-        mAdapter.mergeResults();
+        int count = mAdapter.mergeResults();
 
         List<SearchResult> results = mAdapter.getSearchResults();
         assertThat(results.get(0).title).isEqualTo("alpha");
@@ -123,6 +123,7 @@
         assertThat(results.get(3).title).isEqualTo("bravo");
         assertThat(results.get(4).title).isEqualTo("appCharlie");
         assertThat(results.get(5).title).isEqualTo("Charlie");
+        assertThat(count).isEqualTo(6);
     }
 
     private List<SearchResult> getDummyDbResults() {
diff --git a/tests/robotests/src/com/android/settings/search2/DatabaseResultLoaderTest.java b/tests/robotests/src/com/android/settings/search2/DatabaseResultLoaderTest.java
index 72c658f..8b97a91 100644
--- a/tests/robotests/src/com/android/settings/search2/DatabaseResultLoaderTest.java
+++ b/tests/robotests/src/com/android/settings/search2/DatabaseResultLoaderTest.java
@@ -67,7 +67,6 @@
     private final String summaryOne = "summaryOne";
     private final String summaryTwo = "summaryTwo";
     private final String summaryThree = "summaryThree";
-    private final String summaryFour = "summaryFour";
 
     SQLiteDatabase mDb;
 
diff --git a/tests/robotests/src/com/android/settings/search2/SearchFragmentTest.java b/tests/robotests/src/com/android/settings/search2/SearchFragmentTest.java
index 15b3a67..6a61f52 100644
--- a/tests/robotests/src/com/android/settings/search2/SearchFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/search2/SearchFragmentTest.java
@@ -16,10 +16,13 @@
 
 package com.android.settings.search2;
 
+import android.app.LoaderManager;
+
 import android.content.Context;
 import android.content.Loader;
 import android.os.Bundle;
 
+import android.view.View;
 import com.android.internal.logging.nano.MetricsProto;
 import com.android.settings.R;
 import com.android.settings.SettingsRobolectricTestRunner;
@@ -42,6 +45,7 @@
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyString;
 import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.times;
@@ -241,4 +245,52 @@
 
         verify(fragment, times(2)).onLoadFinished(any(Loader.class), any(List.class));
     }
+
+    @Test
+    public void whenNoQuery_HideFeedbackIsCalled() {
+        when(mFeatureFactory.searchFeatureProvider
+                .getDatabaseSearchLoader(any(Context.class), anyString()))
+                .thenReturn(new MockDBLoader(RuntimeEnvironment.application));
+        when(mFeatureFactory.searchFeatureProvider
+                .getInstalledAppSearchLoader(any(Context.class), anyString()))
+                .thenReturn(new MockAppLoader(RuntimeEnvironment.application));
+
+        ActivityController<SearchActivity> activityController =
+                Robolectric.buildActivity(SearchActivity.class);
+        activityController.setup();
+        SearchFragment fragment = (SearchFragment) spy(activityController.get().getFragmentManager()
+                .findFragmentById(R.id.main_content));
+
+        when(fragment.getLoaderManager()).thenReturn(mock(LoaderManager.class));
+
+        fragment.onQueryTextChange("");
+
+        Robolectric.flushForegroundThreadScheduler();
+
+        verify(mFeatureFactory.searchFeatureProvider).hideFeedbackButton();
+    }
+
+    @Test
+    public void onLoadFinished_ShowsFeedback() {
+
+        when(mFeatureFactory.searchFeatureProvider
+                .getDatabaseSearchLoader(any(Context.class), anyString()))
+                .thenReturn(new MockDBLoader(RuntimeEnvironment.application));
+        when(mFeatureFactory.searchFeatureProvider
+                .getInstalledAppSearchLoader(any(Context.class), anyString()))
+                .thenReturn(new MockAppLoader(RuntimeEnvironment.application));
+
+        ActivityController<SearchActivity> activityController =
+                Robolectric.buildActivity(SearchActivity.class);
+        activityController.setup();
+        SearchFragment fragment = (SearchFragment) spy(activityController.get().getFragmentManager()
+                .findFragmentById(R.id.main_content));
+
+        fragment.onQueryTextChange("non-empty");
+
+        Robolectric.flushForegroundThreadScheduler();
+
+        verify(mFeatureFactory.searchFeatureProvider).showFeedbackButton(any(SearchFragment.class),
+                any(View.class));
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/widget/MasterSwitchPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/MasterSwitchPreferenceTest.java
index 8cf3389..7d2e240 100644
--- a/tests/robotests/src/com/android/settings/widget/MasterSwitchPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/widget/MasterSwitchPreferenceTest.java
@@ -21,7 +21,10 @@
 import android.support.v7.preference.PreferenceViewHolder;
 import android.support.v7.preference.Preference.OnPreferenceChangeListener;
 import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
 import android.widget.CompoundButton.OnCheckedChangeListener;
+import android.widget.LinearLayout;
 import android.widget.Switch;
 
 import com.android.settings.R;
@@ -92,31 +95,39 @@
     }
 
     @Test
-    public void toggleButtonOn_shouldNotifyChecked() {
+    public void clickWidgetView_shouldToggleButton() {
         final MasterSwitchPreference preference = new MasterSwitchPreference(mContext);
+        final LayoutInflater inflater = LayoutInflater.from(mContext);
         final PreferenceViewHolder holder = new PreferenceViewHolder(
-            LayoutInflater.from(mContext).inflate(R.layout.preference_widget_master_switch, null));
+            inflater.inflate(R.layout.preference_master_switch, null));
+        final LinearLayout widgetView = holder.itemView.findViewById(android.R.id.widget_frame);
+        inflater.inflate(R.layout.preference_widget_master_switch, widgetView, true);
         final Switch toggle = (Switch) holder.itemView.findViewById(R.id.switchWidget);
-        final OnPreferenceChangeListener listener = mock(OnPreferenceChangeListener.class);
-        preference.setOnPreferenceChangeListener(listener);
         preference.onBindViewHolder(holder);
 
-        toggle.setChecked(true);
-        verify(listener).onPreferenceChange(preference, true);
+        widgetView.performClick();
+        assertThat(toggle.isChecked()).isTrue();
+
+        widgetView.performClick();
+        assertThat(toggle.isChecked()).isFalse();
     }
 
     @Test
-    public void toggleButtonOff_shouldNotifyUnchecked() {
+    public void clickWidgetView_shouldNotifyPreferenceChanged() {
         final MasterSwitchPreference preference = new MasterSwitchPreference(mContext);
         final PreferenceViewHolder holder = new PreferenceViewHolder(
-            LayoutInflater.from(mContext).inflate(R.layout.preference_widget_master_switch, null));
-        final Switch toggle = (Switch) holder.itemView.findViewById(R.id.switchWidget);
+            LayoutInflater.from(mContext).inflate(R.layout.preference_master_switch, null));
+        final View widgetView = holder.itemView.findViewById(android.R.id.widget_frame);
         final OnPreferenceChangeListener listener = mock(OnPreferenceChangeListener.class);
-        preference.setChecked(true);
         preference.setOnPreferenceChangeListener(listener);
         preference.onBindViewHolder(holder);
 
-        toggle.setChecked(false);
+        preference.setChecked(false);
+        widgetView.performClick();
+        verify(listener).onPreferenceChange(preference, true);
+
+        preference.setChecked(true);
+        widgetView.performClick();
         verify(listener).onPreferenceChange(preference, false);
     }
 
@@ -134,7 +145,7 @@
     }
 
     @Test
-    public void setDisabledByAdmin_noEnforcedAdmin_shouldEnaableButton() {
+    public void setDisabledByAdmin_noEnforcedAdmin_shouldEnableButton() {
         final MasterSwitchPreference preference = new MasterSwitchPreference(mContext);
         final PreferenceViewHolder holder = new PreferenceViewHolder(
             LayoutInflater.from(mContext).inflate(R.layout.preference_widget_master_switch, null));