Merge "Call super.onDestroy in ResetNetworkConfirm fragment"
diff --git a/res/layout/battery_saver_settings_button.xml b/res/layout/battery_saver_settings_button.xml
new file mode 100644
index 0000000..015d4d8
--- /dev/null
+++ b/res/layout/battery_saver_settings_button.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2018 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.
+  -->
+
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="horizontal"
+    android:gravity="bottom"
+    android:paddingStart="72dp"
+    android:paddingEnd="72dp"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <Button
+        android:id="@+id/battery_saver_on_button"
+        style="@style/ActionPrimaryButton"
+        android:layout_width="0dp"
+        android:layout_weight="1"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:text="@string/battery_saver_button_turn_on"
+        android:paddingEnd="8dp" />
+
+    <Button
+        android:id="@+id/battery_saver_off_button"
+        style="@style/ActionSecondaryButton"
+        android:layout_width="0dp"
+        android:layout_weight="1"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:text="@string/battery_saver_button_turn_off"
+        android:paddingEnd="8dp" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/search_feedback.xml b/res/layout/preference_widget_gear_no_bg.xml
similarity index 64%
rename from res/layout/search_feedback.xml
rename to res/layout/preference_widget_gear_no_bg.xml
index cdb0545..89d34d4 100644
--- a/res/layout/search_feedback.xml
+++ b/res/layout/preference_widget_gear_no_bg.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 The Android Open Source Project
+<!-- Copyright (C) 2018 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.
@@ -14,10 +14,14 @@
      limitations under the License.
 -->
 
-<View
+<!-- Settings button -->
+<ImageView
     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>
+    android:id="@+id/settings_button"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:layout_gravity="center"
+    android:scaleType="center"
+    android:src="@drawable/ic_settings"
+    android:contentDescription="@string/settings_button" />
+
diff --git a/res/layout/search_inline_switch_item.xml b/res/layout/search_inline_switch_item.xml
deleted file mode 100644
index 8f050a3..0000000
--- a/res/layout/search_inline_switch_item.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-
-<LinearLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:minHeight="?android:attr/listPreferredItemHeight"
-    android:paddingTop="16dp"
-    android:paddingBottom="16dp"
-    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
-    android:background="?android:attr/selectableItemBackground"
-    android:clipToPadding="false">
-
-    <include layout="@layout/search_icon_view"/>
-
-    <LinearLayout
-        android:layout_width="0dp"
-        android:layout_height="wrap_content"
-        android:layout_weight="1"
-        android:orientation="vertical">
-
-        <TextView
-            android:id="@android:id/title"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:singleLine="true"
-            android:textAppearance="?android:attr/textAppearanceListItem"
-            android:ellipsize="marquee"/>
-
-        <TextView
-            android:id="@android:id/summary"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:singleLine="true"
-            android:textAppearance="?android:attr/textAppearanceListItemSecondary"/>
-
-        <include layout="@layout/search_breadcrumb_view"/>
-    </LinearLayout>
-
-    <Switch
-        android:id="@+id/switchView"
-        android:layout_width="wrap_content"
-        android:layout_height="match_parent"
-        android:gravity="top"
-        android:paddingStart="16dp"/>
-</LinearLayout>
diff --git a/res/layout/search_intent_item.xml b/res/layout/search_intent_item.xml
deleted file mode 100644
index 6bc00ad..0000000
--- a/res/layout/search_intent_item.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-
-<LinearLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:minHeight="?android:attr/listPreferredItemHeight"
-    android:paddingTop="16dp"
-    android:paddingBottom="16dp"
-    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
-    android:background="?android:attr/selectableItemBackground"
-    android:clipToPadding="false">
-
-    <include layout="@layout/search_icon_view"/>
-
-    <LinearLayout
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_weight="1"
-        android:orientation="vertical">
-
-        <TextView
-            android:id="@android:id/title"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:singleLine="true"
-            android:textAppearance="?android:attr/textAppearanceListItem"
-            android:ellipsize="marquee"/>
-
-        <TextView
-            android:id="@android:id/summary"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:singleLine="true"
-            android:textAppearance="?android:attr/textAppearanceListItemSecondary"
-            android:ellipsize="marquee"/>
-
-        <include layout="@layout/search_breadcrumb_view"/>
-    </LinearLayout>
-</LinearLayout>
diff --git a/res/layout/search_panel.xml b/res/layout/search_panel.xml
deleted file mode 100644
index 10c2a00..0000000
--- a/res/layout/search_panel.xml
+++ /dev/null
@@ -1,107 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-<LinearLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:id="@+id/search_panel"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:orientation="vertical">
-
-    <FrameLayout
-        android:id="@+id/search_bar_container"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:background="@color/suggestion_condition_background">
-        <android.support.v7.widget.CardView
-            android:id="@+id/search_bar"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_margin="@dimen/search_bar_margin"
-            app:cardCornerRadius="2dp"
-            app:cardBackgroundColor="?android:attr/colorBackground"
-            app:cardElevation="2dp">
-            <Toolbar
-                android:id="@+id/search_toolbar"
-                android:layout_width="match_parent"
-                android:layout_height="@dimen/search_bar_height"
-                android:background="?android:attr/selectableItemBackground"
-                android:contentInsetStart="0dp"
-                android:contentInsetStartWithNavigation="0dp"
-                android:theme="?android:attr/actionBarTheme">
-                <SearchView
-                    android:id="@+id/search_view"
-                    android:layout_width="match_parent"
-                    android:layout_height="match_parent"
-                    android:iconifiedByDefault="false"
-                    android:imeOptions="actionSearch|flagNoExtractUi"
-                    android:searchIcon="@null"/>
-            </Toolbar>
-        </android.support.v7.widget.CardView>
-    </FrameLayout>
-
-    <FrameLayout
-        android:id="@+id/layout_results"
-        android:layout_width="match_parent"
-        android:layout_height="0dp"
-        android:layout_weight="1"
-        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="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"/>
-
-        <LinearLayout
-            android:id="@+id/no_results_layout"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:paddingTop="35dp"
-            android:orientation="vertical"
-            android:visibility="gone">
-
-            <Space
-                android:layout_width="match_parent"
-                android:layout_height="?android:attr/actionBarSize"/>
-
-            <ImageView
-                android:layout_height="wrap_content"
-                android:layout_width="wrap_content"
-                android:layout_gravity="center_horizontal"
-                android:src="@drawable/empty_search_results"/>
-
-            <TextView
-                android:layout_height="wrap_content"
-                android:layout_width="match_parent"
-                android:paddingTop="24dp"
-                android:textSize="18sp"
-                android:text="@string/search_settings_no_results"
-                android:gravity="center"/>
-
-        </LinearLayout>
-
-    </FrameLayout>
-
-    <include layout="@layout/search_feedback"/>
-
-</LinearLayout>
diff --git a/res/layout/settings_main_dashboard.xml b/res/layout/settings_main_dashboard.xml
index 4f8c308..10ff2ee 100644
--- a/res/layout/settings_main_dashboard.xml
+++ b/res/layout/settings_main_dashboard.xml
@@ -43,7 +43,6 @@
                 android:background="?android:attr/selectableItemBackground"
                 android:contentInsetStartWithNavigation="64dp"
                 android:navigationIcon="@drawable/ic_search_24dp"
-                android:navigationContentDescription="@string/search_menu"
                 android:theme="?android:attr/actionBarTheme">
                 <TextView
                     android:id="@+id/search_action_bar_title"
diff --git a/res/values-sw400dp/dimens.xml b/res/values-sw400dp/dimens.xml
index 8d45dd4..6a02422 100755
--- a/res/values-sw400dp/dimens.xml
+++ b/res/values-sw400dp/dimens.xml
@@ -23,8 +23,6 @@
     <dimen name="support_escalation_card_padding_end">56dp</dimen>
 
     <!-- Suggestion cards-->
-    <dimen name="suggestion_card_width_one_card">384dp</dimen>
-    <dimen name="suggestion_card_width_two_cards">188dp</dimen>
     <dimen name="suggestion_card_width_multiple_cards">180dp</dimen>
     <dimen name="suggestion_card_padding_bottom_one_card">22dp</dimen>
 
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index fbc7490..6ede7c6 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -304,8 +304,6 @@
 
     <!-- Suggestion cards size and padding -->
     <dimen name="suggestion_card_icon_size">24dp</dimen>
-    <dimen name="suggestion_card_width_one_card">332dp</dimen>
-    <dimen name="suggestion_card_width_two_cards">162dp</dimen>
     <dimen name="suggestion_card_width_multiple_cards">156dp</dimen>
     <dimen name="suggestion_card_outer_margin">14dp</dimen>
     <dimen name="suggestion_card_inner_margin">12dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 3e9d716..35bc32e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2423,13 +2423,6 @@
 
     <!-- Main Settings screen, setting option name to go into search settings -->
     <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>
-
-    <!-- Button to clear all search history in Settings [CHAR LIMIT=40]-->
-    <string name="search_clear_history">Clear history</string>
 
     <!-- Display settings --><skip/>
     <!-- Sound & display settings screen, section header for settings related to display -->
@@ -4431,6 +4424,12 @@
     <string name="accessibility_autoclick_preference_title">Click after pointer stops moving</string>
     <!-- Title for accessibility preference for configuring amount of time that has to pass after pointer stops moving before click action can be performed (if automatic click after pointer stops moving feature is enabled). [CHAR LIMIT=NONE] -->
     <string name="accessibility_autoclick_delay_preference_title">Delay before click</string>
+    <!-- Title for accessibility preference screen for configuring vibrations. -->
+    <string name="accessibility_vibration_settings_title">Vibration</string>
+    <!-- Title for accessibility preference for configuring notification vibrations. -->
+    <string name="accessibility_notification_vibration_title">Ring &amp; notification vibration</string>
+    <!-- Title for accessibility preference for configuring touch feedback vibrations. -->
+    <string name="accessibility_touch_vibration_title">Touch vibration</string>
     <!-- Used in the acessibilty service settings to control turning on/off the service entirely -->
     <string name="accessibility_service_master_switch_title">Use service</string>
     <!-- Used in the Color correction settings screen to control turning on/off the feature entirely -->
@@ -4474,6 +4473,30 @@
         <item quantity="other">Very long delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
     </plurals>
 
+    <!-- Summary for vibration settings preference when ring & notification are set to off-->
+    <string name="accessibility_vibration_summary_off">Ring &amp; notification set to off</string>
+
+    <!-- Summary for vibration settings preference when ring & notification are set to low-->
+    <string name="accessibility_vibration_summary_low">Ring &amp; notification set to low</string>
+
+    <!-- Summary for vibration settings preference when ring & notification are set to medium-->
+    <string name="accessibility_vibration_summary_medium">Ring &amp; notification set to medium</string>
+
+    <!-- Summary for vibration settings preference when ring & notification are set to high-->
+    <string name="accessibility_vibration_summary_high">Ring &amp; notification set to high</string>
+
+    <!-- Label describing an option turning vibrations off. [CHAR LIMIT=15] -->
+    <string name="accessibility_vibration_intensity_off">Off</string>
+
+    <!-- Label describing a low intensity vibration option. [CHAR LIMIT=15] -->
+    <string name="accessibility_vibration_intensity_low">Low</string>
+
+    <!-- Label describing a medium intensity vibration option. [CHAR LIMIT=15] -->
+    <string name="accessibility_vibration_intensity_medium">Medium</string>
+
+    <!-- Label describing a high intensity vibration option. [CHAR LIMIT=15] -->
+    <string name="accessibility_vibration_intensity_high">High</string>
+
     <!-- Title for accessibility menu item to lauch a settings activity. [CHAR LIMIT=15] -->
     <string name="accessibility_menu_item_settings">Settings</string>
 
@@ -5136,8 +5159,17 @@
     <!-- Label for dex2oat process in battery usage used for the optimization of one or more apps -->
     <string name="process_dex2oat_label">App optimization</string>
 
