Merge "packages/apps/Settings: Set LOCAL_SDK_VERSION where possible."
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 0ccbbf4..e326dbe 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -313,7 +313,8 @@
 
     <!-- Bluetooth developer settings: Titles for maximum number of connected audio devices -->
     <string-array name="bluetooth_max_connected_audio_devices">
-        <item>1 (Default)</item>
+        <item>Use System Default: <xliff:g id="default_bluetooth_max_connected_audio_devices">%1$d</xliff:g></item>
+        <item>1</item>
         <item>2</item>
         <item>3</item>
         <item>4</item>
@@ -321,7 +322,8 @@
     </string-array>
 
     <!-- Bluetooth developer settings: Values for maximum number of connected audio devices -->
-    <string-array name="bluetooth_max_connected_audio_devices_values">
+    <string-array translatable="false" name="bluetooth_max_connected_audio_devices_values">
+        <item></item>
         <item>1</item>
         <item>2</item>
         <item>3</item>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e7c7bba..38a1f6f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3371,6 +3371,8 @@
     <string name="location_app_level_permissions">App-level permissions</string>
     <!-- [CHAR LIMIT=42] Location settings screen, sub category for recent location requests -->
     <string name="location_category_recent_location_requests">Recent location requests</string>
+    <!-- Location settings screen, displayed when there're more than three recent location requests -->
+    <string name="location_recent_location_requests_see_all">See all</string>
     <!-- Location settings screen, displayed when there's no recent app accessing location -->
     <string name="location_no_recent_apps">No apps have requested location recently</string>
     <!-- [CHAR LIMIT=30] Location settings screen, sub category for location services -->
diff --git a/res/xml/app_and_notification.xml b/res/xml/app_and_notification.xml
index 84b80b8..9fc29c3 100644
--- a/res/xml/app_and_notification.xml
+++ b/res/xml/app_and_notification.xml
@@ -55,7 +55,8 @@
         android:key="manage_perms"
         android:title="@string/app_permissions"
         android:order="12"
-        settings:keywords="@string/keywords_app_permissions">
+        settings:keywords="@string/keywords_app_permissions"
+        settings:controller="com.android.settings.applications.AppPermissionsPreferenceController">
         <intent android:action="android.intent.action.MANAGE_PERMISSIONS" />
     </Preference>
 
@@ -76,4 +77,4 @@
         android:title="@string/special_access"
         android:order="20" />
 
-</PreferenceScreen>
\ No newline at end of file
+</PreferenceScreen>
diff --git a/res/xml/location_recent_requests_see_all.xml b/res/xml/location_recent_requests_see_all.xml
new file mode 100644
index 0000000..38db142
--- /dev/null
+++ b/res/xml/location_recent_requests_see_all.xml
@@ -0,0 +1,24 @@
+<?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:title="@string/location_category_recent_location_requests"
+        android:key="recent_location_requests_see_all">
+
+        <PreferenceCategory
+            android:key="all_recent_location_requests"/>
+</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/location_settings.xml b/res/xml/location_settings.xml
index 43affe6..3f96c58 100644
--- a/res/xml/location_settings.xml
+++ b/res/xml/location_settings.xml
@@ -24,6 +24,13 @@
             android:key="recent_location_requests"
             android:title="@string/location_category_recent_location_requests"/>
 
+        <Preference
+            android:key="recent_location_requests_see_all"
+            android:title="@string/location_recent_location_requests_see_all"
+            android:icon="@drawable/ic_chevron_right_24dp"
+            android:selectable="true"
+            android:fragment="com.android.settings.location.RecentLocationRequestSeeAllFragment"/>
+
         <!-- This preference category gets removed if new_recent_location_ui is disabled -->
         <Preference
             android:key="app_level_permissions"
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 63214d5..0f50d71 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -702,16 +702,16 @@
                 || somethingChanged;
 
         // Enable/disable the Me Card page.
-        final boolean isMeCardEnabled = featureFactory
+        final boolean aboutPhoneV2Enabled = featureFactory
                 .getAccountFeatureProvider()
-                .isMeCardEnabled(this);
+                .isAboutPhoneV2Enabled(this);
         somethingChanged = setTileEnabled(new ComponentName(packageName,
                         Settings.MyDeviceInfoActivity.class.getName()),
-                isMeCardEnabled, isAdmin)
+                aboutPhoneV2Enabled, isAdmin)
                 || somethingChanged;
         somethingChanged = setTileEnabled(new ComponentName(packageName,
                         Settings.DeviceInfoSettingsActivity.class.getName()),
-                !isMeCardEnabled, isAdmin)
+                !aboutPhoneV2Enabled, isAdmin)
                 || somethingChanged;
 
         if (UserHandle.MU_ENABLED && !isAdmin) {
diff --git a/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java b/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
index 0e24a10..ea212cf 100644
--- a/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
+++ b/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
@@ -49,7 +49,7 @@
         mSettingsContentObserver = new SettingObserver(settingKey) {
             @Override
             public void onChange(boolean selfChange, Uri uri) {
-                updateState(null);
+                updateState(mPreference);
             }
         };
     }
@@ -74,14 +74,6 @@
     }
 
     @Override
-    public void updateState(Preference preference) {
-        if (mPreference == null) {
-            return;
-        }
-        mPreference.setSummary(getSummary());
-    }
-
-    @Override
     public CharSequence getSummary() {
         final int intensity = Settings.System.getInt(mContext.getContentResolver(),
                 mSettingKey, getDefaultIntensity());
diff --git a/src/com/android/settings/accounts/AccountFeatureProvider.java b/src/com/android/settings/accounts/AccountFeatureProvider.java
index bbfc48a..ecde8fe 100644
--- a/src/com/android/settings/accounts/AccountFeatureProvider.java
+++ b/src/com/android/settings/accounts/AccountFeatureProvider.java
@@ -28,7 +28,7 @@
     /**
      * Checks whether or not to display the new About Phone page.
      */
-    default boolean isMeCardEnabled(Context context) {
+    default boolean isAboutPhoneV2Enabled(Context context) {
         return FeatureFlagUtils.isEnabled(context, FeatureFlags.ABOUT_PHONE_V2);
     }
 }
diff --git a/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java b/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java
index 7b62078..eb74fb1 100644
--- a/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java
+++ b/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java
@@ -75,7 +75,6 @@
         controllers.add(new EmergencyBroadcastPreferenceController(context,
                 "app_and_notif_cell_broadcast_settings"));
         controllers.add(new SpecialAppAccessPreferenceController(context));
-        controllers.add(new AppPermissionsPreferenceController(context));
         controllers.add(new RecentAppsPreferenceController(context, app, host));
         return controllers;
     }
diff --git a/src/com/android/settings/applications/AppPermissionsPreferenceController.java b/src/com/android/settings/applications/AppPermissionsPreferenceController.java
index 9bd8c0b..206ef33 100644
--- a/src/com/android/settings/applications/AppPermissionsPreferenceController.java
+++ b/src/com/android/settings/applications/AppPermissionsPreferenceController.java
@@ -19,55 +19,40 @@
 import android.content.pm.PackageManager.NameNotFoundException;
 import android.content.pm.PermissionGroupInfo;
 import android.content.pm.PermissionInfo;
-import android.support.v7.preference.Preference;
 import android.text.TextUtils;
 import android.util.ArraySet;
 import android.util.Log;
+
 import com.android.settings.R;
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settings.core.BasePreferenceController;
 
 import java.util.List;
 import java.util.Set;
 