-    <!-- [CHAR_LIMIT=40] Battery saver: Label for feature, title + menu item -->
-    <string name="battery_saver">Battery Saver</string>
+    <!-- Battery saver: Label for feature, title + menu item [CHAR_LIMIT=40] -->
+    <string name="battery_saver">Reduced power mode</string>
+
+    <!-- Battery saver: Label for preference to turn on battery saver automatically when battery is low [CHAR_LIMIT=40] -->
+    <string name="battery_saver_auto_title">Schedule</string>
+
+    <!-- Battery saver: Summary for preference to turn on battery saver automatically when battery is low [CHAR_LIMIT=40] -->
+    <string name="battery_saver_auto_summary">Turn on Reduced power mode automatically when battery is low</string>
+
+    <!-- Battery saver: Label for seekbar to change battery saver threshold [CHAR_LIMIT=40] -->
+    <string name="battery_saver_seekbar_title">Turn on automatically at <xliff:g id="percent">%1$s</xliff:g></string>
 
     <!-- Used in the Battery Saver settings screen to control turning on/off the feature entirely -->
     <string name="battery_saver_master_switch_title">Use Battery Saver</string>
@@ -8478,7 +8510,7 @@
     <!-- Summary of condition that airplane mode is on [CHAR LIMIT=NONE] -->
     <string name="condition_airplane_summary">Wi-Fi, Bluetooth, and mobile network are turned off. You can\'t make phone calls or connect to the internet.</string>
 
-    <!-- Title of condition that do not disturb is on [CHAR LIMIT=30] -->
+    <!-- Title of condition that do not disturb is on [CHAR LIMIT=36] -->
     <string name="condition_zen_title">Do Not Disturb is on</string>
 
     <!-- Title of condition that battery saver is on [CHAR LIMIT=30] -->
@@ -8710,6 +8742,12 @@
     <!-- [CHAR_LIMIT=NONE] Battery saver: Description for automatic entry option: pct% battery -->
     <string name="battery_saver_desc_turn_on_auto_pct">Turn on automatically at %1$s battery</string>
 
+    <!--  Battery saver: Label for button that will turn on battery saver. [CHAR LIMIT=30] -->
+    <string name="battery_saver_button_turn_on">Turn on now</string>
+
+    <!--  Battery saver: Label for button that will turn off battery saver. [CHAR LIMIT=30] -->
+    <string name="battery_saver_button_turn_off">Turn off now</string>
+
     <!-- [CHAR_LIMIT=NONE] Label for when app is ignoring battery optimizations -->
     <string name="not_battery_optimizing">Not using battery optimization</string>
 
@@ -9264,6 +9302,9 @@
     <!-- Help URI, USB Audio [DO NOT TRANSLATE] -->
     <string name="help_url_audio_accessory_not_supported" translatable="false"></string>
 
+    <!-- Help URI, battery saver page [DO NOT TRANSLATE] -->
+    <string name="help_url_battery_saver_settings" translatable="false"></string>
+
     <!-- Title label for new device suggestion, which is displayed in Settings homepage [CHAR LIMIT=100] -->
     <string name="new_device_suggestion_title">What\'s new and exciting?</string>
 
diff --git a/res/layout/search_breadcrumb_view.xml b/res/xml/accessibility_notification_vibration_settings.xml
similarity index 63%
copy from res/layout/search_breadcrumb_view.xml
copy to res/xml/accessibility_notification_vibration_settings.xml
index 08a2651..b37d363 100644
--- a/res/layout/search_breadcrumb_view.xml
+++ b/res/xml/accessibility_notification_vibration_settings.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-  Copyright (C) 2017 The Android Open Source Project
+  Copyright (C) 2018 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.
@@ -15,12 +15,6 @@
   limitations under the License.
   -->
 
-<TextView
+<PreferenceScreen
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/breadcrumb"
-    android:layout_width="wrap_content"
-    android:layout_height="wrap_content"
-    android:paddingTop="5dp"
-    android:textAppearance="?android:attr/textAppearanceListItemSecondary"
-    android:textColor="?android:attr/textColorSecondary"
-    android:ellipsize="marquee"/>
+    android:title="@string/accessibility_notification_vibration_title" />
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index b5da848..060868e 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -93,6 +93,12 @@
                 android:entries="@array/long_press_timeout_selector_titles"
                 android:entryValues="@array/long_press_timeout_selector_values"
                 android:persistent="false"/>
+
+        <Preference
+            android:fragment="com.android.settings.accessibility.VibrationSettings"
+            android:key="vibration_preference_screen"
+            android:title="@string/accessibility_vibration_settings_title" />
+
     </PreferenceCategory>
 
     <PreferenceCategory
diff --git a/res/layout/search_breadcrumb_view.xml b/res/xml/accessibility_touch_vibration_settings.xml
similarity index 63%
rename from res/layout/search_breadcrumb_view.xml
rename to res/xml/accessibility_touch_vibration_settings.xml
index 08a2651..ed8f550 100644
--- a/res/layout/search_breadcrumb_view.xml
+++ b/res/xml/accessibility_touch_vibration_settings.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-  Copyright (C) 2017 The Android Open Source Project
+  Copyright (C) 2018 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.
@@ -15,12 +15,6 @@
   limitations under the License.
   -->
 
-<TextView
+<PreferenceScreen
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/breadcrumb"
-    android:layout_width="wrap_content"
-    android:layout_height="wrap_content"
-    android:paddingTop="5dp"
-    android:textAppearance="?android:attr/textAppearanceListItemSecondary"
-    android:textColor="?android:attr/textColorSecondary"
-    android:ellipsize="marquee"/>
+    android:title="@string/accessibility_touch_vibration_title" />
diff --git a/res/xml/accessibility_vibration_settings.xml b/res/xml/accessibility_vibration_settings.xml
new file mode 100644
index 0000000..d61454d
--- /dev/null
+++ b/res/xml/accessibility_vibration_settings.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 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.
+-->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+        android:key="accessibility_settings_screen"
+        android:title="@string/accessibility_vibration_settings_title"
+        android:persistent="true">
+
+    <Preference
+        android:fragment="com.android.settings.accessibility.NotificationVibrationPreferenceFragment"
+        android:key="notification_vibration_preference_screen"
+        android:title="@string/accessibility_notification_vibration_title" />
+
+    <Preference
+        android:fragment="com.android.settings.accessibility.TouchVibrationPreferenceFragment"
+        android:key="touch_vibration_preference_screen"
+        android:title="@string/accessibility_touch_vibration_title" />
+</PreferenceScreen>
diff --git a/res/xml/battery_saver_settings.xml b/res/xml/battery_saver_settings.xml
index 1720c73..47199c2 100644
--- a/res/xml/battery_saver_settings.xml
+++ b/res/xml/battery_saver_settings.xml
@@ -14,14 +14,32 @@
      limitations under the License.
 -->
 
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
-        android:title="@string/battery_saver"
-        android:key="battery_saver">
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:title="@string/battery_saver"
+    android:key="battery_saver">
 
     <!-- Turn on automatically -->
-    <DropDownPreference
-            android:key="turn_on_automatically"
-            android:title="@string/battery_saver_turn_on_automatically_title"
-            android:summary="%s" />
+    <SwitchPreference
+        android:key="auto_battery_saver"
+        android:title="@string/battery_saver_auto_title"
+        android:summary="@string/battery_saver_auto_summary"/>
+    <com.android.settings.widget.SeekBarPreference
+        android:key="battery_saver_seek_bar"
+        android:title="@string/battery_saver_seekbar_title"
+        android:max="75"
+        android:min="5"/>
+    <com.android.settings.applications.LayoutPreference
+        android:key="battery_saver_button_container"
+        android:selectable="false"
+        android:layout="@layout/battery_saver_settings_button"/>
+
+    <PreferenceCategory
+        android:key="battery_saver_footer">
+        <com.android.settingslib.widget.FooterPreference
+            android:key="battery_saver_footer_preference"
+            android:title="@*android:string/battery_saver_description"
+            android:selectable="false"/>
+    </PreferenceCategory>
 
 </PreferenceScreen>
diff --git a/res/xml/power_usage_summary.xml b/res/xml/power_usage_summary.xml
index d7c3c39..fbe4e0d 100644
--- a/res/xml/power_usage_summary.xml
+++ b/res/xml/power_usage_summary.xml
@@ -23,7 +23,7 @@
 
     <com.android.settings.applications.LayoutPreference
         android:key="battery_header"
-        android:selectable="true"
+        android:selectable="false"
         android:layout="@layout/battery_header"/>
 
     <PreferenceCategory
@@ -34,7 +34,7 @@
         android:key="power_management">
 
         <com.android.settings.widget.MasterSwitchPreference
-            android:fragment="com.android.settings.fuelgauge.BatterySaverSettings"
+            android:fragment="com.android.settings.fuelgauge.batterysaver.BatterySaverSettings"
             android:key="battery_saver_summary"
             android:title="@string/battery_saver"/>
 
diff --git a/res/xml/power_usage_summary_legacy.xml b/res/xml/power_usage_summary_legacy.xml
index 0038cc0..059c737 100644
--- a/res/xml/power_usage_summary_legacy.xml
+++ b/res/xml/power_usage_summary_legacy.xml
@@ -51,7 +51,7 @@
         android:title="@string/battery_power_management">
 
         <com.android.settings.widget.MasterSwitchPreference
-            android:fragment="com.android.settings.fuelgauge.BatterySaverSettings"
+            android:fragment="com.android.settings.fuelgauge.batterysaver.BatterySaverSettings"
             android:key="battery_saver_summary"
             android:title="@string/battery_saver"/>
 
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 3c18efb..01818e9 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -16,6 +16,8 @@
 
 package com.android.settings;
 
+import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO;
+
 import android.app.ActionBar;
 import android.app.ActivityManager;
 import android.app.Fragment;
@@ -329,6 +331,7 @@
             // and goes to the search UI. Also set the background to null so there's no ripple.
             View navView = toolbar.getNavigationView();
             navView.setClickable(false);
+            navView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
             navView.setBackground(null);
         }
 
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index df8d4c8..7335bae 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -16,6 +16,8 @@
 
 package com.android.settings.accessibility;
 
+import static android.os.Vibrator.VibrationIntensity;
+
 import android.accessibilityservice.AccessibilityServiceInfo;
 import android.app.admin.DevicePolicyManager;
 import android.content.ComponentName;
@@ -28,6 +30,7 @@
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.UserHandle;
+import android.os.Vibrator;
 import android.provider.SearchIndexableResource;
 import android.provider.Settings;
 import android.support.annotation.VisibleForTesting;
@@ -111,6 +114,8 @@
             "tts_settings_preference";
     private static final String AUTOCLICK_PREFERENCE_SCREEN =
             "autoclick_preference_screen";
+    private static final String VIBRATION_PREFERENCE_SCREEN =
+            "vibration_preference_screen";
 
     @VisibleForTesting static final String TOGGLE_INVERSION_PREFERENCE =
             "toggle_inversion_preference";
@@ -215,6 +220,7 @@
     private Preference mAutoclickPreferenceScreen;
     private Preference mAccessibilityShortcutPreferenceScreen;
     private Preference mDisplayDaltonizerPreferenceScreen;
+    private Preference mVibrationPreferenceScreen;
     private SwitchPreference mToggleInversionPreference;
 
     private int mLongPressTimeoutDefault;
@@ -452,9 +458,11 @@
         // Display color adjustments.
         mDisplayDaltonizerPreferenceScreen = findPreference(DISPLAY_DALTONIZER_PREFERENCE_SCREEN);
 
-        // Accessibility shortcut
+        // Accessibility shortcut.
         mAccessibilityShortcutPreferenceScreen = findPreference(ACCESSIBILITY_SHORTCUT_PREFERENCE);
 
+        // Vibrations.
+        mVibrationPreferenceScreen = findPreference(VIBRATION_PREFERENCE_SCREEN);
     }
 
     private void updateAllPreferences() {
@@ -661,6 +669,8 @@
         mSelectLongPressTimeoutPreference.setValue(value);
         mSelectLongPressTimeoutPreference.setSummary(mLongPressTimeoutValueToTitleMap.get(value));
 
+        updateVibrationSummary(mVibrationPreferenceScreen);
+
         updateFeatureSummary(Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED,
                 mCaptioningPreferenceScreen);
         updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,
@@ -726,6 +736,29 @@
         pref.setSummary(entries[index]);
     }
 
+    private void updateVibrationSummary(Preference pref) {
+        Vibrator vibrator = getContext().getSystemService(Vibrator.class);
+        final int intensity = Settings.System.getInt(getContext().getContentResolver(),
+                Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
+                vibrator.getDefaultNotificationVibrationIntensity());
+        mVibrationPreferenceScreen.setSummary(getVibrationSummary(getContext(), intensity));
+    }
+
+    private String getVibrationSummary(Context context, @VibrationIntensity int intensity) {
+        switch (intensity) {
+            case Vibrator.VIBRATION_INTENSITY_OFF:
+                return context.getString(R.string.accessibility_vibration_summary_off);
+            case Vibrator.VIBRATION_INTENSITY_LOW:
+                return context.getString(R.string.accessibility_vibration_summary_low);
+            case Vibrator.VIBRATION_INTENSITY_MEDIUM:
+                return context.getString(R.string.accessibility_vibration_summary_medium);
+            case Vibrator.VIBRATION_INTENSITY_HIGH:
+                return context.getString(R.string.accessibility_vibration_summary_high);
+            default:
+                return "";
+        }
+    }
+
     private void updateLockScreenRotationCheckbox() {
         Context context = getActivity();
         if (context != null) {
diff --git a/src/com/android/settings/accessibility/NotificationVibrationPreferenceFragment.java b/src/com/android/settings/accessibility/NotificationVibrationPreferenceFragment.java
new file mode 100644
index 0000000..6340bb1
--- /dev/null
+++ b/src/com/android/settings/accessibility/NotificationVibrationPreferenceFragment.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2018 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.accessibility;
+
+import android.os.Vibrator;
+import android.provider.Settings;
+
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.R;
+
+/**
+ * Fragment for picking accessibility shortcut service
+ */
+public class NotificationVibrationPreferenceFragment extends VibrationPreferenceFragment {
+    @Override
+    public int getMetricsCategory() {
+        return MetricsEvent.ACCESSIBILITY_VIBRATION_NOTIFICATION;
+    }
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.accessibility_notification_vibration_settings;
+    }
+
+    /**
+     * Get the setting string of the vibration intensity setting this preference is dealing with.
+     */
+    @Override
+    protected String getVibrationIntensitySetting() {
+        return Settings.System.NOTIFICATION_VIBRATION_INTENSITY;
+    }
+
+    @Override
+    protected int getDefaultVibrationIntensity() {
+        Vibrator vibrator = getContext().getSystemService(Vibrator.class);
+        return vibrator.getDefaultNotificationVibrationIntensity();
+    }
+}
diff --git a/src/com/android/settings/accessibility/TouchVibrationPreferenceFragment.java b/src/com/android/settings/accessibility/TouchVibrationPreferenceFragment.java
new file mode 100644
index 0000000..ea36833
--- /dev/null
+++ b/src/com/android/settings/accessibility/TouchVibrationPreferenceFragment.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2018 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.accessibility;
+
+import android.graphics.drawable.Drawable;
+import android.os.Vibrator;
+import android.provider.Settings;
+
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.R;
+
+/**
+ * Fragment for picking accessibility shortcut service
+ */
+public class TouchVibrationPreferenceFragment extends VibrationPreferenceFragment {
+    @Override
+    public int getMetricsCategory() {
+        return MetricsEvent.ACCESSIBILITY_VIBRATION_TOUCH;
+    }
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.accessibility_touch_vibration_settings;
+    }
+
+    /**
+     * Get the setting string of the vibration intensity setting this preference is dealing with.
+     */
+    @Override
+    protected String getVibrationIntensitySetting() {
+        return Settings.System.HAPTIC_FEEDBACK_INTENSITY;
+    }
+
+    @Override
+    protected int getDefaultVibrationIntensity() {
+        Vibrator vibrator = getContext().getSystemService(Vibrator.class);
+        return vibrator.getDefaultHapticFeedbackIntensity();
+    }
+
+    @Override
+    public void onVibrationIntensitySelected(int intensity) {
+        // We want to keep HAPTIC_FEEDBACK_ENABLED consistent with this setting since some
+        // applications check it directly before triggering their own haptic feedback.
+        final boolean hapticFeedbackEnabled = !(intensity == Vibrator.VIBRATION_INTENSITY_OFF);
+        Settings.System.putInt(getContext().getContentResolver(),
+                Settings.System.HAPTIC_FEEDBACK_ENABLED, hapticFeedbackEnabled ? 1 : 0);
+    }
+}
diff --git a/src/com/android/settings/accessibility/VibrationPreferenceFragment.java b/src/com/android/settings/accessibility/VibrationPreferenceFragment.java
new file mode 100644
index 0000000..f81208f
--- /dev/null
+++ b/src/com/android/settings/accessibility/VibrationPreferenceFragment.java
@@ -0,0 +1,193 @@
+/*
+ * Copyright (C) 2018 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.accessibility;
+
+import static android.os.Vibrator.VibrationIntensity;
+
+import android.support.annotation.VisibleForTesting;
+import android.content.Context;
+import android.database.ContentObserver;
+import android.graphics.drawable.Drawable;
+import android.net.Uri;
+import android.os.Handler;
+import android.os.Vibrator;
+import android.provider.Settings;
+import android.util.ArrayMap;
+import android.util.Log;
+
+import com.android.internal.accessibility.AccessibilityShortcutController;
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.R;
+import com.android.settings.widget.RadioButtonPickerFragment;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Fragment for changing vibration settings.
+ */
+public abstract class VibrationPreferenceFragment extends RadioButtonPickerFragment {
+    private static final String TAG = "VibrationPreferenceFragment";
+
+    @VisibleForTesting
+    final static String KEY_INTENSITY_OFF = "intensity_off";
+    @VisibleForTesting
+    final static String KEY_INTENSITY_LOW = "intensity_low";
+    @VisibleForTesting
+    final static String KEY_INTENSITY_MEDIUM = "intensity_medium";
+    @VisibleForTesting
+    final static String KEY_INTENSITY_HIGH = "intensity_high";
+
+    private final Map<String, VibrationIntensityCandidateInfo> mCandidates;
+    private final SettingsObserver mSettingsObserver;
+
+    public VibrationPreferenceFragment() {
+        mCandidates = new ArrayMap<>();
+        mCandidates.put(KEY_INTENSITY_OFF,
+                new VibrationIntensityCandidateInfo(KEY_INTENSITY_OFF,
+                    R.string.accessibility_vibration_intensity_off,
+                    Vibrator.VIBRATION_INTENSITY_OFF));
+        mCandidates.put(KEY_INTENSITY_LOW,
+                new VibrationIntensityCandidateInfo(KEY_INTENSITY_LOW,
+                    R.string.accessibility_vibration_intensity_low,
+                    Vibrator.VIBRATION_INTENSITY_LOW));
+        mCandidates.put(KEY_INTENSITY_MEDIUM,
+                new VibrationIntensityCandidateInfo(KEY_INTENSITY_MEDIUM,
+                    R.string.accessibility_vibration_intensity_medium,
+                    Vibrator.VIBRATION_INTENSITY_MEDIUM));
+        mCandidates.put(KEY_INTENSITY_HIGH,
+                new VibrationIntensityCandidateInfo(KEY_INTENSITY_HIGH,
+                    R.string.accessibility_vibration_intensity_high,
+                    Vibrator.VIBRATION_INTENSITY_HIGH));
+        mSettingsObserver = new SettingsObserver();
+    }
+
+    @Override
+    public void onAttach(Context context) {
+        super.onAttach(context);
+        mSettingsObserver.register();
+    }
+
+    @Override
+    public void onDetach() {
+        super.onDetach();
+        mSettingsObserver.unregister();
+    }
+
+    /**
+     * Get the setting string of the vibration intensity setting this preference is dealing with.
+     */
+    protected abstract String getVibrationIntensitySetting();
+
+    /**
+     * Get the default intensity for the desired setting.
+     */
+    protected abstract int getDefaultVibrationIntensity();
+
+    /**
+     * When a new vibration intensity is selected by the user.
+     */
+    protected void onVibrationIntensitySelected(int intensity) { }
+
+    @Override
+    protected List<? extends CandidateInfo> getCandidates() {
+        List<VibrationIntensityCandidateInfo> candidates = new ArrayList<>(mCandidates.values());
+        candidates.sort(
+                Comparator.comparing(VibrationIntensityCandidateInfo::getIntensity).reversed());
+        return candidates;
+    }
+
+    @Override
+    protected String getDefaultKey() {
+        final int vibrationIntensity = Settings.System.getInt(getContext().getContentResolver(),
+                getVibrationIntensitySetting(), getDefaultVibrationIntensity());
+        for (VibrationIntensityCandidateInfo candidate : mCandidates.values()) {
+            if (candidate.getIntensity() == vibrationIntensity) {
+                return candidate.getKey();
+            }
+        }
+        return null;
+    }
+
+    @Override
+    protected boolean setDefaultKey(String key) {
+        VibrationIntensityCandidateInfo candidate = mCandidates.get(key);
+        if (candidate == null) {
+            Log.e(TAG, "Tried to set unknown intensity (key=" + key + ")!");
+            return false;
+        }
+        Settings.System.putInt(getContext().getContentResolver(),
+                getVibrationIntensitySetting(), candidate.getIntensity());
+        onVibrationIntensitySelected(candidate.getIntensity());
+        return true;
+    }
+
+    @VisibleForTesting
+    class VibrationIntensityCandidateInfo extends CandidateInfo {
+        private String mKey;
+        private int mLabelId;
+        @VibrationIntensity
+        private int mIntensity;
+
+        public VibrationIntensityCandidateInfo(String key, int labelId, int intensity) {
+            super(true /* enabled */);
+            mKey = key;
+            mLabelId = labelId;
+            mIntensity = intensity;
+        }
+
+        @Override
+        public CharSequence loadLabel() {
+            return getContext().getString(mLabelId);
+        }
+
+        @Override
+        public Drawable loadIcon() {
+            return null;
+        }
+
+        @Override
+        public String getKey() {
+            return mKey;
+        }
+
+        public int getIntensity() {
+            return mIntensity;
+        }
+    }
+
+    private class SettingsObserver extends ContentObserver {
+        public SettingsObserver() {
+            super(new Handler());
+        }
+
+        public void register() {
+            getContext().getContentResolver().registerContentObserver(
+                    Settings.System.getUriFor(getVibrationIntensitySetting()), false, this);
+        }
+
+        public void unregister() {
+            getContext().getContentResolver().unregisterContentObserver(this);
+        }
+
+        @Override
+        public void onChange(boolean selfChange, Uri uri) {
+            updateCandidates();
+        }
+    }
+}
diff --git a/src/com/android/settings/accessibility/VibrationSettings.java b/src/com/android/settings/accessibility/VibrationSettings.java
new file mode 100644
index 0000000..8aa4513
--- /dev/null
+++ b/src/com/android/settings/accessibility/VibrationSettings.java
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 2018 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.accessibility;
+
+import android.content.Context;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Vibrator;
+import android.provider.SearchIndexableResource;
+import android.provider.Settings;
+import android.support.annotation.VisibleForTesting;
+import android.support.v7.preference.Preference;
+
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Activity with the accessibility settings.
+ */
+public class VibrationSettings extends SettingsPreferenceFragment implements Indexable {
+
+    // Preferences
+    @VisibleForTesting
+    static final String NOTIFICATION_VIBRATION_PREFERENCE_SCREEN =
+            "notification_vibration_preference_screen";
+    @VisibleForTesting
+    static final String TOUCH_VIBRATION_PREFERENCE_SCREEN =
+            "touch_vibration_preference_screen";
+
+    private final Handler mHandler = new Handler();
+    private final SettingsContentObserver mSettingsContentObserver;
+
+    private Preference mNotificationVibrationPreferenceScreen;
+    private Preference mTouchVibrationPreferenceScreen;
+
+    public VibrationSettings() {
+        List<String> vibrationSettings = new ArrayList<>();
+        vibrationSettings.add(Settings.System.HAPTIC_FEEDBACK_INTENSITY);
+        vibrationSettings.add(Settings.System.NOTIFICATION_VIBRATION_INTENSITY);
+        mSettingsContentObserver = new SettingsContentObserver(mHandler, vibrationSettings) {
+            @Override
+            public void onChange(boolean selfChange, Uri uri) {
+                updatePreferences();
+            }
+        };
+    }
+
+    @Override
+    public int getMetricsCategory() {
+        return MetricsEvent.ACCESSIBILITY_VIBRATION;
+    }
+
+    @Override
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+        addPreferencesFromResource(R.xml.accessibility_vibration_settings);
+        initializePreferences();
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+        updatePreferences();
+        mSettingsContentObserver.register(getContentResolver());
+    }
+
+    @Override
+    public void onPause() {
+        mSettingsContentObserver.unregister(getContentResolver());
+        super.onPause();
+    }
+
+    private void initializePreferences() {
+        // Notification and notification vibration strength adjustments.
+        mNotificationVibrationPreferenceScreen =
+                findPreference(NOTIFICATION_VIBRATION_PREFERENCE_SCREEN);
+
+        // Touch feedback strength adjustments.
+        mTouchVibrationPreferenceScreen = findPreference(TOUCH_VIBRATION_PREFERENCE_SCREEN);
+    }
+
+    private void updatePreferences() {
+        updateNotificationVibrationSummary(mNotificationVibrationPreferenceScreen);
+        updateTouchVibrationSummary(mTouchVibrationPreferenceScreen);
+    }
+
+    private void updateNotificationVibrationSummary(Preference pref) {
+        Vibrator vibrator = getContext().getSystemService(Vibrator.class);
+        final int intensity = Settings.System.getInt(getContext().getContentResolver(),
+                Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
+                vibrator.getDefaultNotificationVibrationIntensity());
+        CharSequence summary = getVibrationIntensitySummary(getContext(), intensity);
+        mNotificationVibrationPreferenceScreen.setSummary(summary);
+    }
+
+    private void updateTouchVibrationSummary(Preference pref) {
+        Vibrator vibrator = getContext().getSystemService(Vibrator.class);
+        final int intensity = Settings.System.getInt(getContext().getContentResolver(),
+                Settings.System.HAPTIC_FEEDBACK_INTENSITY,
+                vibrator.getDefaultHapticFeedbackIntensity());
+        CharSequence summary = getVibrationIntensitySummary(getContext(), intensity);
+        mTouchVibrationPreferenceScreen.setSummary(summary);
+    }
+
+    public static String getVibrationIntensitySummary(Context context, int intensity) {
+        switch (intensity) {
+            case Vibrator.VIBRATION_INTENSITY_OFF:
+                return context.getString(R.string.accessibility_vibration_intensity_off);
+            case Vibrator.VIBRATION_INTENSITY_LOW:
+                return context.getString(R.string.accessibility_vibration_intensity_low);
+            case Vibrator.VIBRATION_INTENSITY_MEDIUM:
+                return context.getString(R.string.accessibility_vibration_intensity_medium);
+            case Vibrator.VIBRATION_INTENSITY_HIGH:
+                return context.getString(R.string.accessibility_vibration_intensity_high);
+            default:
+                return "";
+        }
+    }
+
+    public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+            new BaseSearchIndexProvider() {
+                @Override
+                public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
+                        boolean enabled) {
+                    List<SearchIndexableResource> indexables = new ArrayList<>();
+                    SearchIndexableResource indexable = new SearchIndexableResource(context);
+                    indexable.xmlResId = R.xml.accessibility_vibration_settings;
+                    indexables.add(indexable);
+                    return indexables;
+                }
+            };
+}
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index f43c3c8..19d0cd1 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -74,7 +74,7 @@
 import com.android.settings.dream.DreamSettings;
 import com.android.settings.enterprise.EnterprisePrivacySettings;
 import com.android.settings.fuelgauge.AdvancedPowerUsageDetail;