-public class AppPermissionsPreferenceController extends AbstractPreferenceController
-        implements PreferenceControllerMixin {
+public class AppPermissionsPreferenceController extends BasePreferenceController {
 
     private static final String TAG = "AppPermissionPrefCtrl";
     private static final String KEY_APP_PERMISSION_GROUPS = "manage_perms";
     private static final String[] PERMISSION_GROUPS = new String[] {
-        "android.permission-group.LOCATION",
-        "android.permission-group.MICROPHONE",
-        "android.permission-group.CAMERA",
-        "android.permission-group.SMS",
-        "android.permission-group.CONTACTS",
-        "android.permission-group.PHONE"};
+            "android.permission-group.LOCATION",
+            "android.permission-group.MICROPHONE",
+            "android.permission-group.CAMERA",
+            "android.permission-group.SMS",
+            "android.permission-group.CONTACTS",
+            "android.permission-group.PHONE"};
 
     private static final int NUM_PERMISSION_TO_USE = 3;
 
     private final PackageManager mPackageManager;
 
     public AppPermissionsPreferenceController(Context context) {
-        super(context);
+        super(context, KEY_APP_PERMISSION_GROUPS);
         mPackageManager = context.getPackageManager();
     }
 
     @Override
-    public boolean isAvailable() {
-        return true;
-    }
-
-    @Override
-    public String getPreferenceKey() {
-        return KEY_APP_PERMISSION_GROUPS;
-    }
-
-    @Override
-    public void updateState(Preference preference) {
-        final CharSequence summary = getSummary();
-        if (summary != null) {
-            preference.setSummary(summary);
-        }
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
     }
 
     /*
@@ -96,7 +81,7 @@
     private Set<String> getGrantedPermissionGroups(Set<String> permissions) {
         ArraySet<String> grantedPermissionGroups = new ArraySet<>();
         List<PackageInfo> installedPackages =
-            mPackageManager.getInstalledPackages(PackageManager.GET_PERMISSIONS);
+                mPackageManager.getInstalledPackages(PackageManager.GET_PERMISSIONS);
         for (PackageInfo installedPackage : installedPackages) {
             if (installedPackage.permissions == null) {
                 continue;
@@ -134,12 +119,12 @@
         for (String group : PERMISSION_GROUPS) {
             try {
                 final List<PermissionInfo> permissions =
-                    mPackageManager.queryPermissionsByGroup(group, 0);
+                        mPackageManager.queryPermissionsByGroup(group, 0);
                 for (PermissionInfo permissionInfo : permissions) {
                     result.add(permissionInfo.name);
                 }
             } catch (NameNotFoundException e) {
-                Log.e(TAG, "Error getting permissions in group "+group, e);
+                Log.e(TAG, "Error getting permissions in group " + group, e);
             }
         }
         return result;
diff --git a/src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBase.java b/src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBase.java
index 8952de0..cf1731d 100644
--- a/src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBase.java
+++ b/src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBase.java
@@ -50,11 +50,6 @@
     }
 
     @Override
-    public void updateState(Preference preference) {
-        preference.setSummary(getSummary());
-    }
-
-    @Override
     public CharSequence getSummary() {
         int summaryResId = isDefaultApp() ? R.string.yes : R.string.no;
         return mContext.getText(summaryResId);
diff --git a/src/com/android/settings/applications/appinfo/DrawOverlayDetailPreferenceController.java b/src/com/android/settings/applications/appinfo/DrawOverlayDetailPreferenceController.java
index 21c6195..ca63575 100644
--- a/src/com/android/settings/applications/appinfo/DrawOverlayDetailPreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/DrawOverlayDetailPreferenceController.java
@@ -21,7 +21,6 @@
 import android.content.Context;
 import android.content.pm.PackageInfo;
 import android.os.UserManager;
-import android.support.v7.preference.Preference;
 
 import com.android.settings.SettingsPreferenceFragment;
 
@@ -51,11 +50,6 @@
     }
 
     @Override
-    public void updateState(Preference preference) {
-        preference.setSummary(getSummary());
-    }
-
-    @Override
     protected Class<? extends SettingsPreferenceFragment> getDetailFragmentClass() {
         return DrawOverlayDetails.class;
     }
diff --git a/src/com/android/settings/applications/appinfo/WriteSystemSettingsPreferenceController.java b/src/com/android/settings/applications/appinfo/WriteSystemSettingsPreferenceController.java
index ec69b85..71532ea 100644
--- a/src/com/android/settings/applications/appinfo/WriteSystemSettingsPreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/WriteSystemSettingsPreferenceController.java
@@ -21,7 +21,6 @@
 import android.content.Context;
 import android.content.pm.PackageInfo;
 import android.os.UserManager;
-import android.support.v7.preference.Preference;
 
 import com.android.settings.SettingsPreferenceFragment;
 
@@ -52,11 +51,6 @@
     }
 
     @Override
-    public void updateState(Preference preference) {
-        preference.setSummary(getSummary());
-    }
-
-    @Override
     protected Class<? extends SettingsPreferenceFragment> getDetailFragmentClass() {
         return WriteSettingsDetails.class;
     }
diff --git a/src/com/android/settings/backup/BackupSettingsActivityPreferenceController.java b/src/com/android/settings/backup/BackupSettingsActivityPreferenceController.java
index 1070ae9..183d13f 100644
--- a/src/com/android/settings/backup/BackupSettingsActivityPreferenceController.java
+++ b/src/com/android/settings/backup/BackupSettingsActivityPreferenceController.java
@@ -19,7 +19,6 @@
 import android.app.backup.BackupManager;
 import android.content.Context;
 import android.os.UserManager;
-import android.support.v7.preference.Preference;
 
 import com.android.settings.R;
 import com.android.settings.core.BasePreferenceController;
@@ -46,11 +45,6 @@
     }
 
     @Override
-    public void updateState(Preference preference) {
-        preference.setSummary(getSummary());
-    }
-
-    @Override
     public CharSequence getSummary() {
         final boolean backupEnabled = mBackupManager.isBackupEnabled();
 
diff --git a/src/com/android/settings/core/PreferenceControllerListHelper.java b/src/com/android/settings/core/PreferenceControllerListHelper.java
index d955301..bec7c09 100644
--- a/src/com/android/settings/core/PreferenceControllerListHelper.java
+++ b/src/com/android/settings/core/PreferenceControllerListHelper.java
@@ -41,7 +41,7 @@
  */
 public class PreferenceControllerListHelper {
 
-    private static final String TAG = "PrefCtrlListCreator";
+    private static final String TAG = "PrefCtrlListHelper";
 
     /**
      * Instantiates a list of controller based on xml definition.
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 468bd3d..51e151e 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -28,6 +28,7 @@
 import com.android.settings.TestingSettings;
 import com.android.settings.TetherSettings;
 import com.android.settings.TrustedCredentialsSettings;
+import com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment;
 import com.android.settings.wifi.calling.WifiCallingSettings;
 import com.android.settings.accessibility.AccessibilitySettings;
 import com.android.settings.accessibility.AccessibilitySettingsForSetupWizard;
@@ -154,6 +155,7 @@
             UserDictionarySettings.class.getName(),
             DisplaySettings.class.getName(),
             DeviceInfoSettings.class.getName(),
+            MyDeviceInfoFragment.class.getName(),
             ManageApplications.class.getName(),
             ManageAssist.class.getName(),
             ProcessStatsUi.class.getName(),
diff --git a/src/com/android/settings/dashboard/conditional/BackgroundDataCondition.java b/src/com/android/settings/dashboard/conditional/BackgroundDataCondition.java
index cbac86f..34172c2 100644
--- a/src/com/android/settings/dashboard/conditional/BackgroundDataCondition.java
+++ b/src/com/android/settings/dashboard/conditional/BackgroundDataCondition.java
@@ -18,9 +18,12 @@
 import android.content.Intent;
 import android.graphics.drawable.Icon;
 import android.net.NetworkPolicyManager;
+import android.util.FeatureFlagUtils;
+
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.R;
 import com.android.settings.Settings;
+import com.android.settings.core.FeatureFlags;
 
 public class BackgroundDataCondition extends Condition {
 
@@ -55,8 +58,12 @@
 
     @Override
     public void onPrimaryClick() {
-        mManager.getContext().startActivity(new Intent(mManager.getContext(),
-                Settings.DataUsageSummaryActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
+        final Class activityClass = FeatureFlagUtils.isEnabled(mManager.getContext(),
+                FeatureFlags.DATA_USAGE_SETTINGS_V2)
+                ? Settings.DataUsageSummaryActivity.class
+                : Settings.DataUsageSummaryLegacyActivity.class;
+        mManager.getContext().startActivity(new Intent(mManager.getContext(), activityClass)
+                .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
     }
 
     @Override
diff --git a/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceController.java b/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceController.java
index 5512685..79187f5 100644
--- a/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceController.java
+++ b/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceController.java
@@ -22,9 +22,7 @@
 import android.support.v7.preference.ListPreference;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceScreen;
-import android.text.TextUtils;
 
-import com.android.settings.R;
 import com.android.settings.core.PreferenceControllerMixin;
 import com.android.settingslib.development.DeveloperOptionsPreferenceController;
 
@@ -32,58 +30,65 @@
         DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener,
         PreferenceControllerMixin {
 
-    private static final String BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_KEY =
+    private static final String MAX_CONNECTED_AUDIO_DEVICES_PREFERENCE_KEY =
             "bluetooth_max_connected_audio_devices";
 
     @VisibleForTesting
-    static final String BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY =
+    static final String MAX_CONNECTED_AUDIO_DEVICES_PROPERTY =
             "persist.bluetooth.maxconnectedaudiodevices";
 
-    private final String[] mListValues;
-    private final String[] mListSummaries;
+    private final int mDefaultMaxConnectedAudioDevices;
     private ListPreference mPreference;
 
     public BluetoothMaxConnectedAudioDevicesPreferenceController(Context context) {
         super(context);
-
-        mListValues = context.getResources()
-                .getStringArray(R.array.bluetooth_max_connected_audio_devices_values);
-        mListSummaries = context.getResources()
-                .getStringArray(R.array.bluetooth_max_connected_audio_devices);
+        mDefaultMaxConnectedAudioDevices = mContext.getResources().getInteger(
+                com.android.internal.R.integer.config_bluetooth_max_connected_audio_devices);
     }
 
     @Override
     public String getPreferenceKey() {
-        return BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_KEY;
+        return MAX_CONNECTED_AUDIO_DEVICES_PREFERENCE_KEY;
     }
 
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-
         mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
+        final CharSequence[] entries = mPreference.getEntries();
+        entries[0] = String.format(entries[0].toString(), mDefaultMaxConnectedAudioDevices);
+        mPreference.setEntries(entries);
     }
 
     @Override
     public boolean onPreferenceChange(Preference preference, Object newValue) {
-        SystemProperties.set(BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, newValue.toString());
+        String newValueString = newValue.toString();
+        final ListPreference listPreference = (ListPreference) preference;
+        if (listPreference.findIndexOfValue(newValueString) <= 0) {
+            // Reset property value when default is chosen or when value is illegal
+            newValueString = "";
+        }
+        SystemProperties.set(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, newValueString);
         updateState(preference);
         return true;
     }
 
     @Override
     public void updateState(Preference preference) {
-        final String currentValue = SystemProperties.get(
-                BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY);
-        int index = 0; // Defaults to 1 device
-        for (int i = 0; i < mListValues.length; i++) {
-            if (TextUtils.equals(currentValue, mListValues[i])) {
-                index = i;
-                break;
+        final ListPreference listPreference = (ListPreference) preference;
+        final CharSequence[] entries = listPreference.getEntries();
+        final String currentValue = SystemProperties.get(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY);
+        int index = 0;
+        if (!currentValue.isEmpty()) {
+            index = listPreference.findIndexOfValue(currentValue);
+            if (index < 0) {
+                // Reset property value when value is illegal
+                SystemProperties.set(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, "");
+                index = 0;
             }
         }
-        mPreference.setValue(mListValues[index]);
-        mPreference.setSummary(mListSummaries[index]);
+        listPreference.setValueIndex(index);
+        listPreference.setSummary(entries[index]);
     }
 
     @Override
@@ -95,9 +100,8 @@
     @Override
     protected void onDeveloperOptionsSwitchDisabled() {
         mPreference.setEnabled(false);
-        SystemProperties.set(BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, mListValues[0]);
-        mPreference.setValue(mListValues[0]);
-        mPreference.setSummary(mListSummaries[0]);
+        SystemProperties.set(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, "");
+        updateState(mPreference);
     }
 }
 
diff --git a/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java b/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
index 05fe326..8a2d5e3 100644
--- a/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
+++ b/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
@@ -62,7 +62,7 @@
 import java.util.List;
 
 public class MyDeviceInfoFragment extends DashboardFragment {
-    private static final String LOG_TAG = "MeCardFragment";
+    private static final String LOG_TAG = "MyDeviceInfoFragment";
 
     private static final String KEY_MY_DEVICE_INFO_HEADER = "my_device_info_header";
     private static final String KEY_LEGAL_CONTAINER = "legal_container";
diff --git a/src/com/android/settings/display/ColorModePreferenceController.java b/src/com/android/settings/display/ColorModePreferenceController.java
index 2ab2ec9..7fa9782 100644
--- a/src/com/android/settings/display/ColorModePreferenceController.java
+++ b/src/com/android/settings/display/ColorModePreferenceController.java
@@ -21,31 +21,47 @@
 import android.util.Log;
 
 import com.android.internal.annotations.VisibleForTesting;
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.internal.app.ColorDisplayController;
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
 
-public class ColorModePreferenceController extends AbstractPreferenceController implements
-        PreferenceControllerMixin {
+public class ColorModePreferenceController extends BasePreferenceController {
     private static final String TAG = "ColorModePreference";
     private static final String KEY_COLOR_MODE = "color_mode";
 
     private static final int SURFACE_FLINGER_TRANSACTION_QUERY_WIDE_COLOR = 1024;
 
     private final ConfigurationWrapper mConfigWrapper;
+    private ColorDisplayController mColorDisplayController;
 
     public ColorModePreferenceController(Context context) {
-        super(context);
+        super(context, KEY_COLOR_MODE);
         mConfigWrapper = new ConfigurationWrapper();
     }
 
     @Override
-    public String getPreferenceKey() {
-        return KEY_COLOR_MODE;
+    public int getAvailabilityStatus() {
+        return mConfigWrapper.isScreenWideColorGamut() ? AVAILABLE : DISABLED_FOR_USER;
     }
 
     @Override
-    public boolean isAvailable() {
-        return mConfigWrapper.isScreenWideColorGamut();
+    public CharSequence getSummary() {
+        final int colorMode = getColorDisplayController().getColorMode();
+        if (colorMode == ColorDisplayController.COLOR_MODE_SATURATED) {
+            return mContext.getText(R.string.color_mode_option_saturated);
+        }
+        if (colorMode == ColorDisplayController.COLOR_MODE_BOOSTED) {
+            return mContext.getText(R.string.color_mode_option_boosted);
+        }
+        return mContext.getText(R.string.color_mode_option_natural);
+    }
+
+    @VisibleForTesting
+    ColorDisplayController getColorDisplayController() {
+        if (mColorDisplayController == null) {
+            mColorDisplayController = new ColorDisplayController(mContext);
+        }
+        return mColorDisplayController;
     }
 
     @VisibleForTesting
diff --git a/src/com/android/settings/gestures/GesturesSettingPreferenceController.java b/src/com/android/settings/gestures/GesturesSettingPreferenceController.java
index 3a74a8c..1df5b90 100644
--- a/src/com/android/settings/gestures/GesturesSettingPreferenceController.java
+++ b/src/com/android/settings/gestures/GesturesSettingPreferenceController.java
@@ -19,7 +19,6 @@
 import android.content.ContentResolver;
 import android.content.Context;
 import android.provider.Settings;
-import android.support.v7.preference.Preference;
 
 import com.android.internal.hardware.AmbientDisplayConfiguration;
 import com.android.settings.R;
@@ -56,11 +55,6 @@
     }
 
     @Override
-    public void updateState(Preference preference) {
-        preference.setSummary(getSummary());
-    }
-
-    @Override
     public CharSequence getSummary() {
         if (!mFeatureProvider.isSensorAvailable(mContext)) {
             return "";
diff --git a/src/com/android/settings/location/LocationSettings.java b/src/com/android/settings/location/LocationSettings.java
index 153403a..a6feacc 100644
--- a/src/com/android/settings/location/LocationSettings.java
+++ b/src/com/android/settings/location/LocationSettings.java
@@ -70,8 +70,10 @@
     public int getInitialExpandedChildCount() {
         final RecentLocationApps recentLocationApps = new RecentLocationApps(getActivity());
         final int locationRequestsApps = recentLocationApps.getAppList().size();
-        final int locationRequestsPrefs = locationRequestsApps == 0 ? 1 : locationRequestsApps;
-        return locationRequestsPrefs + 2;
+        final int locationRequestsPrefs =
+                locationRequestsApps == 0
+                        ? 1 : (locationRequestsApps > 3 ? 4 : locationRequestsApps);
+        return locationRequestsPrefs + 1;
     }
 
     @Override
diff --git a/src/com/android/settings/location/RecentLocationRequestPreferenceController.java b/src/com/android/settings/location/RecentLocationRequestPreferenceController.java
index 8238a9b..b017ec1 100644
--- a/src/com/android/settings/location/RecentLocationRequestPreferenceController.java
+++ b/src/com/android/settings/location/RecentLocationRequestPreferenceController.java
@@ -20,32 +20,33 @@
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceCategory;
 import android.support.v7.preference.PreferenceScreen;
-
 import com.android.settings.R;
 import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
 import com.android.settings.core.SubSettingLauncher;
+import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.widget.AppPreference;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 import com.android.settingslib.location.RecentLocationApps;
-
-import java.util.ArrayList;
 import java.util.List;
 
 public class RecentLocationRequestPreferenceController extends LocationBasePreferenceController {
 
     /** Key for preference category "Recent location requests" */
     private static final String KEY_RECENT_LOCATION_REQUESTS = "recent_location_requests";
+    @VisibleForTesting
+    static final String KEY_SEE_ALL = "recent_location_requests_see_all";
     private final LocationSettings mFragment;
     private final RecentLocationApps mRecentLocationApps;
     private PreferenceCategory mCategoryRecentLocationRequests;
+    private Preference mSeeAllButton;
 
-    @VisibleForTesting
+    /** Used in this class and {@link RecentLocationRequestSeeAllPreferenceController}*/
     static class PackageEntryClickedListener implements Preference.OnPreferenceClickListener {
-        private final LocationSettings mFragment;
+        private final DashboardFragment mFragment;
         private final String mPackage;
         private final UserHandle mUserHandle;
 
-        public PackageEntryClickedListener(LocationSettings fragment, String packageName,
+        public PackageEntryClickedListener(DashboardFragment fragment, String packageName,
                 UserHandle userHandle) {
             mFragment = fragment;
             mPackage = packageName;
@@ -92,24 +93,32 @@
         super.displayPreference(screen);
         mCategoryRecentLocationRequests =
                 (PreferenceCategory) screen.findPreference(KEY_RECENT_LOCATION_REQUESTS);
+        mSeeAllButton = screen.findPreference(KEY_SEE_ALL);
+
     }
 
     @Override
     public void updateState(Preference preference) {
         mCategoryRecentLocationRequests.removeAll();
+        mSeeAllButton.setVisible(false);
 
         final Context prefContext = preference.getContext();
         final List<RecentLocationApps.Request> recentLocationRequests =
                 mRecentLocationApps.getAppListSorted();
 
-        final List<Preference> recentLocationPrefs = new ArrayList<>(recentLocationRequests.size());
-        for (final RecentLocationApps.Request request : recentLocationRequests) {
-            recentLocationPrefs.add(createAppPreference(prefContext, request));
-        }
-        if (recentLocationRequests.size() > 0) {
+        if (recentLocationRequests.size() > 3) {
+            // Display the top 3 preferences to container in original order.
+            for (int i = 0; i < 3; i ++) {
+                mCategoryRecentLocationRequests.addPreference(
+                        createAppPreference(prefContext, recentLocationRequests.get(i)));
+            }
+            // Display a button to list all requests
+            mSeeAllButton.setVisible(true);
+        } else if (recentLocationRequests.size() > 0) {
             // Add preferences to container in original order (already sorted by recency).
-            for (Preference entry : recentLocationPrefs) {
-                mCategoryRecentLocationRequests.addPreference(entry);
+            for (RecentLocationApps.Request request : recentLocationRequests) {
+                mCategoryRecentLocationRequests.addPreference(
+                        createAppPreference(prefContext, request));
             }
         } else {
             // If there's no item to display, add a "No recent apps" item.
@@ -132,7 +141,7 @@
 
     @VisibleForTesting
     AppPreference createAppPreference(Context prefContext, RecentLocationApps.Request request) {
-        final AppPreference pref =  createAppPreference(prefContext);
+        final AppPreference pref = createAppPreference(prefContext);
         pref.setSummary(request.contentDescription);
         pref.setIcon(request.icon);
         pref.setTitle(request.label);
diff --git a/src/com/android/settings/location/RecentLocationRequestSeeAllFragment.java b/src/com/android/settings/location/RecentLocationRequestSeeAllFragment.java
new file mode 100644
index 0000000..0b7614c
--- /dev/null
+++ b/src/com/android/settings/location/RecentLocationRequestSeeAllFragment.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright 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.location;
+
+
+import android.content.Context;
+import android.provider.SearchIndexableResource;
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+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;
+
+/** Dashboard Fragment to display all recent location requests, sorted by recency. */
+public class RecentLocationRequestSeeAllFragment extends DashboardFragment {
+
+    private static final String TAG = "RecentLocationReqAll";
+
+    public static final String PATH =
+            "com.android.settings.location.RecentLocationRequestSeeAllFragment";
+
+    @Override
+    public int getMetricsCategory() {
+      return MetricsEvent.RECENT_LOCATION_REQUESTS_ALL;
+    }
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.location_recent_requests_see_all;
+    }
+
+    @Override
+    protected String getLogTag() {
+      return TAG;
+    }
+
+    @Override
+    protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
+        return buildPreferenceControllers(context, getLifecycle(), this);
+    }
+
+    private static List<AbstractPreferenceController> buildPreferenceControllers(
+            Context context, Lifecycle lifecycle, RecentLocationRequestSeeAllFragment fragment) {
+        final List<AbstractPreferenceController> controllers = new ArrayList<>();
+        controllers.add(
+                new RecentLocationRequestSeeAllPreferenceController(context, lifecycle, fragment));
+        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.location_recent_requests_see_all;
+                    return Arrays.asList(sir);
+                }
+
+                @Override
+                public List<AbstractPreferenceController> getPreferenceControllers(Context
+                        context) {
+                    return buildPreferenceControllers(
+                            context, /* lifecycle = */ null, /* fragment = */ null);
+                }
+            };
+}
diff --git a/src/com/android/settings/location/RecentLocationRequestSeeAllPreferenceController.java b/src/com/android/settings/location/RecentLocationRequestSeeAllPreferenceController.java
new file mode 100644
index 0000000..4b59df2
--- /dev/null
+++ b/src/com/android/settings/location/RecentLocationRequestSeeAllPreferenceController.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 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.location;
+
+import android.content.Context;
+import android.support.annotation.VisibleForTesting;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceCategory;
+import android.support.v7.preference.PreferenceScreen;
+import com.android.settings.widget.AppPreference;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.location.RecentLocationApps;
+import java.util.List;
+
+/** Preference controller for preference category displaying all recent location requests. */
+public class RecentLocationRequestSeeAllPreferenceController
+        extends LocationBasePreferenceController {
+
+    /** Key for preference category "All recent location requests" */
+    private static final String KEY_ALL_RECENT_LOCATION_REQUESTS = "all_recent_location_requests";
+    private final RecentLocationRequestSeeAllFragment mFragment;
+    private PreferenceCategory mCategoryAllRecentLocationRequests;
+    private RecentLocationApps mRecentLocationApps;
+
+    public RecentLocationRequestSeeAllPreferenceController(
+            Context context, Lifecycle lifecycle, RecentLocationRequestSeeAllFragment fragment) {
+        this(context, lifecycle, fragment, new RecentLocationApps(context));
+    }
+
+    @VisibleForTesting
+    RecentLocationRequestSeeAllPreferenceController(
+            Context context,
+            Lifecycle lifecycle,
+            RecentLocationRequestSeeAllFragment fragment,
+            RecentLocationApps recentLocationApps) {
+        super(context, lifecycle);
+        mFragment = fragment;
+        mRecentLocationApps = recentLocationApps;
+    }
+
+    @Override
+    public String getPreferenceKey() {
+        return KEY_ALL_RECENT_LOCATION_REQUESTS;
+    }
+
+    @Override
+    public void onLocationModeChanged(int mode, boolean restricted) {
+        mCategoryAllRecentLocationRequests.setEnabled(mLocationEnabler.isEnabled(mode));
+    }
+
+    @Override
+    public void displayPreference(PreferenceScreen screen) {
+        super.displayPreference(screen);
+        mCategoryAllRecentLocationRequests =
+                (PreferenceCategory) screen.findPreference(KEY_ALL_RECENT_LOCATION_REQUESTS);
+
+    }
+
+    @Override
+    public void updateState(Preference preference) {
+        mCategoryAllRecentLocationRequests.removeAll();
+        List<RecentLocationApps.Request> requests = mRecentLocationApps.getAppListSorted();
+        for (RecentLocationApps.Request request : requests) {
+            Preference appPreference = createAppPreference(preference.getContext(), request);
+            mCategoryAllRecentLocationRequests.addPreference(appPreference);
+        }
+    }
+
+    @VisibleForTesting
+    AppPreference createAppPreference(
+            Context prefContext, RecentLocationApps.Request request) {
+        final AppPreference pref = new AppPreference(prefContext);
+        pref.setSummary(request.contentDescription);
+        pref.setIcon(request.icon);
+        pref.setTitle(request.label);
+        pref.setOnPreferenceClickListener(
+                new RecentLocationRequestPreferenceController.PackageEntryClickedListener(
+                        mFragment, request.packageName, request.userHandle));
+        return pref;
+    }
+}
diff --git a/src/com/android/settings/network/MobileNetworkPreferenceController.java b/src/com/android/settings/network/MobileNetworkPreferenceController.java
index 1670b0d..09f0f8b 100644
--- a/src/com/android/settings/network/MobileNetworkPreferenceController.java
+++ b/src/com/android/settings/network/MobileNetworkPreferenceController.java
@@ -32,11 +32,11 @@
 import com.android.settingslib.Utils;
 import com.android.settingslib.core.AbstractPreferenceController;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.core.lifecycle.events.OnPause;
-import com.android.settingslib.core.lifecycle.events.OnResume;
+import com.android.settingslib.core.lifecycle.events.OnStart;
+import com.android.settingslib.core.lifecycle.events.OnStop;
 
 public class MobileNetworkPreferenceController extends AbstractPreferenceController
-        implements PreferenceControllerMixin, LifecycleObserver, OnResume, OnPause {
+        implements PreferenceControllerMixin, LifecycleObserver, OnStart, OnStop {
 
     private static final String KEY_MOBILE_NETWORK_SETTINGS = "mobile_network_settings";
 
@@ -71,9 +71,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        if (isAvailable()) {
-            mPreference = screen.findPreference(getPreferenceKey());
-        }
+        mPreference = screen.findPreference(getPreferenceKey());
     }
 
     @Override
@@ -82,15 +80,13 @@
     }
 
     @Override
-    public void onResume() {
+    public void onStart() {
         if (isAvailable()) {
             if (mPhoneStateListener == null) {
                 mPhoneStateListener = new PhoneStateListener() {
                     @Override
                     public void onServiceStateChanged(ServiceState serviceState) {
-                        if (mPreference != null) {
-                            mPreference.setSummary(mTelephonyManager.getNetworkOperatorName());
-                        }
+                        updateState(mPreference);
                     }
                 };
             }
@@ -99,9 +95,14 @@
     }
 
     @Override
-    public void onPause() {
+    public void onStop() {
         if (mPhoneStateListener != null) {
             mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
         }
     }
+
+    @Override
+    public CharSequence getSummary() {
+        return mTelephonyManager.getNetworkOperatorName();
+    }
 }
diff --git a/src/com/android/settings/notification/HeaderPreferenceController.java b/src/com/android/settings/notification/HeaderPreferenceController.java
index 1247659..f30abf4 100644
--- a/src/com/android/settings/notification/HeaderPreferenceController.java
+++ b/src/com/android/settings/notification/HeaderPreferenceController.java
@@ -51,6 +51,7 @@
         return mAppRow != null;
     }
 
+    @Override
     public void updateState(Preference preference) {
         if (mAppRow != null && mFragment != null) {
             LayoutPreference pref = (LayoutPreference) preference;
diff --git a/src/com/android/settings/password/ChooseLockPassword.java b/src/com/android/settings/password/ChooseLockPassword.java
index a9c5c03..38fdbce 100644
--- a/src/com/android/settings/password/ChooseLockPassword.java
+++ b/src/com/android/settings/password/ChooseLockPassword.java
@@ -279,7 +279,7 @@
                     0,
                     0,
                     0,
-                    R.string.next_label);
+                    R.string.lockpassword_confirm_label);
 
             Stage(int hintInAlpha, int hintInAlphaForFingerprint,
                     int hintInNumeric, int hintInNumericForFingerprint,
@@ -885,7 +885,7 @@
                 // Hide password requirement view when we are just asking user to confirm the pw.
                 mPasswordRestrictionView.setVisibility(View.GONE);
                 setHeaderText(getString(mUiStage.getHint(mIsAlphaMode, mForFingerprint)));
-                setNextEnabled(canInput && length > 0);
+                setNextEnabled(canInput && length >= mPasswordMinLength);
                 mClearButton.setEnabled(canInput && length > 0);
             }
             int message = mUiStage.getMessage(mIsAlphaMode, mForFingerprint);
diff --git a/src/com/android/settings/print/PrintSettingPreferenceController.java b/src/com/android/settings/print/PrintSettingPreferenceController.java
index 7fb6734..a589770 100644
--- a/src/com/android/settings/print/PrintSettingPreferenceController.java
+++ b/src/com/android/settings/print/PrintSettingPreferenceController.java
@@ -84,10 +84,7 @@
 
     @Override
     public void updateState(Preference preference) {
-        if (preference == null) {
-            return;
-        }
-        preference.setSummary(getSummary());
+        super.updateState(preference);
         ((RestrictedPreference) preference).checkRestrictionAndSetDisabled(
                 UserManager.DISALLOW_PRINTING);
     }
diff --git a/src/com/android/settings/search/SearchIndexableResourcesImpl.java b/src/com/android/settings/search/SearchIndexableResourcesImpl.java
index f8da560..87c2a91 100644
--- a/src/com/android/settings/search/SearchIndexableResourcesImpl.java
+++ b/src/com/android/settings/search/SearchIndexableResourcesImpl.java
@@ -65,6 +65,7 @@
 import com.android.settings.inputmethod.VirtualKeyboardFragment;
 import com.android.settings.language.LanguageAndInputSettings;
 import com.android.settings.location.LocationSettings;
+import com.android.settings.location.RecentLocationRequestSeeAllFragment;
 import com.android.settings.location.ScanningSettings;
 import com.android.settings.network.NetworkDashboardFragment;
 import com.android.settings.nfc.PaymentSettings;
@@ -177,6 +178,7 @@
         addIndex(SmartBatterySettings.class);
         addIndex(MyDeviceInfoFragment.class);
         addIndex(VibrationSettings.class);
+        addIndex(RecentLocationRequestSeeAllFragment.class);
     }
 
     @Override
diff --git a/src/com/android/settings/security/ScreenPinningPreferenceController.java b/src/com/android/settings/security/ScreenPinningPreferenceController.java
index 36b25a3..a90746e 100644
--- a/src/com/android/settings/security/ScreenPinningPreferenceController.java
+++ b/src/com/android/settings/security/ScreenPinningPreferenceController.java
@@ -18,7 +18,6 @@
 
 import android.content.Context;
 import android.provider.Settings;
-import android.support.v7.preference.Preference;
 
 import com.android.settings.R;
 import com.android.settings.core.BasePreferenceController;
@@ -44,10 +43,4 @@
                 ? mContext.getText(R.string.switch_on_text)
                 : mContext.getText(R.string.switch_off_text);
     }
-
-    @Override
-    public void updateState(Preference preference) {
-        super.updateState(preference);
-        preference.setSummary(getSummary());
-    }
 }
diff --git a/src/com/android/settings/shortcut/CreateShortcut.java b/src/com/android/settings/shortcut/CreateShortcut.java
index 2bd9b761..b078740 100644
--- a/src/com/android/settings/shortcut/CreateShortcut.java
+++ b/src/com/android/settings/shortcut/CreateShortcut.java
@@ -71,7 +71,7 @@
     @VisibleForTesting
     Intent createResultIntent(Intent shortcutIntent, ResolveInfo resolveInfo,
             CharSequence label) {
-        shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
+        shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
         ShortcutManager sm = getSystemService(ShortcutManager.class);
         ActivityInfo activityInfo = resolveInfo.activityInfo;
 
diff --git a/src/com/android/settings/system/SystemUpdatePreferenceController.java b/src/com/android/settings/system/SystemUpdatePreferenceController.java
index 134166f..80d4ecb 100644
--- a/src/com/android/settings/system/SystemUpdatePreferenceController.java
+++ b/src/com/android/settings/system/SystemUpdatePreferenceController.java
@@ -83,11 +83,6 @@
     }
 
     @Override
-    public void updateState(Preference preference) {
-        preference.setSummary(getSummary());
-    }
-
-    @Override
     public CharSequence getSummary() {
         final Bundle updateInfo = mUpdateManager.retrieveSystemUpdateInfo();
         CharSequence summary = mContext.getString(R.string.android_version_summary,
diff --git a/tests/robotests/assets/grandfather_not_in_search_index_provider_registry b/tests/robotests/assets/grandfather_not_in_search_index_provider_registry
index 948b14a..be3507c 100644
--- a/tests/robotests/assets/grandfather_not_in_search_index_provider_registry
+++ b/tests/robotests/assets/grandfather_not_in_search_index_provider_registry
@@ -1 +1,2 @@
 com.android.settings.display.ScreenZoomPreferenceFragmentForSetupWizard
+com.android.settings.search.indexing.FakeSettingsFragment
diff --git a/tests/robotests/assets/grandfather_not_sharing_pref_controllers_with_search_provider b/tests/robotests/assets/grandfather_not_sharing_pref_controllers_with_search_provider
index da541e2..b329072 100644
--- a/tests/robotests/assets/grandfather_not_sharing_pref_controllers_with_search_provider
+++ b/tests/robotests/assets/grandfather_not_sharing_pref_controllers_with_search_provider
@@ -1,5 +1 @@
-com.android.settings.datausage.DataUsageSummaryLegacy
 com.android.settings.fuelgauge.PowerUsageSummary
-com.android.settings.fuelgauge.PowerUsageAdvanced
-com.android.settings.search.indexing.FakeSettingsFragment
-com.android.settings.system.SystemDashboardFragment
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceControllerTest.java
index 2f55e00..32e17b9 100644
--- a/tests/robotests/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceControllerTest.java
@@ -86,25 +86,25 @@
     public void updateState_shouldRefreshSummary() {
         Settings.System.putInt(mContext.getContentResolver(),
                 NOTIFICATION_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
-        mController.updateState(null);
+        mController.updateState(mPreference);
         assertThat(mPreference.getSummary())
                 .isEqualTo(mContext.getString(R.string.accessibility_vibration_intensity_low));
 
         Settings.System.putInt(mContext.getContentResolver(),
                 NOTIFICATION_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
-        mController.updateState(null);
+        mController.updateState(mPreference);
         assertThat(mPreference.getSummary())
                 .isEqualTo(mContext.getString(R.string.accessibility_vibration_intensity_high));
 
         Settings.System.putInt(mContext.getContentResolver(),
                 NOTIFICATION_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_MEDIUM);
-        mController.updateState(null);
+        mController.updateState(mPreference);
         assertThat(mPreference.getSummary())
                 .isEqualTo(mContext.getString(R.string.accessibility_vibration_intensity_medium));
 
         Settings.System.putInt(mContext.getContentResolver(),
                 NOTIFICATION_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
-        mController.updateState(null);
+        mController.updateState(mPreference);
         assertThat(mPreference.getSummary())
                 .isEqualTo(mContext.getString(R.string.accessibility_vibration_intensity_off));
     }
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentSearchIndexProviderInspector.java b/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentSearchIndexProviderInspector.java
index 80083ed..83579b4 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentSearchIndexProviderInspector.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentSearchIndexProviderInspector.java
@@ -19,6 +19,8 @@
 import android.app.Fragment;
 import android.content.Context;
 
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.core.PreferenceControllerListHelper;
 import com.android.settings.search.DatabaseIndexingUtils;
 import com.android.settings.search.Indexable;
 import com.android.settingslib.core.AbstractPreferenceController;
@@ -58,6 +60,14 @@
         try {
             controllersFromFragment =
                     ((DashboardFragment) fragment).createPreferenceControllers(context);
+            List<BasePreferenceController> controllersFromXml = PreferenceControllerListHelper
+                    .getPreferenceControllersFromXml(context,
+                            ((DashboardFragment) fragment).getPreferenceScreenResId());
+            final List<BasePreferenceController> uniqueControllerFromXml =
+                    PreferenceControllerListHelper.filterControllers(
+                            controllersFromXml, controllersFromFragment);
+            controllersFromFragment.addAll(uniqueControllerFromXml);
+
         } catch (Throwable e) {
             // Can't do much with exception, assume the test passed.
             return true;
diff --git a/tests/robotests/src/com/android/settings/dashboard/conditional/BackgroundDataConditionTest.java b/tests/robotests/src/com/android/settings/dashboard/conditional/BackgroundDataConditionTest.java
new file mode 100644
index 0000000..be0da83
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/dashboard/conditional/BackgroundDataConditionTest.java
@@ -0,0 +1,88 @@
+/*
+ * 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.dashboard.conditional;
+
+import android.content.Context;
+import android.content.Intent;
+import android.util.FeatureFlagUtils;
+
+import com.android.settings.Settings;
+import com.android.settings.TestConfig;
+import com.android.settings.core.FeatureFlags;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowSystemProperties;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows =
+        SettingsShadowSystemProperties.class)
+public class BackgroundDataConditionTest {
+    @Mock
+    private ConditionManager mConditionManager;
+
+    private Context mContext;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mContext = spy(RuntimeEnvironment.application);
+        when(mConditionManager.getContext()).thenReturn(mContext);
+    }
+
+    @Test
+    public void onPrimaryClick_v2enabled_shouldReturnv2SummaryActivity() {
+        FeatureFlagUtils.setEnabled(mContext, FeatureFlags.DATA_USAGE_SETTINGS_V2, true);
+
+        final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
+        BackgroundDataCondition backgroundDataCondition
+                = new BackgroundDataCondition(mConditionManager);
+        backgroundDataCondition.onPrimaryClick();
+        verify(mContext).startActivity(argumentCaptor.capture());
+        Intent intent = argumentCaptor.getValue();
+
+        assertThat(intent.getComponent().getClassName()).isEqualTo(
+                Settings.DataUsageSummaryActivity.class.getName());
+    }
+
+    @Test
+    public void onPrimaryClick_v2disabled_shouldReturnLegacySummaryActivity() {
+        FeatureFlagUtils.setEnabled(mContext, FeatureFlags.DATA_USAGE_SETTINGS_V2, false);
+
+        final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
+        BackgroundDataCondition backgroundDataCondition
+                = new BackgroundDataCondition(mConditionManager);
+        backgroundDataCondition.onPrimaryClick();
+        verify(mContext).startActivity(argumentCaptor.capture());
+        Intent intent = argumentCaptor.getValue();
+
+        assertThat(intent.getComponent().getClassName()).isEqualTo(
+                Settings.DataUsageSummaryLegacyActivity.class.getName());
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceControllerTest.java
index cf892f8..cd56b78 100644
--- a/tests/robotests/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceControllerTest.java
@@ -17,13 +17,15 @@
 package com.android.settings.development;
 
 import static com.android.settings.development.BluetoothMaxConnectedAudioDevicesPreferenceController
-        .BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY;
+        .MAX_CONNECTED_AUDIO_DEVICES_PROPERTY;
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
+import android.content.res.Resources;
 import android.os.SystemProperties;
 import android.support.v7.preference.ListPreference;
 import android.support.v7.preference.PreferenceScreen;
@@ -39,6 +41,7 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
 
@@ -47,37 +50,41 @@
         sdk = TestConfig.SDK_VERSION,
         shadows = {SettingsShadowSystemProperties.class})
 public class BluetoothMaxConnectedAudioDevicesPreferenceControllerTest {
+    private static final int TEST_MAX_CONNECTED_AUDIO_DEVICES = 3;
 
     @Mock
     private PreferenceScreen mPreferenceScreen;
+    @Spy
+    private Context mSpyContext = RuntimeEnvironment.application;
+    @Spy
+    private Resources mSpyResources = RuntimeEnvironment.application.getResources();
 
-    private Context mContext;
     private ListPreference mPreference;
     private BluetoothMaxConnectedAudioDevicesPreferenceController mController;
 
-    /**
-     * 0: 1 device maximum (Default)
-     * 1: 2 devices maximum
-     * 2: 3 devices maximum
-     * 3: 4 devices maximum
-     * 4: 5 devices maximum
-     */
-    private String[] mListValues;
-    private String[] mListSummaries;
+    private CharSequence[] mListValues;
+    private CharSequence[] mListEntries;
 
     @Before
     public void setup() {
         MockitoAnnotations.initMocks(this);
-        mContext = RuntimeEnvironment.application;
-        mPreference = new ListPreference(mContext);
-        mListValues = mContext.getResources().getStringArray(
-                R.array.bluetooth_max_connected_audio_devices_values);
-        mListSummaries = mContext.getResources().getStringArray(
-                R.array.bluetooth_max_connected_audio_devices);
-        mController = new BluetoothMaxConnectedAudioDevicesPreferenceController(mContext);
+        doReturn(mSpyResources).when(mSpyContext).getResources();
+        // Get XML values without mock
+        // Setup test list preference using XML values
+        mPreference = new ListPreference(mSpyContext);
+        mPreference.setEntries(R.array.bluetooth_max_connected_audio_devices);
+        mPreference.setEntryValues(R.array.bluetooth_max_connected_audio_devices_values);
+        // Stub default max connected audio devices to a test controlled value
+        doReturn(TEST_MAX_CONNECTED_AUDIO_DEVICES).when(mSpyResources).getInteger(
+                com.android.internal.R.integer.config_bluetooth_max_connected_audio_devices);
+        // Init the actual controller
+        mController = new BluetoothMaxConnectedAudioDevicesPreferenceController(mSpyContext);
+        // Construct preference in the controller via a mocked preference screen object
         when(mPreferenceScreen.findPreference(mController.getPreferenceKey())).thenReturn(
                 mPreference);
         mController.displayPreference(mPreferenceScreen);
+        mListValues = mPreference.getEntryValues();
+        mListEntries = mPreference.getEntries();
     }
 
     @After
@@ -86,39 +93,67 @@
     }
 
     @Test
+    public void verifyResourceSizeAndRange() {
+        // Verify normal list entries and default preference entries have the same size
+        assertThat(mListEntries.length).isEqualTo(mListValues.length);
+        // Verify that list entries are formatted correctly
+        final String defaultEntry = String.format(mListEntries[0].toString(),
+                TEST_MAX_CONNECTED_AUDIO_DEVICES);
+        assertThat(mListEntries[0]).isEqualTo(defaultEntry);
+        // Update the preference
+        mController.updateState(mPreference);
+        // Verify default preference value, entry and summary
+        assertThat(mPreference.getValue()).isEqualTo(mListValues[0]);
+        assertThat(mPreference.getEntry()).isEqualTo(mListEntries[0]);
+        assertThat(mPreference.getSummary()).isEqualTo(mListEntries[0]);
+        // Verify that default system property is empty
+        assertThat(SystemProperties.get(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY)).isEmpty();
+        // Verify default property integer value
+        assertThat(SystemProperties.getInt(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY,
+                TEST_MAX_CONNECTED_AUDIO_DEVICES)).isEqualTo(TEST_MAX_CONNECTED_AUDIO_DEVICES);
+    }
+
+    @Test
     public void onPreferenceChange_setNumberOfDevices() {
-        for (int numberOfDevices = 0; numberOfDevices < mListValues.length; numberOfDevices++) {
-            mController.onPreferenceChange(mPreference, mListValues[numberOfDevices]);
-
-            final String currentValue = SystemProperties.get(
-                    BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY);
-
-            assertThat(currentValue).isEqualTo(mListValues[numberOfDevices]);
-            assertThat(mPreference.getValue()).isEqualTo(mListValues[numberOfDevices]);
-            assertThat(mPreference.getSummary()).isEqualTo(mListSummaries[numberOfDevices]);
+        for (final CharSequence newValue : mListValues) {
+            // Change preference using a list value
+            mController.onPreferenceChange(mPreference, newValue);
+            // Verify that value is set on the preference
+            assertThat(mPreference.getValue()).isEqualTo(newValue);
+            int index = mPreference.findIndexOfValue(newValue.toString());
+            assertThat(mPreference.getEntry()).isEqualTo(mListEntries[index]);
+            // Verify that system property is set correctly after the change
+            final String currentValue = SystemProperties.get(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY);
+            assertThat(currentValue).isEqualTo(mListValues[index]);
         }
     }
 
     @Test
     public void updateState_NumberOfDevicesUpdated_shouldSetPreference() {
-        for (int numberOfDevices = 0; numberOfDevices < mListValues.length; numberOfDevices++) {
-            SystemProperties.set(BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY,
-                    mListValues[numberOfDevices]);
-
+        for (int i = 0; i < mListValues.length; ++i) {
+            final String propertyValue = mListValues[i].toString();
+            SystemProperties.set(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, propertyValue);
+            // Verify that value is set on the preference
             mController.updateState(mPreference);
-
-            assertThat(mPreference.getValue()).isEqualTo(mListValues[numberOfDevices]);
-            assertThat(mPreference.getSummary()).isEqualTo(mListSummaries[numberOfDevices]);
+            assertThat(mPreference.getValue()).isEqualTo(mListValues[i]);
+            assertThat(mPreference.getEntry()).isEqualTo(mListEntries[i]);
+            assertThat(mPreference.getSummary()).isEqualTo(mListEntries[i]);
+            // Verify that property value remain unchanged
+            assertThat(SystemProperties.get(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY))
+                    .isEqualTo(propertyValue);
         }
     }
 
     @Test
     public void updateState_noValueSet_shouldSetDefaultTo1device() {
-        SystemProperties.set(BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, "garbage");
+        SystemProperties.set(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, "garbage");
         mController.updateState(mPreference);
 
+        // Verify that preference is reset back to default and property is reset to default
         assertThat(mPreference.getValue()).isEqualTo(mListValues[0]);
-        assertThat(mPreference.getSummary()).isEqualTo(mListSummaries[0]);
+        assertThat(mPreference.getEntry()).isEqualTo(mListEntries[0]);
+        assertThat(mPreference.getSummary()).isEqualTo(mListEntries[0]);
+        assertThat(SystemProperties.get(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY)).isEmpty();
     }
 
     @Test
@@ -126,26 +161,30 @@
         mController.onDeveloperOptionsSwitchDisabled();
 
         assertThat(mPreference.isEnabled()).isFalse();
+        // Verify that preference is reset back to default and property is reset to default
         assertThat(mPreference.getValue()).isEqualTo(mListValues[0]);
-        assertThat(mPreference.getSummary()).isEqualTo(mListSummaries[0]);
-        final String currentValue = SystemProperties.get(
-                BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY);
-        assertThat(currentValue).isEqualTo(mListValues[0]);
+        assertThat(mPreference.getEntry()).isEqualTo(mListEntries[0]);
+        assertThat(mPreference.getSummary()).isEqualTo(mListEntries[0]);
+        assertThat(SystemProperties.get(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY)).isEmpty();
     }
 
     @Test
     public void onDeveloperOptionsSwitchEnabled_shouldEnablePreference() {
-        for (int numberOfDevices = 0; numberOfDevices < mListValues.length; numberOfDevices++) {
+        for (int i = 0; i < mListValues.length; ++i) {
+            final String initialValue = mListValues[i].toString();
             mController.onDeveloperOptionsSwitchDisabled();
             assertThat(mPreference.isEnabled()).isFalse();
 
-            SystemProperties.set(BLUETOOTH_MAX_CONNECTED_AUDIO_DEVICES_PROPERTY,
-                    mListValues[numberOfDevices]);
+            SystemProperties.set(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, initialValue);
             mController.onDeveloperOptionsSwitchEnabled();
 
             assertThat(mPreference.isEnabled()).isTrue();
-            assertThat(mPreference.getValue()).isEqualTo(mListValues[numberOfDevices]);
-            assertThat(mPreference.getSummary()).isEqualTo(mListSummaries[numberOfDevices]);
+            assertThat(mPreference.getValue()).isEqualTo(mListValues[i]);
+            assertThat(mPreference.getEntry()).isEqualTo(mListEntries[i]);
+            assertThat(mPreference.getSummary()).isEqualTo(mListEntries[i]);
+            // Verify that property value remain unchanged
+            assertThat(SystemProperties.get(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY))
+                    .isEqualTo(initialValue);
         }
     }
 }
diff --git a/tests/robotests/src/com/android/settings/display/ColorModePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/ColorModePreferenceControllerTest.java
new file mode 100644
index 0000000..567b200
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/display/ColorModePreferenceControllerTest.java
@@ -0,0 +1,90 @@
+/*
+ * 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.display;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.support.v7.preference.Preference;
+
+import com.android.internal.app.ColorDisplayController;
+import com.android.settings.R;
+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.Mock;
+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 ColorModePreferenceControllerTest {
+
+    @Mock
+    private Preference mPreference;
+    @Mock
+    private ColorDisplayController mColorDisplayController;
+
+    private Context mContext;
+    private ColorModePreferenceController mController;
+
+    @Before
+    public void setup() {
+        MockitoAnnotations.initMocks(this);
+        mContext = RuntimeEnvironment.application;
+        mController = spy(new ColorModePreferenceController(mContext));
+        doReturn(mColorDisplayController).when(mController).getColorDisplayController();
+    }
+
+    @Test
+    public void updateState_colorModeSaturated_shouldSetSummaryToSaturated() {
+        when(mColorDisplayController.getColorMode())
+            .thenReturn(ColorDisplayController.COLOR_MODE_SATURATED);
+
+        mController.updateState(mPreference);
+
+        verify(mPreference).setSummary(mContext.getString(R.string.color_mode_option_saturated));
+    }
+
+    @Test
+    public void updateState_colorModeBoosted_shouldSetSummaryToBoosted() {
+        when(mColorDisplayController.getColorMode())
+            .thenReturn(ColorDisplayController.COLOR_MODE_BOOSTED);
+
+        mController.updateState(mPreference);
+
+        verify(mPreference).setSummary(mContext.getString(R.string.color_mode_option_boosted));
+    }
+
+    @Test
+    public void updateState_colorModeNatural_shouldSetSummaryToNatural() {
+        when(mColorDisplayController.getColorMode())
+            .thenReturn(ColorDisplayController.COLOR_MODE_NATURAL);
+
+        mController.updateState(mPreference);
+
+        verify(mPreference).setSummary(mContext.getString(R.string.color_mode_option_natural));
+    }
+
+}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
index 45edb47..b613bb3 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
@@ -71,7 +71,7 @@
     private static final int PLUGGED_IN = 1;
     private static final long REMAINING_TIME_NULL = -1;
     private static final long REMAINING_TIME = 2;
-    public static final String ENHANCED_STRING_SUFFIX = "left based on your usage";
+    public static final String ENHANCED_STRING_SUFFIX = "based on your usage";
     public static final long TEST_CHARGE_TIME_REMAINING = TimeUnit.MINUTES.toMicros(1);
     public static final String TEST_CHARGE_TIME_REMAINING_STRINGIFIED =
             "1m left until fully charged";
@@ -183,7 +183,7 @@
         // Check that strings are showing less than 15 minutes remaining regardless of exact time.
         assertThat(info.chargeLabel.toString()).isEqualTo(
                 mContext.getString(R.string.power_remaining_less_than_duration,
-                        TEST_BATTERY_LEVEL_10, FIFTEEN_MIN_FORMATTED));
+                        FIFTEEN_MIN_FORMATTED, TEST_BATTERY_LEVEL_10));
         assertThat(info.remainingLabel.toString()).isEqualTo(
                 mContext.getString(R.string.power_remaining_less_than_duration_only,
                         FIFTEEN_MIN_FORMATTED));
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryLegacyTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryLegacyTest.java
index c4b6aea..329665b 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryLegacyTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryLegacyTest.java
@@ -445,19 +445,6 @@
                 eq(Bundle.EMPTY), any());
     }
 
-    @Ignore("b/73892008")
-    @Test
-    public void testShowBothEstimates_summariesAreBothModified() {
-        doReturn(new TextView(mRealContext)).when(mBatteryLayoutPref).findViewById(R.id.summary2);
-        doReturn(new TextView(mRealContext)).when(mBatteryLayoutPref).findViewById(R.id.summary1);
-        mFragment.onLongClick(new View(mRealContext));
-        TextView summary1 = mFragment.mBatteryLayoutPref.findViewById(R.id.summary1);
-        TextView summary2 = mFragment.mBatteryLayoutPref.findViewById(R.id.summary2);
-        Robolectric.flushBackgroundThreadScheduler();
-        assertThat(summary2.getText().toString()).contains(NEW_ML_EST_SUFFIX);
-        assertThat(summary1.getText().toString()).contains(OLD_EST_SUFFIX);
-    }
-
     @Test
     public void testSaveInstanceState_showAllAppsRestored() {
         Bundle bundle = new Bundle();
diff --git a/tests/robotests/src/com/android/settings/location/RecentLocationRequestPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/RecentLocationRequestPreferenceControllerTest.java
index a339451..1bacd5b 100644
--- a/tests/robotests/src/com/android/settings/location/RecentLocationRequestPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/location/RecentLocationRequestPreferenceControllerTest.java
@@ -22,6 +22,7 @@
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
@@ -34,7 +35,6 @@
 import android.support.v7.preference.PreferenceCategory;
 import android.support.v7.preference.PreferenceScreen;
 import android.text.TextUtils;
-
 import com.android.settings.R;
 import com.android.settings.TestConfig;
 import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
@@ -43,7 +43,8 @@
 import com.android.settingslib.core.lifecycle.Lifecycle;
 import com.android.settingslib.location.RecentLocationApps;
 import com.android.settingslib.location.RecentLocationApps.Request;
-
+import java.util.ArrayList;
+import java.util.List;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -56,9 +57,6 @@
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
 
-import java.util.ArrayList;
-import java.util.List;
-
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
 public class RecentLocationRequestPreferenceControllerTest {
@@ -71,6 +69,8 @@
     private PreferenceScreen mScreen;
     @Mock
     private RecentLocationApps mRecentLocationApps;
+    @Mock
+    private Preference mSeeAllButton;
 
     private Context mContext;
     private RecentLocationRequestPreferenceController mController;
@@ -86,6 +86,7 @@
         mController = spy(new RecentLocationRequestPreferenceController(
                 mContext, mFragment, mLifecycle, mRecentLocationApps));
         when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mCategory);
+        when(mScreen.findPreference(mController.KEY_SEE_ALL)).thenReturn(mSeeAllButton);
         final String key = mController.getPreferenceKey();
         when(mCategory.getKey()).thenReturn(key);
         when(mCategory.getContext()).thenReturn(mContext);
@@ -123,38 +124,43 @@
 
     @Test
     public void updateState_hasRecentRequest_shouldRemoveAllAndAddInjectedSettings() {
-        final List<RecentLocationApps.Request> requests = new ArrayList<>();
-        final Request req1 = mock(Request.class);
-        final Request req2 = mock(Request.class);
-        requests.add(req1);
-        requests.add(req2);
+        List<Request> requests = createMockRequests(2);
         doReturn(requests).when(mRecentLocationApps).getAppListSorted();
-        final String title1 = "testTitle1";
-        final String title2 = "testTitle2";
-        final AppPreference preference1 = mock(AppPreference.class);
-        final AppPreference preference2 = mock(AppPreference.class);
-        when(preference1.getTitle()).thenReturn(title1);
-        when(preference2.getTitle()).thenReturn(title2);
-        doReturn(preference1).when(mController)
-                .createAppPreference(any(Context.class), eq(req1));
-        doReturn(preference2).when(mController)
-                .createAppPreference(any(Context.class), eq(req2));
+
         mController.displayPreference(mScreen);
         mController.updateState(mCategory);
 
         verify(mCategory).removeAll();
         // Verifies two preferences are added in original order
         InOrder inOrder = Mockito.inOrder(mCategory);
-        inOrder.verify(mCategory).addPreference(argThat(titleMatches(title1)));
-        inOrder.verify(mCategory).addPreference(argThat(titleMatches(title2)));
+        inOrder.verify(mCategory).addPreference(argThat(titleMatches("appTitle0")));
+        inOrder.verify(mCategory).addPreference(argThat(titleMatches("appTitle1")));
+    }
+
+    @Test
+    public void updateState_hasOverThreeRequests_shouldDisplaySeeAllButton() {
+        List<Request> requests = createMockRequests(6);
+        when(mRecentLocationApps.getAppListSorted()).thenReturn(requests);
+
+        mController.displayPreference(mScreen);
+        mController.updateState(mCategory);
+
+        verify(mCategory).removeAll();
+        // Verifies the first three preferences are added
+        InOrder inOrder = Mockito.inOrder(mCategory);
+        inOrder.verify(mCategory).addPreference(argThat(titleMatches("appTitle0")));
+        inOrder.verify(mCategory).addPreference(argThat(titleMatches("appTitle1")));
+        inOrder.verify(mCategory).addPreference(argThat(titleMatches("appTitle2")));
+        verify(mCategory, never()).addPreference(argThat(titleMatches("appTitle3")));
+        // Verifies the "See all" preference is visible
+        verify(mSeeAllButton).setVisible(true);
     }
 
     @Test
     public void createAppPreference_shouldAddClickListener() {
         final Request request = mock(Request.class);
         final AppPreference preference = mock(AppPreference.class);
-        doReturn(preference).when(mController)
-                .createAppPreference(any(Context.class));
+        doReturn(preference).when(mController).createAppPreference(any(Context.class));
 
         mController.createAppPreference(mContext, request);
 
@@ -190,4 +196,19 @@
         return preference -> TextUtils.equals(expected, preference.getTitle());
     }
 
-}
+    private List<RecentLocationApps.Request> createMockRequests(int count) {
+        List<RecentLocationApps.Request> requests = new ArrayList<>();
+        for (int i = 0; i < count; i++) {
+            // Add mock requests
+            Request req = mock(Request.class, "request" + i);
+            requests.add(req);
+            // Map mock AppPreferences with mock requests
+            String title = "appTitle" + i;
+            AppPreference appPreference = mock(AppPreference.class, "AppPreference" + i);
+            doReturn(title).when(appPreference).getTitle();
+            doReturn(appPreference)
+                    .when(mController).createAppPreference(any(Context.class), eq(req));
+        }
+        return requests;
+    }
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/location/RecentLocationRequestSeeAllPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/RecentLocationRequestSeeAllPreferenceControllerTest.java
new file mode 100644
index 0000000..2b64dbc
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/location/RecentLocationRequestSeeAllPreferenceControllerTest.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright 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.location;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.arch.lifecycle.LifecycleOwner;
+import android.content.Context;
+import android.provider.Settings.Secure;
+import android.support.v7.preference.PreferenceCategory;
+import android.support.v7.preference.PreferenceScreen;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.widget.AppPreference;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.location.RecentLocationApps;
+import com.android.settingslib.location.RecentLocationApps.Request;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+/** Unit tests for {@link RecentLocationRequestSeeAllPreferenceController} */
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class RecentLocationRequestSeeAllPreferenceControllerTest {
+
+    @Mock
+    RecentLocationRequestSeeAllFragment mFragment;
+    @Mock
+    private PreferenceScreen mScreen;
+    @Mock
+    private PreferenceCategory mCategory;
+    @Mock
+    private RecentLocationApps mRecentLocationApps;
+
+    private Context mContext;
+    private LifecycleOwner mLifecycleOwner;
+    private Lifecycle mLifecycle;
+    private RecentLocationRequestSeeAllPreferenceController mController;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mContext = spy(RuntimeEnvironment.application);
+        mLifecycleOwner = () -> mLifecycle;
+        mLifecycle = new Lifecycle(mLifecycleOwner);
+        mController = spy(
+                new RecentLocationRequestSeeAllPreferenceController(
+                        mContext, mLifecycle, mFragment, mRecentLocationApps));
+        when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mCategory);
+        final String key = mController.getPreferenceKey();
+        when(mCategory.getKey()).thenReturn(key);
+        when(mCategory.getContext()).thenReturn(mContext);
+    }
+
+    @Test
+    public void onLocationModeChanged_locationOn_shouldEnablePreference() {
+        mController.displayPreference(mScreen);
+
+        mController.onLocationModeChanged(Secure.LOCATION_MODE_HIGH_ACCURACY, false);
+
+        verify(mCategory).setEnabled(true);
+    }
+
+    @Test
+    public void onLocationModeChanged_locationOff_shouldDisablePreference() {
+        mController.displayPreference(mScreen);
+
+        mController.onLocationModeChanged(Secure.LOCATION_MODE_OFF, false);
+
+        verify(mCategory).setEnabled(false);
+    }
+
+    @Test
+    public void updateState_shouldRemoveAll() {
+        doReturn(Collections.EMPTY_LIST).when(mRecentLocationApps).getAppListSorted();
+
+        mController.displayPreference(mScreen);
+        mController.updateState(mCategory);
+
+        verify(mCategory).removeAll();
+    }
+
+    @Test
+    public void updateState_hasRecentLocationRequest_shouldAddPreference() {
+        Request request = mock(Request.class);
+        AppPreference appPreference = mock(AppPreference.class);
+        doReturn(appPreference)
+                .when(mController).createAppPreference(any(Context.class), eq(request));
+        when(mRecentLocationApps.getAppListSorted())
+                .thenReturn(new ArrayList<>(Arrays.asList(request)));
+
+        mController.displayPreference(mScreen);
+        mController.updateState(mCategory);
+
+        verify(mCategory).removeAll();
+        verify(mCategory).addPreference(appPreference);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/network/MobileNetworkPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/MobileNetworkPreferenceControllerTest.java
index f070f7a..bd55051 100644
--- a/tests/robotests/src/com/android/settings/network/MobileNetworkPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/MobileNetworkPreferenceControllerTest.java
@@ -15,11 +15,9 @@
  */
 package com.android.settings.network;
 
-import static android.arch.lifecycle.Lifecycle.Event.ON_PAUSE;
-import static android.arch.lifecycle.Lifecycle.Event.ON_RESUME;
-
+import static android.arch.lifecycle.Lifecycle.Event.ON_START;
+import static android.arch.lifecycle.Lifecycle.Event.ON_STOP;
 import static com.google.common.truth.Truth.assertThat;
-
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
@@ -53,10 +51,10 @@
 
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(
-    manifest = TestConfig.MANIFEST_PATH,
-    sdk = TestConfig.SDK_VERSION,
-    shadows = {ShadowRestrictedLockUtilsWrapper.class, ShadowConnectivityManager.class,
-            ShadowUserManager.class}
+        manifest = TestConfig.MANIFEST_PATH,
+        sdk = TestConfig.SDK_VERSION,
+        shadows = {ShadowRestrictedLockUtilsWrapper.class, ShadowConnectivityManager.class,
+                ShadowUserManager.class}
 )
 public class MobileNetworkPreferenceControllerTest {
 
@@ -110,11 +108,11 @@
         mLifecycle.addObserver(mController);
         doReturn(true).when(mController).isAvailable();
 
-        mLifecycle.handleLifecycleEvent(ON_RESUME);
+        mLifecycle.handleLifecycleEvent(ON_START);
         verify(mTelephonyManager).listen(mController.mPhoneStateListener,
                 PhoneStateListener.LISTEN_SERVICE_STATE);
 
-        mLifecycle.handleLifecycleEvent(ON_PAUSE);
+        mLifecycle.handleLifecycleEvent(ON_STOP);
         verify(mTelephonyManager).listen(mController.mPhoneStateListener,
                 PhoneStateListener.LISTEN_NONE);
     }
@@ -131,8 +129,8 @@
 
         // Display pref and go through lifecycle to set up listener.
         mController.displayPreference(mScreen);
-        mLifecycle.handleLifecycleEvent(ON_RESUME);
-        verify(mController).onResume();
+        mLifecycle.handleLifecycleEvent(ON_START);
+        verify(mController).onStart();
         verify(mTelephonyManager).listen(mController.mPhoneStateListener,
                 PhoneStateListener.LISTEN_SERVICE_STATE);
 
diff --git a/tests/uitests/src/com/android/settings/ui/AboutPhoneSettingsTests.java b/tests/uitests/src/com/android/settings/ui/AboutPhoneSettingsTests.java
index b92a707..738d710 100644
--- a/tests/uitests/src/com/android/settings/ui/AboutPhoneSettingsTests.java
+++ b/tests/uitests/src/com/android/settings/ui/AboutPhoneSettingsTests.java
@@ -52,10 +52,8 @@
     // TODO: retrieve using name/ids from com.android.settings package
     private static final String[] sResourceTexts = {
             "Phone number",
-            "SIM status",
-            "Model & hardware",
-            "MEID",
-            "Android version"
+            "Legal information",
+            "Regulatory labels"
     };
 
     private UiDevice mDevice;
@@ -94,11 +92,11 @@
     }
 
     @Test
-    public void testAllMenuEntriesExist() throws Exception {
+    public void testAllMenuEntriesExist() {
         searchForItemsAndTakeAction(mDevice, sResourceTexts);
     }
 
-    private void launchAboutPhoneSettings(String aboutSetting) throws Exception {
+    private void launchAboutPhoneSettings(String aboutSetting) {
         Intent aboutIntent = new Intent(aboutSetting);
         aboutIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         InstrumentationRegistry.getTargetContext().startActivity(aboutIntent);
@@ -107,8 +105,7 @@
     /**
      * Removes items found in the view and optionally takes some action.
      */
-    private void removeItemsAndTakeAction(UiDevice device, ArrayList<String> itemsLeftToFind)
-            throws Exception {
+    private void removeItemsAndTakeAction(UiDevice device, ArrayList<String> itemsLeftToFind) {
         for (Iterator<String> iterator = itemsLeftToFind.iterator(); iterator.hasNext(); ) {
             String itemText = iterator.next();
             UiObject2 item = device.wait(Until.findObject(By.text(itemText)), TIMEOUT);
@@ -124,8 +121,7 @@
      * <p>Will scroll down the screen until it has found all elements or reached the bottom.
      * This allows elements to be found and acted on even if they change order.
      */
-    private void searchForItemsAndTakeAction(UiDevice device, String[] itemsToFind)
-            throws Exception {
+    private void searchForItemsAndTakeAction(UiDevice device, String[] itemsToFind) {
 
         ArrayList<String> itemsLeftToFind = new ArrayList<>(Arrays.asList(itemsToFind));
         assertWithMessage("There must be at least one item to search for on the screen!")
diff --git a/tests/unit/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceControllerInstrumentationTest.java b/tests/unit/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceControllerInstrumentationTest.java
new file mode 100644
index 0000000..ce81667
--- /dev/null
+++ b/tests/unit/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceControllerInstrumentationTest.java
@@ -0,0 +1,64 @@
+/*
+ * 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.development;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.SmallTest;
+import android.support.test.runner.AndroidJUnit4;
+
+import com.android.settings.R;
+
+import org.hamcrest.CoreMatchers;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.Arrays;
+
+@RunWith(AndroidJUnit4.class)
+@SmallTest
+public class BluetoothMaxConnectedAudioDevicesPreferenceControllerInstrumentationTest {
+
+    private Context mTargetContext;
+    private String[] mListValues;
+    private String[] mListEntries;
+    private String mDefaultMaxConnectedAudioDevices;
+
+    @Before
+    public void setUp() throws Exception {
+        mTargetContext = InstrumentationRegistry.getTargetContext();
+        // Get XML values without mock
+        mListValues = mTargetContext.getResources()
+                .getStringArray(R.array.bluetooth_max_connected_audio_devices_values);
+        mListEntries = mTargetContext.getResources()
+                .getStringArray(R.array.bluetooth_max_connected_audio_devices);
+        mDefaultMaxConnectedAudioDevices = String.valueOf(mTargetContext.getResources()
+                .getInteger(
+                        com.android.internal.R.integer
+                                .config_bluetooth_max_connected_audio_devices));
+    }
+
+    @Test
+    public void verifyResource() {
+        // Verify normal list entries and default preference entries have the same size
+        Assert.assertEquals(mListEntries.length, mListValues.length);
+        Assert.assertThat(Arrays.asList(mListValues),
+                CoreMatchers.hasItem(mDefaultMaxConnectedAudioDevices));
+    }
+}