-import com.android.settings.fuelgauge.BatterySaverSettings;
+import com.android.settings.fuelgauge.batterysaver.BatterySaverSettings;
 import com.android.settings.fuelgauge.PowerUsageSummary;
 import com.android.settings.fuelgauge.PowerUsageSummaryLegacy;
 import com.android.settings.gestures.AssistGestureSettings;
diff --git a/src/com/android/settings/dashboard/conditional/BatterySaverCondition.java b/src/com/android/settings/dashboard/conditional/BatterySaverCondition.java
index 7feac23..7877f9d 100644
--- a/src/com/android/settings/dashboard/conditional/BatterySaverCondition.java
+++ b/src/com/android/settings/dashboard/conditional/BatterySaverCondition.java
@@ -20,7 +20,7 @@
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.R;
 import com.android.settings.Utils;
-import com.android.settings.fuelgauge.BatterySaverSettings;
+import com.android.settings.fuelgauge.batterysaver.BatterySaverSettings;
 
 public class BatterySaverCondition extends Condition {
     public BatterySaverCondition(ConditionManager manager) {
diff --git a/src/com/android/settings/dashboard/suggestions/SuggestionAdapter.java b/src/com/android/settings/dashboard/suggestions/SuggestionAdapter.java
index 62bc148..b24a914 100644
--- a/src/com/android/settings/dashboard/suggestions/SuggestionAdapter.java
+++ b/src/com/android/settings/dashboard/suggestions/SuggestionAdapter.java
@@ -23,12 +23,15 @@
 import android.graphics.drawable.Icon;
 import android.os.Bundle;
 import android.service.settings.suggestions.Suggestion;
+import android.support.annotation.VisibleForTesting;
 import android.support.v7.widget.RecyclerView;
 import android.text.TextUtils;
+import android.util.DisplayMetrics;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.WindowManager;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 
@@ -117,7 +120,7 @@
         mConfig.setCardLayout(holder, suggestionCount, position);
         final Icon icon = suggestion.getIcon();
         final Drawable drawable = mCache.getIcon(icon);
-        if ((suggestion.getFlags() & Suggestion.FLAG_ICON_TINTABLE) != 0) {
+        if (drawable != null && (suggestion.getFlags() & Suggestion.FLAG_ICON_TINTABLE) != 0) {
             drawable.setTint(Utils.getColorAccent(mContext));
         }
         holder.icon.setImageDrawable(drawable);
@@ -226,28 +229,27 @@
         return mSuggestions;
     }
 
-    private static class CardConfig {
+    @VisibleForTesting
+    static class CardConfig {
         // Card start/end margin
         private final int mMarginInner;
         private final int mMarginOuter;
-        // Card width for different numbers of cards
-        private final int mWidthSingleCard;
-        private final int mWidthTwoCards;
+        // Card width if there are more than 2 cards
         private final int mWidthMultipleCards;
         // padding between icon and title
         private final int mPaddingTitleTopSingleCard;
         private final int mPaddingTitleTopMultipleCards;
+        private final WindowManager mWindowManager;
 
         private static CardConfig sConfig;
 
         private CardConfig(Context context) {
+            mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
             final Resources res = context.getResources();
             mMarginInner =
                 res.getDimensionPixelOffset(R.dimen.suggestion_card_inner_margin);
             mMarginOuter =
                 res.getDimensionPixelOffset(R.dimen.suggestion_card_outer_margin);
-            mWidthSingleCard = res.getDimensionPixelOffset(R.dimen.suggestion_card_width_one_card);
-            mWidthTwoCards = res.getDimensionPixelOffset(R.dimen.suggestion_card_width_two_cards);
             mWidthMultipleCards =
                 res.getDimensionPixelOffset(R.dimen.suggestion_card_width_multiple_cards);
             mPaddingTitleTopSingleCard =
@@ -263,12 +265,12 @@
             return sConfig;
         }
 
-        private void setCardLayout(DashboardItemHolder holder, int suggestionCount,
-            int position) {
+        @VisibleForTesting
+        void setCardLayout(DashboardItemHolder holder, int suggestionCount, int position) {
             final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                 suggestionCount == 1
-                    ? mWidthSingleCard : suggestionCount == 2
-                    ? mWidthTwoCards : mWidthMultipleCards,
+                    ? LinearLayout.LayoutParams.MATCH_PARENT : suggestionCount == 2
+                    ? getWidthForTwoCrads() : mWidthMultipleCards,
                 LinearLayout.LayoutParams.WRAP_CONTENT);
             if (suggestionCount == 1) {
                 params.setMarginStart(mMarginOuter);
@@ -281,6 +283,16 @@
             holder.itemView.setLayoutParams(params);
         }
 
+        private int getWidthForTwoCrads() {
+            return (getScreenWidth() - mMarginInner - mMarginOuter * 2) / 2;
+        }
+
+        @VisibleForTesting
+        int getScreenWidth() {
+            final DisplayMetrics metrics = new DisplayMetrics();
+            mWindowManager.getDefaultDisplay().getMetrics(metrics);
+            return metrics.widthPixels;
+        }
     }
 
 }
diff --git a/src/com/android/settings/fuelgauge/BatterySaverSettings.java b/src/com/android/settings/fuelgauge/BatterySaverSettings.java
deleted file mode 100644
index 2a4fd6e..0000000
--- a/src/com/android/settings/fuelgauge/BatterySaverSettings.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * 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.fuelgauge;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.res.Resources;
-import android.database.ContentObserver;
-import android.net.Uri;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.PowerManager;
-import android.provider.SearchIndexableResource;
-import android.provider.Settings;
-import android.provider.Settings.Global;
-import android.support.annotation.VisibleForTesting;
-import android.util.Log;
-import android.widget.Switch;
-
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.internal.util.ArrayUtils;
-import com.android.settings.R;
-import com.android.settings.SettingsActivity;
-import com.android.settings.SettingsPreferenceFragment;
-import com.android.settings.Utils;
-import com.android.settings.dashboard.conditional.BatterySaverCondition;
-import com.android.settings.dashboard.conditional.ConditionManager;
-import com.android.settings.notification.SettingPref;
-import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.search.Indexable;
-import com.android.settings.widget.SwitchBar;
-
-import java.util.Arrays;
-import java.util.List;
-
-public class BatterySaverSettings extends SettingsPreferenceFragment
-        implements SwitchBar.OnSwitchChangeListener, BatterySaverReceiver.BatterySaverListener,
-        Indexable {
-    private static final String TAG = "BatterySaverSettings";
-    private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
-    private static final String KEY_TURN_ON_AUTOMATICALLY = "turn_on_automatically";
-    private static final long WAIT_FOR_SWITCH_ANIM = 500;
-
-    private final Handler mHandler = new Handler();
-    private final SettingsObserver mSettingsObserver = new SettingsObserver(mHandler);
-
-    @VisibleForTesting
-    SwitchBar mSwitchBar;
-    private Context mContext;
-    private boolean mCreated;
-    private SettingPref mTriggerPref;
-    private Switch mSwitch;
-    private boolean mValidListener;
-    private PowerManager mPowerManager;
-    private BatterySaverReceiver mReceiver;
-
-    @Override
-    public int getMetricsCategory() {
-        return MetricsEvent.FUELGAUGE_BATTERY_SAVER;
-    }
-
-    @Override
-    public void onActivityCreated(Bundle savedInstanceState) {
-        super.onActivityCreated(savedInstanceState);
-        if (mCreated) {
-            mSwitchBar.show();
-            return;
-        }
-        mCreated = true;
-        addPreferencesFromResource(R.xml.battery_saver_settings);
-        mFooterPreferenceMixin.createFooterPreference()
-                .setTitle(com.android.internal.R.string.battery_saver_description);
-        mContext = getActivity();
-        mSwitchBar = ((SettingsActivity) mContext).getSwitchBar();
-        mSwitchBar.setSwitchBarText(R.string.battery_saver_master_switch_title,
-                R.string.battery_saver_master_switch_title);
-        mSwitch = mSwitchBar.getSwitch();
-        mSwitchBar.show();
-
-        int[] levelChoices = getResources().getIntArray(R.array.battery_saver_trigger_values);
-        final int currentThreshold = Global.getInt(mContext.getContentResolver(),
-                Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
-        levelChoices = ArrayUtils.appendInt(levelChoices, currentThreshold);
-        Arrays.sort(levelChoices);
-
-        mTriggerPref = new SettingPref(SettingPref.TYPE_GLOBAL, KEY_TURN_ON_AUTOMATICALLY,
-                Global.LOW_POWER_MODE_TRIGGER_LEVEL,
-                0, /*default*/
-                levelChoices) {
-            @Override
-            protected String getCaption(Resources res, int value) {
-                if (value > 0 && value <= 100) {
-                    return res.getString(R.string.battery_saver_turn_on_automatically_pct,
-                            Utils.formatPercentage(value));
-                }
-                return res.getString(R.string.battery_saver_turn_on_automatically_never);
-            }
-        };
-        mTriggerPref.init(this);
-
-        mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
-        mReceiver = new BatterySaverReceiver(mContext);
-        mReceiver.setBatterySaverListener(this);
-    }
-
-    @Override
-    public void onDestroyView() {
-        super.onDestroyView();
-        mSwitchBar.hide();
-    }
-
-    @Override
-    public void onResume() {
-        super.onResume();
-        mSettingsObserver.setListening(true);
-        mReceiver.setListening(true);
-        if (!mValidListener) {
-            mSwitchBar.addOnSwitchChangeListener(this);
-            mValidListener = true;
-        }
-        updateSwitch();
-    }
-
-    @Override
-    public void onPause() {
-        super.onPause();
-        mSettingsObserver.setListening(false);
-        mReceiver.setListening(false);
-        if (mValidListener) {
-            mSwitchBar.removeOnSwitchChangeListener(this);
-            mValidListener = false;
-        }
-    }
-
-    @Override
-    public void onSwitchChanged(Switch switchView, boolean isChecked) {
-        mHandler.removeCallbacks(mStartMode);
-        if (isChecked) {
-            mHandler.postDelayed(mStartMode, WAIT_FOR_SWITCH_ANIM);
-        } else {
-            if (DEBUG) Log.d(TAG, "Stopping low power mode from settings");
-            trySetPowerSaveMode(false);
-        }
-    }
-
-    private void trySetPowerSaveMode(boolean mode) {
-        if (!mPowerManager.setPowerSaveMode(mode)) {
-            if (DEBUG) Log.d(TAG, "Setting mode failed, fallback to current value");
-            mHandler.post(mUpdateSwitch);
-        }
-        // TODO: Remove once broadcast is in place.
-        ConditionManager.get(getContext()).getCondition(BatterySaverCondition.class).refreshState();
-    }
-
-    private void updateSwitch() {
-        final boolean mode = mPowerManager.isPowerSaveMode();
-        if (DEBUG) Log.d(TAG, "updateSwitch: isChecked=" + mSwitch.isChecked() + " mode=" + mode);
-        if (mode == mSwitch.isChecked()) return;
-
-        // set listener to null so that that code below doesn't trigger onCheckedChanged()
-        if (mValidListener) {
-            mSwitchBar.removeOnSwitchChangeListener(this);
-        }
-        mSwitch.setChecked(mode);
-        if (mValidListener) {
-            mSwitchBar.addOnSwitchChangeListener(this);
-        }
-    }
-
-    private final Runnable mUpdateSwitch = new Runnable() {
-        @Override
-        public void run() {
-            updateSwitch();
-        }
-    };
-
-    private final Runnable mStartMode = new Runnable() {
-        @Override
-        public void run() {
-            AsyncTask.execute(new Runnable() {
-                @Override
-                public void run() {
-                    if (DEBUG) Log.d(TAG, "Starting low power mode from settings");
-                    trySetPowerSaveMode(true);
-                }
-            });
-        }
-    };
-
-    @Override
-    public void onPowerSaveModeChanged() {
-        mHandler.post(mUpdateSwitch);
-    }
-
-    @Override
-    public void onBatteryChanged(boolean pluggedIn) {
-        mSwitchBar.setEnabled(!pluggedIn);
-    }
-
-    private final class SettingsObserver extends ContentObserver {
-        private final Uri LOW_POWER_MODE_TRIGGER_LEVEL_URI
-                = Global.getUriFor(Global.LOW_POWER_MODE_TRIGGER_LEVEL);
-
-        public SettingsObserver(Handler handler) {
-            super(handler);
-        }
-
-        @Override
-        public void onChange(boolean selfChange, Uri uri) {
-            if (LOW_POWER_MODE_TRIGGER_LEVEL_URI.equals(uri)) {
-                mTriggerPref.update(mContext);
-            }
-        }
-
-        public void setListening(boolean listening) {
-            final ContentResolver cr = getContentResolver();
-            if (listening) {
-                cr.registerContentObserver(LOW_POWER_MODE_TRIGGER_LEVEL_URI, false, this);
-            } else {
-                cr.unregisterContentObserver(this);
-            }
-        }
-    }
-
-    /**
-     * For Search.
-     */
-    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
-            new BaseSearchIndexProvider() {
-                @Override
-                public List<SearchIndexableResource> getXmlResourcesToIndex(
-                        Context context, boolean enabled) {
-                    final SearchIndexableResource sir = new SearchIndexableResource(context);
-                    sir.xmlResId = R.xml.battery_saver_settings;
-                    return Arrays.asList(sir);
-                }
-            };
-}
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index 2a841f9..74dc986 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -72,7 +72,7 @@
  * consumed since the last time it was unplugged.
  */
 public class PowerUsageSummary extends PowerUsageBase implements OnLongClickListener,
-        OnClickListener, BatteryTipPreferenceController.BatteryTipListener {
+        BatteryTipPreferenceController.BatteryTipListener {
 
     static final String TAG = "PowerUsageSummary";
 
@@ -80,7 +80,6 @@
     private static final String KEY_APP_LIST = "app_list";
     private static final String KEY_BATTERY_HEADER = "battery_header";
     private static final String KEY_BATTERY_TIP = "battery_tip";
-    private static final String KEY_SHOW_ALL_APPS = "show_all_apps";
 
     private static final String KEY_SCREEN_USAGE = "screen_usage";
     private static final String KEY_TIME_SINCE_LAST_FULL_CHARGE = "last_full_charge";
@@ -225,15 +224,6 @@
     }
 
     @Override
-    public boolean onPreferenceTreeClick(Preference preference) {
-        if (KEY_BATTERY_HEADER.equals(preference.getKey())) {
-            performBatteryHeaderClick();
-            return true;
-        }
-        return super.onPreferenceTreeClick(preference);
-    }
-
-    @Override
     protected String getLogTag() {
         return TAG;
     }
@@ -311,22 +301,6 @@
         }
     }
 
-    private void performBatteryHeaderClick() {
-        if (mPowerFeatureProvider.isAdvancedUiEnabled()) {
-            Utils.startWithFragment(getContext(), PowerUsageAdvanced.class.getName(), null,
-                    null, 0, R.string.advanced_battery_title, null, getMetricsCategory());
-        } else {
-            mStatsHelper.storeStatsHistoryInFile(BatteryHistoryDetail.BATTERY_HISTORY_FILE);
-            Bundle args = new Bundle(2);
-            args.putString(BatteryHistoryDetail.EXTRA_STATS,
-                    BatteryHistoryDetail.BATTERY_HISTORY_FILE);
-            args.putParcelable(BatteryHistoryDetail.EXTRA_BROADCAST,
-                    mStatsHelper.getBatteryBroadcast());
-            Utils.startWithFragment(getContext(), BatteryHistoryDetail.class.getName(), args,
-                    null, 0, R.string.history_details_title, null, getMetricsCategory());
-        }
-    }
-
     protected void refreshUi() {
         final Context context = getContext();
         if (context == null) {
@@ -405,12 +379,9 @@
         getLoaderManager().restartLoader(BATTERY_INFO_LOADER, Bundle.EMPTY,
                 mBatteryInfoLoaderCallbacks);
         if (mPowerFeatureProvider.isEstimateDebugEnabled()) {
-            // Unfortunately setting a long click listener on a view means it will no
-            // longer pass the regular click event to the parent, so we have to register
-            // a regular click listener as well.
+            // Set long click action for summary to show debug info
             View header = mBatteryLayoutPref.findViewById(R.id.summary1);
             header.setOnLongClickListener(this);
-            header.setOnClickListener(this);
         }
     }
 
@@ -422,11 +393,6 @@
     }
 
     @Override
-    public void onClick(View view) {
-        performBatteryHeaderClick();
-    }
-
-    @Override
     protected void restartBatteryStatsLoader() {
         restartBatteryStatsLoader(true /* clearHeader */);
     }
diff --git a/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySaverPreferenceController.java b/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySaverPreferenceController.java
new file mode 100644
index 0000000..4d3dd31
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySaverPreferenceController.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2018 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.fuelgauge.batterysaver;
+
+import android.content.Context;
+import android.provider.Settings;
+import android.support.annotation.VisibleForTesting;
+import android.support.v14.preference.SwitchPreference;
+import android.support.v7.preference.Preference;
+
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.core.TogglePreferenceController;
+
+/**
+ * Controller that update whether to turn on battery saver automatically
+ */
+public class AutoBatterySaverPreferenceController extends TogglePreferenceController implements
+        Preference.OnPreferenceChangeListener {
+    private static final int LOW_POWER_MODE_TRIGGER_THRESHOLD = 15;
+
+    @VisibleForTesting
+    static final String KEY_AUTO_BATTERY_SAVER = "auto_battery_saver";
+
+    public AutoBatterySaverPreferenceController(Context context) {
+        super(context, KEY_AUTO_BATTERY_SAVER);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+
+    @Override
+    public boolean isChecked() {
+        return Settings.Global.getInt(mContext.getContentResolver(),
+                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0) != 0;
+    }
+
+    @Override
+    public boolean setChecked(boolean isChecked) {
+        Settings.Global.putInt(mContext.getContentResolver(),
+                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL,
+                isChecked
+                        ? LOW_POWER_MODE_TRIGGER_THRESHOLD
+                        : 0);
+        return true;
+    }
+}
diff --git a/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySeekBarPreferenceController.java b/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySeekBarPreferenceController.java
new file mode 100644
index 0000000..1c787ab
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySeekBarPreferenceController.java
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2018 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.fuelgauge.batterysaver;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.database.ContentObserver;
+import android.net.Uri;
+import android.os.Handler;
+import android.provider.Settings;
+import android.support.annotation.VisibleForTesting;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.Utils;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.widget.SeekBarPreference;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnStart;
+import com.android.settingslib.core.lifecycle.events.OnStop;
+
+/**
+ * Controller that update the battery saver seekbar
+ */
+public class AutoBatterySeekBarPreferenceController extends BasePreferenceController implements
+        LifecycleObserver, OnStart, OnStop, SeekBarPreference.OnPreferenceChangeListener {
+    @VisibleForTesting
+    static final String KEY_AUTO_BATTERY_SEEK_BAR = "battery_saver_seek_bar";
+    private SeekBarPreference mPreference;
+    private AutoBatterySaverSettingObserver mContentObserver;
+
+    public AutoBatterySeekBarPreferenceController(Context context, Lifecycle lifecycle) {
+        super(context, KEY_AUTO_BATTERY_SEEK_BAR);
+        mContentObserver = new AutoBatterySaverSettingObserver(new Handler());
+        if (lifecycle != null) {
+            lifecycle.addObserver(this);
+        }
+    }
+
+    @Override
+    public void displayPreference(PreferenceScreen screen) {
+        super.displayPreference(screen);
+        mPreference = (SeekBarPreference) screen.findPreference(
+                KEY_AUTO_BATTERY_SEEK_BAR);
+        updatePreference(mPreference);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+
+    @Override
+    public void updateState(Preference preference) {
+        super.updateState(preference);
+        updatePreference(preference);
+    }
+
+    @Override
+    public void onStart() {
+        mContentObserver.registerContentObserver();
+    }
+
+    @Override
+    public void onStop() {
+        mContentObserver.unRegisterContentObserver();
+    }
+
+    @Override
+    public boolean onPreferenceChange(Preference preference, Object newValue) {
+        final int progress = (int) newValue;
+        Settings.Global.putInt(mContext.getContentResolver(),
+                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, progress);
+        return true;
+    }
+
+    @VisibleForTesting
+    void updatePreference(Preference preference) {
+        final ContentResolver contentResolver = mContext.getContentResolver();
+        final int level = Settings.Global.getInt(contentResolver,
+                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
+        if (level == 0) {
+            preference.setVisible(false);
+        } else {
+            preference.setVisible(true);
+            preference.setTitle(mContext.getString(R.string.battery_saver_seekbar_title,
+                    Utils.formatPercentage(level)));
+            ((SeekBarPreference) preference).setProgress(level);
+        }
+    }
+
+    /**
+     * Observer that listens to change from {@link Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL}
+     */
+    private final class AutoBatterySaverSettingObserver extends ContentObserver {
+        private final Uri mUri = Settings.Global.getUriFor(
+                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL);
+        private final ContentResolver mContentResolver;
+
+        public AutoBatterySaverSettingObserver(Handler handler) {
+            super(handler);
+            mContentResolver = mContext.getContentResolver();
+        }
+
+        public void registerContentObserver() {
+            mContentResolver.registerContentObserver(mUri, false, this);
+        }
+
+        public void unRegisterContentObserver() {
+            mContentResolver.unregisterContentObserver(this);
+        }
+
+        @Override
+        public void onChange(boolean selfChange, Uri uri, int userId) {
+            if (mUri.equals(uri)) {
+                updatePreference(mPreference);
+            }
+        }
+    }
+}
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverSettings.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverSettings.java
new file mode 100644
index 0000000..392032c
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverSettings.java
@@ -0,0 +1,102 @@
+/*
+ * 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.fuelgauge.batterysaver;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.os.PowerManager;
+import android.provider.SearchIndexableResource;
+import android.provider.Settings.Global;
+import android.support.annotation.VisibleForTesting;
+import android.util.Log;
+
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.internal.util.ArrayUtils;
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
+import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Battery saver settings page
+ */
+public class BatterySaverSettings extends DashboardFragment {
+    private static final String TAG = "BatterySaverSettings";
+
+    @Override
+    public void onActivityCreated(Bundle savedInstanceState) {
+        super.onActivityCreated(savedInstanceState);
+    }
+
+    @Override
+    public int getMetricsCategory() {
+        return MetricsEvent.FUELGAUGE_BATTERY_SAVER;
+    }
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.battery_saver_settings;
+    }
+
+    @Override
+    protected String getLogTag() {
+        return TAG;
+    }
+
+    @Override
+    protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
+        return buildPreferenceControllers(context, getLifecycle());
+    }
+
+    @Override
+    public int getHelpResource() {
+        return R.string.help_url_battery_saver_settings;
+    }
+
+    private static List<AbstractPreferenceController> buildPreferenceControllers(
+            Context context, Lifecycle lifecycle) {
+        final List<AbstractPreferenceController> controllers = new ArrayList<>();
+        controllers.add(new AutoBatterySaverPreferenceController(context));
+        controllers.add(new AutoBatterySeekBarPreferenceController(context, lifecycle));
+        return controllers;
+    }
+
+    /**
+     * For Search.
+     */
+    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+            new BaseSearchIndexProvider() {
+                @Override
+                public List<SearchIndexableResource> getXmlResourcesToIndex(
+                        Context context, boolean enabled) {
+                    final SearchIndexableResource sir = new SearchIndexableResource(context);
+                    sir.xmlResId = R.xml.battery_saver_settings;
+                    return Arrays.asList(sir);
+                }
+
+                @Override
+                public List<AbstractPreferenceController> getPreferenceControllers(Context context) {
+                    return buildPreferenceControllers(context, null);
+                }
+            };
+}
diff --git a/src/com/android/settings/search/SearchIndexableResourcesImpl.java b/src/com/android/settings/search/SearchIndexableResourcesImpl.java
index 1edc2de..2b25512 100644
--- a/src/com/android/settings/search/SearchIndexableResourcesImpl.java
+++ b/src/com/android/settings/search/SearchIndexableResourcesImpl.java
@@ -26,6 +26,7 @@
 import com.android.settings.accessibility.AccessibilitySettings;
 import com.android.settings.accessibility.AccessibilityShortcutPreferenceFragment;
 import com.android.settings.accessibility.MagnificationPreferenceFragment;
+import com.android.settings.accessibility.VibrationSettings;
 import com.android.settings.accounts.AccountDashboardFragment;
 import com.android.settings.applications.AppAndNotificationDashboardFragment;
 import com.android.settings.applications.DefaultAppSettings;
@@ -49,7 +50,7 @@
 import com.android.settings.display.ScreenZoomSettings;
 import com.android.settings.dream.DreamSettings;
 import com.android.settings.enterprise.EnterprisePrivacySettings;
-import com.android.settings.fuelgauge.BatterySaverSettings;
+import com.android.settings.fuelgauge.batterysaver.BatterySaverSettings;
 import com.android.settings.fuelgauge.PowerUsageAdvanced;
 import com.android.settings.fuelgauge.PowerUsageSummary;
 import com.android.settings.fuelgauge.SmartBatterySettings;
@@ -176,6 +177,7 @@
         addIndex(NightDisplaySettings.class);
         addIndex(SmartBatterySettings.class);
         addIndex(MyDeviceInfoFragment.class);
+        addIndex(VibrationSettings.class);
     }
 
     @Override
diff --git a/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceController.java b/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceController.java
index 5bb8f75..3e39860 100644
--- a/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceController.java
+++ b/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceController.java
@@ -20,7 +20,6 @@
 import android.os.UserHandle;
 import android.support.annotation.VisibleForTesting;
 import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceScreen;
 
 import com.android.internal.widget.LockPatternUtils;
 import com.android.settings.R;
@@ -52,21 +51,18 @@
     }
 
     @Override
-    public void displayPreference(PreferenceScreen screen) {
-        super.displayPreference(screen);
-        final Preference preference = screen.findPreference(getPreferenceKey());
-        if (preference == null) {
-            return;
-        }
+    public void updateState(Preference preference) {
         final int numberOfTrustAgent = getTrustAgentCount();
         if (!mLockPatternUtils.isSecure(MY_USER_ID)) {
             preference.setEnabled(false);
             preference.setSummary(R.string.disabled_because_no_backup_security);
         } else if (numberOfTrustAgent > 0) {
+            preference.setEnabled(true);
             preference.setSummary(mContext.getResources().getQuantityString(
                     R.plurals.manage_trust_agents_summary_on,
                     numberOfTrustAgent, numberOfTrustAgent));
         } else {
+            preference.setEnabled(true);
             preference.setSummary(R.string.manage_trust_agents_summary);
         }
     }
diff --git a/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java b/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
index 77142ed..8d798b1 100644
--- a/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
+++ b/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
@@ -59,7 +59,8 @@
     @VisibleForTesting
     public static boolean isSuggestionComplete(Context context) {
         final WallpaperManagerWrapper manager = new WallpaperManagerWrapper(context);
-        return manager.getWallpaperId(WallpaperManager.FLAG_SYSTEM) > 0;
+        return manager.isWallpaperServiceEnabled() ? manager.getWallpaperId(
+                WallpaperManager.FLAG_SYSTEM) > 0 : false;
     }
 
 }
diff --git a/src/com/android/settings/widget/SeekBarPreference.java b/src/com/android/settings/widget/SeekBarPreference.java
index ee7d4b8..5af21b3 100644
--- a/src/com/android/settings/widget/SeekBarPreference.java
+++ b/src/com/android/settings/widget/SeekBarPreference.java
@@ -40,6 +40,7 @@
 
     private int mProgress;
     private int mMax;
+    private int mMin;
     private boolean mTrackingTouch;
 
     private boolean mContinuousUpdates;
@@ -55,6 +56,7 @@
         TypedArray a = context.obtainStyledAttributes(
                 attrs, com.android.internal.R.styleable.ProgressBar, defStyleAttr, defStyleRes);
         setMax(a.getInt(com.android.internal.R.styleable.ProgressBar_max, mMax));
+        setMin(a.getInt(com.android.internal.R.styleable.ProgressBar_min, mMin));
         a.recycle();
 
         a = context.obtainStyledAttributes(attrs,
@@ -94,6 +96,7 @@
                 com.android.internal.R.id.seekbar);
         mSeekBar.setOnSeekBarChangeListener(this);
         mSeekBar.setMax(mMax);
+        mSeekBar.setMin(mMin);
         mSeekBar.setProgress(mProgress);
         mSeekBar.setEnabled(isEnabled());
         final CharSequence title = getTitle();
@@ -154,10 +157,21 @@
         }
     }
 
+    public void setMin(int min) {
+        if (min != mMin) {
+            mMin = min;
+            notifyChanged();
+        }
+    }
+
     public int getMax() {
         return mMax;
     }
 
+    public int getMin() {
+        return mMin;
+    }
+
     public void setProgress(int progress) {
         setProgress(progress, true);
     }
@@ -187,8 +201,8 @@
         if (progress > mMax) {
             progress = mMax;
         }
-        if (progress < 0) {
-            progress = 0;
+        if (progress < mMin) {
+            progress = mMin;
         }
         if (progress != mProgress) {
             mProgress = progress;
@@ -257,6 +271,7 @@
         final SavedState myState = new SavedState(superState);
         myState.progress = mProgress;
         myState.max = mMax;
+        myState.min = mMin;
         return myState;
     }
 
@@ -273,6 +288,7 @@
         super.onRestoreInstanceState(myState.getSuperState());
         mProgress = myState.progress;
         mMax = myState.max;
+        mMin = myState.min;
         notifyChanged();
     }
 
@@ -285,6 +301,7 @@
     private static class SavedState extends BaseSavedState {
         int progress;
         int max;
+        int min;
 
         public SavedState(Parcel source) {
             super(source);
@@ -292,6 +309,7 @@
             // Restore the click counter
             progress = source.readInt();
             max = source.readInt();
+            min = source.readInt();
         }
 
         @Override
@@ -301,6 +319,7 @@
             // Save the click counter
             dest.writeInt(progress);
             dest.writeInt(max);
+            dest.writeInt(min);
         }
 
         public SavedState(Parcelable superState) {
diff --git a/src/com/android/settings/wifi/ConnectedAccessPointPreference.java b/src/com/android/settings/wifi/ConnectedAccessPointPreference.java
index 6b9c788..514525c 100644
--- a/src/com/android/settings/wifi/ConnectedAccessPointPreference.java
+++ b/src/com/android/settings/wifi/ConnectedAccessPointPreference.java
@@ -36,6 +36,7 @@
     public ConnectedAccessPointPreference(AccessPoint accessPoint, Context context,
             UserBadgeCache cache, @DrawableRes int iconResId, boolean forSavedNetworks) {
         super(accessPoint, context, cache, iconResId, forSavedNetworks);
+        setWidgetLayoutResource(R.layout.preference_widget_gear_no_bg);
     }
 
     public void setOnGearClickListener(OnGearClickListener l) {
@@ -44,26 +45,6 @@
     }
 
     @Override
-    protected int getSecondTargetResId() {
-        return R.layout.preference_widget_gear;
-    }
-
-    @Override
-    protected boolean shouldHideSecondTarget() {
-        return mOnGearClickListener == null;
-    }
-
-    @Override
-    public void onBindViewHolder(PreferenceViewHolder holder) {
-        super.onBindViewHolder(holder);
-        final View gear = holder.findViewById(R.id.settings_button);
-        if (gear != null) {
-            gear.setOnClickListener(this);
-        }
-        setDividerVisibility(holder, View.VISIBLE);
-    }
-
-    @Override
     public void onClick(View v) {
         if (v.getId() == R.id.settings_button) {
             if (mOnGearClickListener != null) {
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 22f8c43..ce0ff80 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -884,13 +884,14 @@
                 connectedAp);
 
         // Launch details page on click.
-        pref.setOnGearClickListener(l -> {
+        pref.setOnPreferenceClickListener(preference -> {
             pref.getAccessPoint().saveWifiState(pref.getExtras());
 
             SettingsActivity activity = (SettingsActivity) WifiSettings.this.getActivity();
             activity.startPreferencePanel(this,
                     WifiNetworkDetailsFragment.class.getName(), pref.getExtras(),
                     -1 /* resId */, pref.getTitle(), null, 0 /* resultRequestCode */);
+            return true;
         });
 
         pref.refresh();
diff --git a/src/com/android/settings/wrapper/WallpaperManagerWrapper.java b/src/com/android/settings/wrapper/WallpaperManagerWrapper.java
index 89015e5..eabc5bb 100644
--- a/src/com/android/settings/wrapper/WallpaperManagerWrapper.java
+++ b/src/com/android/settings/wrapper/WallpaperManagerWrapper.java
@@ -22,12 +22,23 @@
 public class WallpaperManagerWrapper {
 
     private final WallpaperManager mWallpaperManager;
+    private final boolean mWallpaperServiceEnabled;
 
     public WallpaperManagerWrapper(Context context) {
-        mWallpaperManager = (WallpaperManager) context.getSystemService(Context.WALLPAPER_SERVICE);
+        mWallpaperServiceEnabled = context.getResources().getBoolean(
+                com.android.internal.R.bool.config_enableWallpaperService);
+        mWallpaperManager = mWallpaperServiceEnabled ? (WallpaperManager) context.getSystemService(
+                Context.WALLPAPER_SERVICE) : null;
+    }
+
+    public boolean isWallpaperServiceEnabled() {
+        return mWallpaperServiceEnabled;
     }
 
     public int getWallpaperId(int which) {
+        if (!mWallpaperServiceEnabled) {
+            throw new RuntimeException("This device does not have wallpaper service enabled.");
+        }
         return mWallpaperManager.getWallpaperId(which);
     }
 }
diff --git a/tests/robotests/src/com/android/internal/app/ColorDisplayController.java b/tests/robotests/src/com/android/internal/app/ColorDisplayController.java
index 74e7d8a..e31ba51 100644
--- a/tests/robotests/src/com/android/internal/app/ColorDisplayController.java
+++ b/tests/robotests/src/com/android/internal/app/ColorDisplayController.java
@@ -16,8 +16,8 @@
 package com.android.internal.app;
 
 /**
- * Fake controller to make robolectric test compile. Should be removed when Robolectric supports
- * API 25.
+ * Fake controller to make robolectric test compile. This is necessary since
+ * ColorDisplayController is not part of Android's API.
  */
 public class ColorDisplayController {
 
diff --git a/tests/robotests/src/com/android/settings/accessibility/VibrationPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/VibrationPreferenceFragmentTest.java
new file mode 100644
index 0000000..f6a5a82
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/VibrationPreferenceFragmentTest.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2018 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.accessibility;
+
+import static com.android.settings.accessibility.VibrationPreferenceFragment.KEY_INTENSITY_OFF;
+import static com.android.settings.accessibility.VibrationPreferenceFragment.KEY_INTENSITY_LOW;
+import static com.android.settings.accessibility.VibrationPreferenceFragment.KEY_INTENSITY_MEDIUM;
+import static com.android.settings.accessibility.VibrationPreferenceFragment.KEY_INTENSITY_HIGH;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.app.Activity;
+import android.content.Context;
+import android.os.UserManager;
+import android.os.Vibrator;
+import android.provider.Settings;
+
+import com.android.settings.TestConfig;
+import com.android.settings.accessibility.VibrationPreferenceFragment.VibrationIntensityCandidateInfo;
+import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.widget.RadioButtonPickerFragment.CandidateInfo;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class VibrationPreferenceFragmentTest {
+    public static final Map<Integer, String> INTENSITY_TO_KEY = new HashMap<>();
+
+    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+    private Activity mActivity;
+    @Mock
+    private UserManager mUserManager;
+
+    private Context mContext;
+    private TestVibrationPreferenceFragment mFragment;
+
+    static {
+        INTENSITY_TO_KEY.put(Vibrator.VIBRATION_INTENSITY_OFF, KEY_INTENSITY_OFF);
+        INTENSITY_TO_KEY.put(Vibrator.VIBRATION_INTENSITY_LOW, KEY_INTENSITY_LOW);
+        INTENSITY_TO_KEY.put(Vibrator.VIBRATION_INTENSITY_MEDIUM, KEY_INTENSITY_MEDIUM);
+        INTENSITY_TO_KEY.put(Vibrator.VIBRATION_INTENSITY_HIGH, KEY_INTENSITY_HIGH);
+    }
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        FakeFeatureFactory.setupForTest();
+
+        mContext = RuntimeEnvironment.application;
+
+        mFragment = spy(new TestVibrationPreferenceFragment());
+        doReturn(mUserManager).when(mActivity).getSystemService(Context.USER_SERVICE);
+        doReturn(mContext).when(mFragment).getContext();
+        mFragment.onAttach(mActivity);
+    }
+
+    @Test
+    public void changeIntensitySetting_shouldResultInCorrespondingKey() {
+        for (Map.Entry<Integer, String> entry : INTENSITY_TO_KEY.entrySet()) {
+            Settings.System.putInt(mContext.getContentResolver(),
+                    Settings.System.HAPTIC_FEEDBACK_INTENSITY, entry.getKey());
+            assertThat(mFragment.getDefaultKey()).isEqualTo(entry.getValue());
+        }
+    }
+
+    @Test
+    public void initialDefaultKey_shouldBeMedium() {
+        assertThat(mFragment.getDefaultKey()).isEqualTo(KEY_INTENSITY_MEDIUM);
+    }
+
+    @Test
+    public void candidates_shouldBeSortedByIntensity() {
+        final List<? extends CandidateInfo> candidates = mFragment.getCandidates();
+        assertThat(candidates.size()).isEqualTo(INTENSITY_TO_KEY.size());
+        VibrationIntensityCandidateInfo prevCandidate =
+                (VibrationIntensityCandidateInfo) candidates.get(0);
+        for (int i = 1; i < candidates.size(); i++) {
+            VibrationIntensityCandidateInfo candidate =
+                    (VibrationIntensityCandidateInfo) candidates.get(i);
+            assertThat(candidate.getIntensity()).isLessThan(prevCandidate.getIntensity());
+        }
+    }
+
+    private class TestVibrationPreferenceFragment extends VibrationPreferenceFragment {
+        @Override
+        protected int getPreferenceScreenResId() {
+            return 0;
+        }
+
+        @Override
+        public int getMetricsCategory() {
+            return 0;
+        }
+
+        /**
+        * Get the setting string of the vibration intensity setting this preference is dealing with.
+        */
+        @Override
+        protected String getVibrationIntensitySetting() {
+            return Settings.System.HAPTIC_FEEDBACK_INTENSITY;
+        }
+
+        @Override
+        protected int getDefaultVibrationIntensity() {
+            return Vibrator.VIBRATION_INTENSITY_MEDIUM;
+        }
+    }
+}
+
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java
index d25969e..cc25b5d 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java
@@ -35,6 +35,7 @@
 import android.util.DisplayMetrics;
 import android.view.LayoutInflater;
 import android.view.View;
+import android.view.WindowManager;
 import android.widget.TextView;
 
 import com.android.settings.R;
@@ -77,6 +78,8 @@
     private Condition mCondition;
     @Mock
     private Resources mResources;
+    @Mock
+    private WindowManager mWindowManager;
     private FakeFeatureFactory mFactory;
     private DashboardAdapter mDashboardAdapter;
     private List<Condition> mConditionList;
@@ -87,6 +90,7 @@
         mFactory = FakeFeatureFactory.setupForTest();
         when(mFactory.dashboardFeatureProvider.shouldTintIcon()).thenReturn(true);
 
+        when(mContext.getSystemService(Context.WINDOW_SERVICE)).thenReturn(mWindowManager);
         when(mContext.getResources()).thenReturn(mResources);
         when(mResources.getQuantityString(any(int.class), any(int.class), any()))
                 .thenReturn("");
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java
index fc773a7..bac02d3 100644
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java
@@ -28,12 +28,15 @@
 
 import android.app.PendingIntent;
 import android.content.Context;
+import android.content.res.Resources;
 import android.content.res.TypedArray;
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.Icon;
 import android.service.settings.suggestions.Suggestion;
+import android.view.Display;
 import android.view.LayoutInflater;
 import android.view.View;
+import android.view.WindowManager;
 import android.widget.FrameLayout;
 import android.widget.LinearLayout;
 
@@ -67,17 +70,33 @@
     private SettingsActivity mActivity;
     @Mock
     private SuggestionControllerMixin mSuggestionControllerMixin;
+    @Mock
+    private Resources mResources;
+    @Mock
+    private WindowManager mWindowManager;
+
     private FakeFeatureFactory mFeatureFactory;
     private Context mContext;
     private SuggestionAdapter mSuggestionAdapter;
     private DashboardAdapter.DashboardItemHolder mSuggestionHolder;
     private List<Suggestion> mOneSuggestion;
     private List<Suggestion> mTwoSuggestions;
+    private SuggestionAdapter.CardConfig mConfig;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mContext = spy(RuntimeEnvironment.application);
+        when(mActivity.getSystemService(Context.WINDOW_SERVICE)).thenReturn(mWindowManager);
+        when(mActivity.getResources()).thenReturn(mResources);
+        when(mResources.getDimensionPixelOffset(R.dimen.suggestion_card_inner_margin))
+            .thenReturn(10);
+        when(mResources.getDimensionPixelOffset(R.dimen.suggestion_card_outer_margin))
+            .thenReturn(20);
+        when(mResources.getDimensionPixelOffset(R.dimen.suggestion_card_width_multiple_cards))
+            .thenReturn(120);
+        mConfig = spy(SuggestionAdapter.CardConfig.get(mActivity));
+
         mFeatureFactory = FakeFeatureFactory.setupForTest();
 
         final Suggestion suggestion1 = new Suggestion.Builder("id1")
@@ -275,6 +294,44 @@
         verify(drawable).setTint(colorAccent);
     }
 
+    @Test
+    public void setCardLayout_oneCard_shouldSetCardWidthToMatchParent() {
+        final List<Suggestion> suggestions = makeSuggestions("pkg1");
+        setupSuggestions(mContext, suggestions);
+
+        mConfig.setCardLayout(mSuggestionHolder, 1, 0);
+
+        assertThat(mSuggestionHolder.itemView.getLayoutParams().width)
+            .isEqualTo(LinearLayout.LayoutParams.MATCH_PARENT);
+    }
+
+    @Test
+    public void setCardLayout_twoCards_shouldSetCardWidthToHalfScreenMinusPadding() {
+        final List<Suggestion> suggestions = makeSuggestions("pkg1");
+        setupSuggestions(mContext, suggestions);
+        doReturn(200).when(mConfig).getScreenWidth();
+
+        mConfig.setCardLayout(mSuggestionHolder, 2, 0);
+
+        /*
+         * card width = (screen width - left margin - inner margin - right margin) / 2
+         *            = (200 - 20 - 10 - 20) / 2
+         *            = 75
+         */
+        assertThat(mSuggestionHolder.itemView.getLayoutParams().width).isEqualTo(75);
+    }
+
+
+    @Test
+    public void setCardLayout_multipleCards_shouldSetCardWidthFromResource() {
+        final List<Suggestion> suggestions = makeSuggestions("pkg1");
+        setupSuggestions(mContext, suggestions);
+
+        mConfig.setCardLayout(mSuggestionHolder, 3, 0);
+
+        assertThat(mSuggestionHolder.itemView.getLayoutParams().width).isEqualTo(120);
+    }
+
     private void setupSuggestions(Context context, List<Suggestion> suggestions) {
         mSuggestionAdapter = new SuggestionAdapter(context, mSuggestionControllerMixin,
             null /* savedInstanceState */, null /* callback */, null /* lifecycle */);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverSettingsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverSettingsTest.java
deleted file mode 100644
index 0e32f6b..0000000
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverSettingsTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.
- */
-package com.android.settings.fuelgauge;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-import android.provider.SearchIndexableResource;
-
-import com.android.settings.R;
-import com.android.settings.TestConfig;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.widget.SwitchBar;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-
-import java.util.List;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class BatterySaverSettingsTest {
-    private Context mContext;
-    private BatterySaverSettings mBatterySaverSettings;
-
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
-        mContext = RuntimeEnvironment.application;
-        mBatterySaverSettings = new BatterySaverSettings();
-        mBatterySaverSettings.mSwitchBar = new SwitchBar(mContext);
-    }
-
-    @Test
-    public void testOnBatteryChanged_pluggedIn_setDisable() {
-        mBatterySaverSettings.onBatteryChanged(true /* pluggedIn */);
-
-        assertThat(mBatterySaverSettings.mSwitchBar.isEnabled()).isFalse();
-    }
-
-    @Test
-    public void testOnBatteryChanged_notPluggedIn_setEnable() {
-        mBatterySaverSettings.onBatteryChanged(false /* pluggedIn */);
-
-        assertThat(mBatterySaverSettings.mSwitchBar.isEnabled()).isTrue();
-    }
-
-    @Test
-    public void searchProvider_shouldIndexDefaultXml() {
-        final List<SearchIndexableResource> sir = mBatterySaverSettings.SEARCH_INDEX_DATA_PROVIDER
-                .getXmlResourcesToIndex(mContext, true /* enabled */);
-
-        assertThat(sir).hasSize(1);
-        assertThat(sir.get(0).xmlResId).isEqualTo(R.xml.battery_saver_settings);
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySaverPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySaverPreferenceControllerTest.java
new file mode 100644
index 0000000..cabcdcf
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySaverPreferenceControllerTest.java
@@ -0,0 +1,87 @@
+/*
+ * 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.
+ *
+ *
+ */
+
+package com.android.settings.fuelgauge.batterysaver;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.provider.Settings;
+import android.support.v14.preference.SwitchPreference;
+
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class AutoBatterySaverPreferenceControllerTest {
+
+    private AutoBatterySaverPreferenceController mController;
+    private Context mContext;
+    private SwitchPreference mPreference;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+
+        mContext = RuntimeEnvironment.application;
+        mPreference = new SwitchPreference(mContext);
+        mController = new AutoBatterySaverPreferenceController(mContext);
+    }
+
+    @Test
+    public void testUpdateState_lowPowerLevelZero_preferenceNotChecked() {
+        Settings.Global.putInt(mContext.getContentResolver(),
+                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
+        mController.updateState(mPreference);
+
+        assertThat(mPreference.isChecked()).isFalse();
+    }
+
+    @Test
+    public void testUpdateState_lowPowerLevelZero_preferenceChecked() {
+        Settings.Global.putInt(mContext.getContentResolver(),
+                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 15);
+        mController.updateState(mPreference);
+
+        assertThat(mPreference.isChecked()).isTrue();
+    }
+
+    @Test
+    public void testOnPreferenceChange_turnOn_setValueNotZero() {
+        mController.onPreferenceChange(mPreference, true);
+
+        assertThat(Settings.Global.getInt(mContext.getContentResolver(),
+                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0)).isNotEqualTo(0);
+    }
+
+    @Test
+    public void testOnPreferenceChange_turnOff_setValueZero() {
+        mController.onPreferenceChange(mPreference, false);
+
+        assertThat(Settings.Global.getInt(mContext.getContentResolver(),
+                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0)).isEqualTo(0);
+    }
+
+}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySeekBarPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySeekBarPreferenceControllerTest.java
new file mode 100644
index 0000000..32a4fac
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySeekBarPreferenceControllerTest.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2018 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.fuelgauge.batterysaver;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.arch.lifecycle.LifecycleOwner;
+import android.content.Context;
+import android.provider.Settings;
+import android.support.v14.preference.SwitchPreference;
+
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.widget.SeekBarPreference;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class AutoBatterySeekBarPreferenceControllerTest {
+    private static final int TRIGGER_LEVEL = 15;
+
+    private AutoBatterySeekBarPreferenceController mController;
+    private Context mContext;
+    private SeekBarPreference mPreference;
+    private Lifecycle mLifecycle;
+    private LifecycleOwner mLifecycleOwner;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mLifecycleOwner = () -> mLifecycle;
+        mLifecycle = new Lifecycle(mLifecycleOwner);
+
+        mContext = RuntimeEnvironment.application;
+        mPreference = new SeekBarPreference(mContext);
+        mPreference.setMax(100);
+        mController = new AutoBatterySeekBarPreferenceController(mContext, mLifecycle);
+    }
+
+    @Test
+    public void testPreference_lowPowerLevelZero_preferenceInvisible() {
+        Settings.Global.putInt(mContext.getContentResolver(),
+                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
+
+        mController.updateState(mPreference);
+
+        assertThat(mPreference.isVisible()).isFalse();
+    }
+
+    @Test
+    public void testPreference_lowPowerLevelNotZero_updatePreference() {
+        Settings.Global.putInt(mContext.getContentResolver(),
+                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, TRIGGER_LEVEL);
+        mController.updateState(mPreference);
+
+        assertThat(mPreference.isVisible()).isTrue();
+        assertThat(mPreference.getTitle()).isEqualTo("Turn on automatically at 15%");
+        assertThat(mPreference.getProgress()).isEqualTo(TRIGGER_LEVEL);
+    }
+
+    @Test
+    public void testOnPreferenceChange_updateValue() {
+        Settings.Global.putInt(mContext.getContentResolver(),
+                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
+
+        mController.onPreferenceChange(mPreference, TRIGGER_LEVEL);
+
+        assertThat(Settings.Global.getInt(mContext.getContentResolver(),
+                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0)).isEqualTo(TRIGGER_LEVEL);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceControllerTest.java
index 42d640a..64a0cea 100644
--- a/tests/robotests/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceControllerTest.java
@@ -16,14 +16,12 @@
 
 package com.android.settings.security.trustagent;
 
-import static com.android.settings.core.BasePreferenceController.AVAILABLE;
 import static com.google.common.truth.Truth.assertThat;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
 import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceScreen;
 
 import com.android.internal.widget.LockPatternUtils;
 import com.android.settings.R;
@@ -50,8 +48,6 @@
     private TrustAgentManager mTrustAgentManager;
     @Mock
     private LockPatternUtils mLockPatternUtils;
-    @Mock
-    private PreferenceScreen mScreen;
 
     private FakeFeatureFactory mFeatureFactory;
     private Context mContext;
@@ -70,8 +66,6 @@
         mController = new ManageTrustAgentsPreferenceController(mContext);
         mPreference = new Preference(mContext);
         mPreference.setKey(mController.getPreferenceKey());
-        when(mScreen.findPreference(mController.getPreferenceKey()))
-                .thenReturn(mPreference);
     }
 
     @Test
@@ -86,10 +80,10 @@
     }
 
     @Test
-    public void displayPreference_isNotSecure_shouldDisablePreference() {
+    public void updateState_isNotSecure_shouldDisablePreference() {
         when(mLockPatternUtils.isSecure(anyInt())).thenReturn(false);
 
-        mController.displayPreference(mScreen);
+        mController.updateState(mPreference);
 
         assertThat(mPreference.isEnabled()).isFalse();
         assertThat(mPreference.getSummary())
@@ -97,12 +91,12 @@
     }
 
     @Test
-    public void displayPreference_isSecure_noTrustAgent_shouldShowGenericSummary() {
+    public void updateState_isSecure_noTrustAgent_shouldShowGenericSummary() {
         when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
         when(mTrustAgentManager.getActiveTrustAgents(mContext, mLockPatternUtils))
                 .thenReturn(new ArrayList<>());
 
-        mController.displayPreference(mScreen);
+        mController.updateState(mPreference);
 
         assertThat(mPreference.isEnabled()).isTrue();
         assertThat(mPreference.getSummary())
@@ -110,12 +104,12 @@
     }
 
     @Test
-    public void displayPreference_isSecure_hasTrustAgent_shouldShowDetailedSummary() {
+    public void updateState_isSecure_hasTrustAgent_shouldShowDetailedSummary() {
         when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
         when(mTrustAgentManager.getActiveTrustAgents(mContext, mLockPatternUtils))
                 .thenReturn(Arrays.asList(new TrustAgentManager.TrustAgentComponentInfo()));
 
-        mController.displayPreference(mScreen);
+        mController.updateState(mPreference);
 
         assertThat(mPreference.isEnabled()).isTrue();
         assertThat(mPreference.getSummary())
diff --git a/tests/robotests/src/com/android/settings/wallpaper/WallpaperSuggestionActivityTest.java b/tests/robotests/src/com/android/settings/wallpaper/WallpaperSuggestionActivityTest.java
index ced4b0a..daaf4b3 100644
--- a/tests/robotests/src/com/android/settings/wallpaper/WallpaperSuggestionActivityTest.java
+++ b/tests/robotests/src/com/android/settings/wallpaper/WallpaperSuggestionActivityTest.java
@@ -17,12 +17,14 @@
 package com.android.settings.wallpaper;
 
 import static com.google.common.truth.Truth.assertThat;
+
 import static org.mockito.Mockito.when;
 import static org.robolectric.Shadows.shadowOf;
 
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageManager;
+import android.content.res.Resources;
 
 import com.android.settings.SubSettings;
 import com.android.settings.TestConfig;
@@ -42,16 +44,16 @@
 import org.robolectric.shadows.ShadowActivity;
 
 @RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
-        shadows = {
-                WallpaperSuggestionActivityTest.ShadowWallpaperManagerWrapper.class
-        })
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
 public class WallpaperSuggestionActivityTest {
 
     @Mock
     private Context mContext;
     @Mock
     private PackageManager mPackageManager;
+    @Mock
+    private Resources mResources;
+
     private ActivityController<WallpaperSuggestionActivity> mController;
 
     @Before
@@ -72,6 +74,17 @@
     }
 
     @Test
+    public void wallpaperServiceEnabled_no_shouldReturnFalse() {
+        when(mContext.getResources()).thenReturn(mResources);
+        when(mResources.getBoolean(
+                com.android.internal.R.bool.config_enableWallpaperService)).thenReturn(false);
+
+        assertThat(WallpaperSuggestionActivity.isSuggestionComplete(mContext))
+                .isFalse();
+    }
+
+    @Test
+    @Config(shadows = WallpaperSuggestionActivityTest.ShadowWallpaperManagerWrapper.class)
     public void hasWallpaperSet_no_shouldReturnFalse() {
         ShadowWallpaperManagerWrapper.setWallpaperId(0);
 
@@ -80,6 +93,7 @@
     }
 
     @Test
+    @Config(shadows = WallpaperSuggestionActivityTest.ShadowWallpaperManagerWrapper.class)
     public void hasWallpaperSet_yes_shouldReturnTrue() {
         ShadowWallpaperManagerWrapper.setWallpaperId(100);
 
@@ -100,6 +114,15 @@
             sWallpaperId = 0;
         }
 
+        public void __constructor__(Context context) {
+
+        }
+
+        @Implementation
+        public boolean isWallpaperServiceEnabled() {
+            return true;
+        }
+
         @Implementation
         public int getWallpaperId(int which) {
             return sWallpaperId;
diff --git a/tests/robotests/src/com/android/settings/widget/SeekBarPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/SeekBarPreferenceTest.java
new file mode 100644
index 0000000..7a042a0
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/widget/SeekBarPreferenceTest.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2018 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.widget;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.os.Parcelable;
+
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class SeekBarPreferenceTest {
+    private static final int MAX = 75;
+    private static final int MIN = 5;
+    private static final int PROGRESS = 16;
+
+    private Context mContext;
+    private SeekBarPreference mSeekBarPreference;
+
+    @Before
+    public void setUp() {
+        mContext = RuntimeEnvironment.application;
+
+        mSeekBarPreference = new SeekBarPreference(mContext);
+        mSeekBarPreference.setMax(MAX);
+        mSeekBarPreference.setMin(MIN);
+        mSeekBarPreference.setProgress(PROGRESS);
+        mSeekBarPreference.setPersistent(false);
+    }
+
+    @Test
+    public void testSaveAndRestoreInstanceState() {
+        final Parcelable parcelable = mSeekBarPreference.onSaveInstanceState();
+
+        final SeekBarPreference preference = new SeekBarPreference(mContext);
+        preference.onRestoreInstanceState(parcelable);
+
+        assertThat(preference.getMax()).isEqualTo(MAX);
+        assertThat(preference.getMin()).isEqualTo(MIN);
+        assertThat(preference.getProgress()).isEqualTo(PROGRESS);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/ConnectedAccessPointPreferenceTest.java b/tests/robotests/src/com/android/settings/wifi/ConnectedAccessPointPreferenceTest.java
index 2eaa587..c122a65 100644
--- a/tests/robotests/src/com/android/settings/wifi/ConnectedAccessPointPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/ConnectedAccessPointPreferenceTest.java
@@ -16,6 +16,8 @@
 
 package com.android.settings.wifi;
 
+import static com.google.common.truth.Truth.assertThat;
+
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
@@ -75,4 +77,9 @@
         verify(mOnGearClickListener, never()).onGearClick(mConnectedAccessPointPreference);
     }
 
+    @Test
+    public void testWidgetLayoutPreference() {
+        assertThat(mConnectedAccessPointPreference.getWidgetLayoutResource()).isEqualTo(
+                R.layout.preference_widget_gear_no_bg);
+    }
 }