Merge "Fix landscape pattern enroll crash" into pi-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 14fe92b..8767198 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -207,6 +207,8 @@
                 android:value="com.android.settings.category.ia.homepage"/>
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
                 android:value="true" />
+            <meta-data android:name="android.metadata.SLICE_URI"
+                android:value="content://android.settings.slices/action/toggle_bluetooth_switch" />
         </activity>
 
         <activity android:name="AirplaneModeVoiceActivity"
@@ -2235,6 +2237,8 @@
                 android:value="com.android.settings.category.ia.homepage" />
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.fuelgauge.PowerUsageSummary" />
+            <meta-data android:name="android.metadata.SLICE_URI"
+                android:value="content://android.settings.slices/action/auto_brightness" />
         </activity>
 
         <activity
@@ -2251,6 +2255,8 @@
                 android:value="com.android.settings.fuelgauge.batterysaver.BatterySaverSettings" />
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
                 android:value="true" />
+            <meta-data android:name="android.metadata.SLICE_URI"
+                android:value="content://android.settings.slices/action/battery_saver_summary" />
         </activity>
 
         <activity android:name=".fuelgauge.BatterySaverModeVoiceActivity"
@@ -2670,6 +2676,8 @@
                 android:value="true" />
             <meta-data android:name="com.android.settings.summary"
                 android:resource="@string/sound_dashboard_summary"/>
+            <meta-data android:name="android.metadata.SLICE_URI"
+                android:value="content://android.settings.slices/action/alarm_volume" />
         </activity>
 
         <!-- Show apps for which application-level notification settings are applicable -->
diff --git a/res/drawable-nodpi/gesture_swipe_up.png b/res/drawable-nodpi/gesture_swipe_up.png
new file mode 100644
index 0000000..b9390d2
--- /dev/null
+++ b/res/drawable-nodpi/gesture_swipe_up.png
Binary files differ
diff --git a/res/layout/preference_volume_slider.xml b/res/layout/preference_volume_slider.xml
index 4bed218..7e146b8 100644
--- a/res/layout/preference_volume_slider.xml
+++ b/res/layout/preference_volume_slider.xml
@@ -56,7 +56,7 @@
                 android:layout_width="0dp"
                 android:layout_height="wrap_content"
                 android:layout_weight="1"
-                android:paddingStart="16dp"
+                android:paddingStart="12dp"
                 android:singleLine="true"
                 android:textAppearance="@android:style/TextAppearance.Material.Subhead"
                 android:textColor="?android:attr/textColorPrimary"
@@ -68,7 +68,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="match_parent"
                 android:gravity="end|center_vertical"
-                android:paddingStart="16dp"
+                android:paddingStart="12dp"
                 android:orientation="vertical"/>
         </LinearLayout>
 
@@ -80,6 +80,7 @@
             <SeekBar
                 android:id="@*android:id/seekbar"
                 android:layout_gravity="center_vertical"
+                android:paddingStart="12dp"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"/>
 
@@ -87,7 +88,7 @@
                 android:id="@+id/suppression_text"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:paddingStart="16dp"
+                android:paddingStart="12dp"
                 android:layout_gravity="center_vertical|start"
                 android:textAlignment="viewStart"
                 android:singleLine="true"
diff --git a/res/raw/gesture_swipe_up.mp4 b/res/raw/gesture_swipe_up.mp4
new file mode 100644
index 0000000..16cbb2b
--- /dev/null
+++ b/res/raw/gesture_swipe_up.mp4
Binary files differ
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 43d5563..029f2ad 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7236,7 +7236,7 @@
     <!-- Do not disturb: what to block option [CHAR LIMIT=NONE] -->
     <string name="zen_mode_block_effect_badge">Hide notification dots</string>
     <!-- Do not disturb: what to block option [CHAR LIMIT=NONE] -->
-    <string name="zen_mode_block_effect_ambient">Hide from ambient display</string>
+    <string name="zen_mode_block_effect_ambient">Don\'t wake for notifications</string>
     <!-- Do not disturb: what to block option [CHAR LIMIT=NONE] -->
     <string name="zen_mode_block_effect_list">Hide from notification list</string>
 
@@ -7330,7 +7330,7 @@
     <string name="zen_onboarding_screen_off_title">Block when the screen is off</string>
     <string name="zen_onboarding_dnd_visual_disturbances_description">Do Not Disturb can do more than block unwanted sounds - it can block visuals too. This may be helpful if you\'re trying to sleep, focus, or limit time spent on your phone.</string>
     <string name="zen_onboarding_dnd_visual_disturbances_header">Block sounds and visuals</string>
-    <string name="zen_onboarding_screen_off_summary">Don\'t turn on the screen or show notifications in the ambient display</string>
+    <string name="zen_onboarding_screen_off_summary">Don\'t turn on the screen or wake for notifications</string>
     <string name="zen_onboarding_screen_on_summary">Don\'t show notifications at all, except for basic phone activity and status</string>
 
     <!-- Work Sounds: Work sound settings section header.  [CHAR LIMIT=50] -->
diff --git a/res/xml/gestures.xml b/res/xml/gestures.xml
index aec933a..650b1c4 100644
--- a/res/xml/gestures.xml
+++ b/res/xml/gestures.xml
@@ -46,6 +46,12 @@
         settings:controller="com.android.settings.gestures.DoubleTwistPreferenceController" />
 
     <Preference
+        android:key="gesture_swipe_up_input_summary"
+        android:title="@string/swipe_up_to_switch_apps_title"
+        android:fragment="com.android.settings.gestures.SwipeUpGestureSettings"
+        settings:controller="com.android.settings.gestures.SwipeUpPreferenceController" />
+
+    <Preference
         android:key="gesture_double_tap_screen_input_summary"
         android:title="@string/ambient_display_title"
         android:fragment="com.android.settings.gestures.DoubleTapScreenSettings"
diff --git a/res/xml/swipe_up_gesture_settings.xml b/res/xml/swipe_up_gesture_settings.xml
new file mode 100644
index 0000000..0f1dc4a
--- /dev/null
+++ b/res/xml/swipe_up_gesture_settings.xml
@@ -0,0 +1,36 @@
+<?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"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:key="gesture_swipe_up_screen"
+    android:title="@string/swipe_up_to_switch_apps_title">
+
+    <com.android.settings.widget.VideoPreference
+        android:key="gesture_swipe_up_video"
+        app:animation="@raw/gesture_swipe_up"
+        app:preview="@drawable/gesture_swipe_up" />
+
+    <SwitchPreference
+        android:key="gesture_swipe_up"
+        android:title="@string/swipe_up_to_switch_apps_title"
+        android:summary="@string/swipe_up_to_switch_apps_summary"
+        app:keywords="@string/keywords_gesture"
+        app:controller="com.android.settings.gestures.SwipeUpPreferenceController" />
+
+</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/zen_mode_settings.xml b/res/xml/zen_mode_settings.xml
index 24ed0b9..385e8ff 100644
--- a/res/xml/zen_mode_settings.xml
+++ b/res/xml/zen_mode_settings.xml
@@ -23,10 +23,9 @@
     settings:keywords="@string/keywords_zen_mode_settings">
 
     <!-- sound vibration -->
-    <CheckBoxPreference
+    <com.android.settings.widget.DisabledCheckBoxPreference
         android:key="zen_effect_sound"
-        android:title="@string/zen_mode_block_effect_sound"
-        android:enabled="false" />
+        android:title="@string/zen_mode_block_effect_sound" />
 
     <!-- What to block (effects) -->
     <Preference
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index ab8cc71..301e71b 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -176,7 +176,8 @@
     private static final int NO_USER_SPECIFIED = -1;
 
     // sort order
-    private int mSortOrder = R.id.sort_order_alpha;
+    @VisibleForTesting
+    int mSortOrder = R.id.sort_order_alpha;
 
     // whether showing system apps.
     private boolean mShowSystem;
@@ -649,9 +650,8 @@
         switch (item.getItemId()) {
             case R.id.sort_order_alpha:
             case R.id.sort_order_size:
-                mSortOrder = menuId;
                 if (mApplications != null) {
-                    mApplications.rebuild(mSortOrder);
+                    mApplications.rebuild(menuId);
                 }
                 break;
             case R.id.show_system:
@@ -712,6 +712,7 @@
     public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
         mFilter = mFilterAdapter.getFilter(position);
         mApplications.setFilter(mFilter);
+
         if (DEBUG) Log.d(TAG, "Selecting filter " + mFilter);
     }
 
@@ -986,6 +987,7 @@
             if (sort == mLastSortMode) {
                 return;
             }
+            mManageApplications.mSortOrder = sort;
             mLastSortMode = sort;
             rebuild();
         }
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
index e322bb4..67cf299 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
@@ -167,7 +167,7 @@
     }
 
     @Override
-    public void onProfileAudioStateChanged(int bluetoothProfile, int state) {
+    public void onAudioModeChanged() {
     }
 
     /**
diff --git a/src/com/android/settings/bluetooth/BluetoothSummaryUpdater.java b/src/com/android/settings/bluetooth/BluetoothSummaryUpdater.java
index 380bf69..5724ab4 100644
--- a/src/com/android/settings/bluetooth/BluetoothSummaryUpdater.java
+++ b/src/com/android/settings/bluetooth/BluetoothSummaryUpdater.java
@@ -81,7 +81,7 @@
     }
 
     @Override
-    public void onProfileAudioStateChanged(int bluetoothProfile, int state) {
+    public void onAudioModeChanged() {
     }
 
     @Override
diff --git a/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java b/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java
index 0a7dc7c..904d737 100644
--- a/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java
+++ b/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java
@@ -276,7 +276,7 @@
     public void onActiveDeviceChanged(CachedBluetoothDevice activeDevice, int bluetoothProfile) { }
 
     @Override
-    public void onProfileAudioStateChanged(int bluetoothProfile, int state) { }
+    public void onAudioModeChanged() { }
 
     /**
      * Return the key of the {@link PreferenceGroup} that contains the bluetooth devices
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 7842dbf..afa5f5e 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -78,6 +78,7 @@
 import com.android.settings.gestures.DoubleTapPowerSettings;
 import com.android.settings.gestures.DoubleTapScreenSettings;
 import com.android.settings.gestures.DoubleTwistGestureSettings;
+import com.android.settings.gestures.SwipeUpGestureSettings;
 import com.android.settings.gestures.PickupGestureSettings;
 import com.android.settings.gestures.SwipeToNotificationSettings;
 import com.android.settings.inputmethod.AvailableVirtualKeyboardFragment;
@@ -188,6 +189,7 @@
             DoubleTapScreenSettings.class.getName(),
             PickupGestureSettings.class.getName(),
             DoubleTwistGestureSettings.class.getName(),
+            SwipeUpGestureSettings.class.getName(),
             CryptKeeperSettings.class.getName(),
             DataUsageSummary.class.getName(),
             DataUsageSummaryLegacy.class.getName(),
diff --git a/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java b/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java
index 1c1d2f3..528ab3f 100644
--- a/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java
+++ b/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java
@@ -18,19 +18,16 @@
 
 import android.app.Activity;
 import android.app.AlertDialog;
-import android.app.AppGlobals;
 import android.app.admin.DevicePolicyManager;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
-import android.content.pm.ActivityInfo;
 import android.graphics.drawable.Drawable;
 import android.os.Process;
-import android.os.RemoteException;
 import android.os.UserHandle;
 import android.os.UserManager;
 import android.support.annotation.VisibleForTesting;
-import android.util.Log;
+import android.util.IconDrawableFactory;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -40,6 +37,7 @@
 import com.android.settings.DeviceAdminAdd;
 import com.android.settings.R;
 import com.android.settings.Settings;
+import com.android.settings.Utils;
 import com.android.settingslib.RestrictedLockUtils;
 import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
 
@@ -99,20 +97,12 @@
                 || !RestrictedLockUtils.isCurrentUserOrProfile(mActivity, userId)) {
             admin = null;
         } else {
-            ActivityInfo ai = null;
-            try {
-                ai = AppGlobals.getPackageManager().getReceiverInfo(admin, 0 /* flags */,
-                        userId);
-            } catch (RemoteException e) {
-                Log.w(TAG, "Missing reciever info", e);
-            }
-            if (ai != null) {
-                final Drawable icon = ai.loadIcon(mActivity.getPackageManager());
-                final Drawable badgedIcon = mActivity.getPackageManager().getUserBadgedIcon(
-                        icon, new UserHandle(userId));
-                ((ImageView) root.findViewById(R.id.admin_support_icon)).setImageDrawable(
-                        badgedIcon);
-            }
+            final Drawable badgedIcon = Utils.getBadgedIcon(
+                    IconDrawableFactory.newInstance(mActivity),
+                    mActivity.getPackageManager(),
+                    admin.getPackageName(),
+                    userId);
+            ((ImageView) root.findViewById(R.id.admin_support_icon)).setImageDrawable(badgedIcon);
         }
 
         setAdminSupportTitle(root, restriction);
diff --git a/src/com/android/settings/fuelgauge/batterytip/AnomalyConfigJobService.java b/src/com/android/settings/fuelgauge/batterytip/AnomalyConfigJobService.java
index 5686d6e..eb1e983 100644
--- a/src/com/android/settings/fuelgauge/batterytip/AnomalyConfigJobService.java
+++ b/src/com/android/settings/fuelgauge/batterytip/AnomalyConfigJobService.java
@@ -71,7 +71,11 @@
         ThreadUtils.postOnBackgroundThread(() -> {
             final StatsManager statsManager = getSystemService(StatsManager.class);
             checkAnomalyConfig(statsManager);
-            BatteryTipUtils.uploadAnomalyPendingIntent(this, statsManager);
+            try {
+                BatteryTipUtils.uploadAnomalyPendingIntent(this, statsManager);
+            } catch (StatsManager.StatsUnavailableException e) {
+                Log.w(TAG, "Failed to uploadAnomalyPendingIntent.", e);
+            }
             jobFinished(params, false /* wantsReschedule */);
         });
 
@@ -96,23 +100,26 @@
         Log.i(TAG, "CurrentVersion: " + currentVersion + " new version: " + newVersion);
 
         if (newVersion > currentVersion) {
-            statsManager.removeConfiguration(StatsManagerConfig.ANOMALY_CONFIG_KEY);
+            try {
+                statsManager.removeConfig(StatsManagerConfig.ANOMALY_CONFIG_KEY);
+            } catch (StatsManager.StatsUnavailableException e) {
+                Log.i(TAG, "When updating anomaly config, failed to first remove the old config "
+                        + StatsManagerConfig.ANOMALY_CONFIG_KEY, e);
+            }
             if (!TextUtils.isEmpty(rawConfig)) {
                 try {
                     final byte[] config = Base64.decode(rawConfig, Base64.DEFAULT);
-                    if (statsManager.addConfiguration(StatsManagerConfig.ANOMALY_CONFIG_KEY,
-                            config)) {
-                        Log.i(TAG, "Upload the anomaly config. configKey: "
-                                + StatsManagerConfig.ANOMALY_CONFIG_KEY);
-                        SharedPreferences.Editor editor = sharedPreferences.edit();
-                        editor.putInt(KEY_ANOMALY_CONFIG_VERSION, newVersion);
-                        editor.commit();
-                    } else {
-                        Log.i(TAG, "Upload the anomaly config failed. configKey: "
-                                + StatsManagerConfig.ANOMALY_CONFIG_KEY);
-                    }
+                    statsManager.addConfig(StatsManagerConfig.ANOMALY_CONFIG_KEY, config);
+                    Log.i(TAG, "Upload the anomaly config. configKey: "
+                            + StatsManagerConfig.ANOMALY_CONFIG_KEY);
+                    SharedPreferences.Editor editor = sharedPreferences.edit();
+                    editor.putInt(KEY_ANOMALY_CONFIG_VERSION, newVersion);
+                    editor.commit();
                 } catch (IllegalArgumentException e) {
                     Log.e(TAG, "Anomaly raw config is in wrong format", e);
+                } catch (StatsManager.StatsUnavailableException e) {
+                    Log.i(TAG, "Upload of anomaly config failed for configKey "
+                            + StatsManagerConfig.ANOMALY_CONFIG_KEY, e);
                 }
             }
         }
diff --git a/src/com/android/settings/fuelgauge/batterytip/AnomalyConfigReceiver.java b/src/com/android/settings/fuelgauge/batterytip/AnomalyConfigReceiver.java
index bad1c11..8e22447 100644
--- a/src/com/android/settings/fuelgauge/batterytip/AnomalyConfigReceiver.java
+++ b/src/com/android/settings/fuelgauge/batterytip/AnomalyConfigReceiver.java
@@ -41,7 +41,11 @@
             // Check whether to update the config
             AnomalyConfigJobService.scheduleConfigUpdate(context);
 
-            BatteryTipUtils.uploadAnomalyPendingIntent(context, statsManager);
+            try {
+                BatteryTipUtils.uploadAnomalyPendingIntent(context, statsManager);
+            } catch (StatsManager.StatsUnavailableException e) {
+                Log.w(TAG, "Failed to uploadAnomalyPendingIntent.", e);
+            }
 
             if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
                 AnomalyCleanupJobService.scheduleCleanUp(context);
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipUtils.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipUtils.java
index a9e0fc8..98ff244 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryTipUtils.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryTipUtils.java
@@ -110,12 +110,14 @@
 
     /**
      * Upload the {@link PendingIntent} to {@link StatsManager} for anomaly detection
+     * @throws StatsManager.StatsUnavailableException if failed to communicate with stats service
      */
-    public static void uploadAnomalyPendingIntent(Context context, StatsManager statsManager) {
+    public static void uploadAnomalyPendingIntent(Context context, StatsManager statsManager)
+            throws StatsManager.StatsUnavailableException {
         final Intent extraIntent = new Intent(context, AnomalyDetectionReceiver.class);
         final PendingIntent pendingIntent = PendingIntent.getBroadcast(context, REQUEST_CODE,
                 extraIntent, PendingIntent.FLAG_UPDATE_CURRENT);
-        statsManager.setBroadcastSubscriber(StatsManagerConfig.ANOMALY_CONFIG_KEY,
-                StatsManagerConfig.SUBSCRIBER_ID, pendingIntent);
+        statsManager.setBroadcastSubscriber(pendingIntent,
+                StatsManagerConfig.ANOMALY_CONFIG_KEY, StatsManagerConfig.SUBSCRIBER_ID);
     }
 }
diff --git a/src/com/android/settings/gestures/GestureSettings.java b/src/com/android/settings/gestures/GestureSettings.java
index 439819c..ec0577b 100644
--- a/src/com/android/settings/gestures/GestureSettings.java
+++ b/src/com/android/settings/gestures/GestureSettings.java
@@ -45,6 +45,7 @@
     private static final String KEY_DOUBLE_TAP_SCREEN = "gesture_double_tap_screen_input_summary";
     private static final String KEY_PICK_UP = "gesture_pick_up_input_summary";
     private static final String KEY_PREVENT_RINGING = "gesture_prevent_ringing_summary";
+    private static final String KEY_SWIPE_UP = "gesture_swipe_up_input_summary";
 
     private AmbientDisplayConfiguration mAmbientDisplayConfig;
 
@@ -96,6 +97,7 @@
                     keys.add(KEY_SWIPE_DOWN);
                     keys.add(KEY_DOUBLE_TAP_POWER);
                     keys.add(KEY_DOUBLE_TWIST);
+                    keys.add(KEY_SWIPE_UP);
                     keys.add(KEY_DOUBLE_TAP_SCREEN);
                     keys.add(KEY_PICK_UP);
                     keys.add(KEY_PREVENT_RINGING);
diff --git a/src/com/android/settings/gestures/SwipeUpGestureSettings.java b/src/com/android/settings/gestures/SwipeUpGestureSettings.java
new file mode 100644
index 0000000..1fe74c6
--- /dev/null
+++ b/src/com/android/settings/gestures/SwipeUpGestureSettings.java
@@ -0,0 +1,79 @@
+/*
+ * 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.gestures;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.provider.SearchIndexableResource;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
+import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.search.BaseSearchIndexProvider;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class SwipeUpGestureSettings extends DashboardFragment {
+
+    private static final String TAG = "SwipeUpGesture";
+
+    public static final String PREF_KEY_SUGGESTION_COMPLETE =
+            "pref_swipe_up_suggestion_complete";
+
+    @Override
+    public void onAttach(Context context) {
+        super.onAttach(context);
+        SuggestionFeatureProvider suggestionFeatureProvider = FeatureFactory.getFactory(context)
+                .getSuggestionFeatureProvider(context);
+        SharedPreferences prefs = suggestionFeatureProvider.getSharedPrefs(context);
+        prefs.edit().putBoolean(PREF_KEY_SUGGESTION_COMPLETE, true).apply();
+    }
+
+    @Override
+    public int getMetricsCategory() {
+        return MetricsProto.MetricsEvent.SETTINGS_GESTURE_SWIPE_UP;
+    }
+
+    @Override
+    protected String getLogTag() {
+        return TAG;
+    }
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.swipe_up_gesture_settings;
+    }
+
+    public static final 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.swipe_up_gesture_settings;
+                    return Arrays.asList(sir);
+                }
+
+                @Override
+                protected boolean isPageSearchEnabled(Context context) {
+                    return SwipeUpPreferenceController.isGestureAvailable(context);
+                }
+            };
+}
diff --git a/src/com/android/settings/gestures/SwipeUpPreferenceController.java b/src/com/android/settings/gestures/SwipeUpPreferenceController.java
new file mode 100644
index 0000000..a20cd97
--- /dev/null
+++ b/src/com/android/settings/gestures/SwipeUpPreferenceController.java
@@ -0,0 +1,76 @@
+/*
+ * 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.gestures;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.content.res.Resources;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.provider.Settings;
+import android.support.annotation.VisibleForTesting;
+import android.text.TextUtils;
+
+import com.android.settings.R;
+import com.android.settings.Utils;
+
+public class SwipeUpPreferenceController extends GesturePreferenceController {
+
+    private final int ON = 1;
+    private final int OFF = 0;
+
+    private static final String PREF_KEY_VIDEO = "gesture_swipe_up_video";
+    private final UserManager mUserManager;
+
+    public SwipeUpPreferenceController(Context context, String key) {
+        super(context, key);
+        mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
+    }
+
+    static boolean isGestureAvailable(Context context) {
+        return true;
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return isGestureAvailable(mContext) ? AVAILABLE : DISABLED_UNSUPPORTED;
+    }
+
+    @Override
+    protected String getVideoPrefKey() {
+        return PREF_KEY_VIDEO;
+    }
+
+    @Override
+    public boolean setChecked(boolean isChecked) {
+        setSwipeUpPreference(mContext, mUserManager, isChecked ? ON : OFF);
+        return true;
+    }
+
+    public static void setSwipeUpPreference(Context context, UserManager userManager,
+            int enabled) {
+        Settings.Secure.putInt(context.getContentResolver(),
+                Settings.Secure.SWIPE_UP_TO_SWITCH_APPS_ENABLED, enabled);
+    }
+
+    @Override
+    public boolean isChecked() {
+        final int swipeUpEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
+                Settings.Secure.SWIPE_UP_TO_SWITCH_APPS_ENABLED, OFF);
+        return swipeUpEnabled != OFF;
+    }
+}
diff --git a/src/com/android/settings/password/ChooseLockGeneric.java b/src/com/android/settings/password/ChooseLockGeneric.java
index aa67b85..62978b3 100644
--- a/src/com/android/settings/password/ChooseLockGeneric.java
+++ b/src/com/android/settings/password/ChooseLockGeneric.java
@@ -654,7 +654,6 @@
             }
 
             if (quality == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
-                mLockPatternUtils.setSeparateProfileChallengeEnabled(mUserId, true, mUserPassword);
                 mChooseLockSettingsHelper.utils().clearLock(mUserPassword, mUserId);
                 mChooseLockSettingsHelper.utils().setLockScreenDisabled(disabled, mUserId);
                 getActivity().setResult(Activity.RESULT_OK);
diff --git a/src/com/android/settings/search/DeviceIndexFeatureProvider.java b/src/com/android/settings/search/DeviceIndexFeatureProvider.java
index 690943e..2273ffd 100644
--- a/src/com/android/settings/search/DeviceIndexFeatureProvider.java
+++ b/src/com/android/settings/search/DeviceIndexFeatureProvider.java
@@ -33,6 +33,10 @@
     // TODO: Remove this and index all action and intent slices through search index.
     String[] ACTIONS_TO_INDEX = new String[]{
             Settings.ACTION_WIFI_SETTINGS,
+            Settings.ACTION_BATTERY_SAVER_SETTINGS,
+            Settings.ACTION_BLUETOOTH_SETTINGS,
+            "android.intent.action.POWER_USAGE_SUMMARY",
+            Settings.ACTION_SOUND_SETTINGS,
     };
 
     String TAG = "DeviceIndex";
@@ -40,7 +44,7 @@
     String INDEX_VERSION = "settings:index_version";
 
     // Increment when new items are added to ensure they get pushed to the device index.
-    int VERSION = 1;
+    int VERSION = 2;
 
     boolean isIndexingEnabled();
 
diff --git a/src/com/android/settings/search/SearchIndexableResourcesImpl.java b/src/com/android/settings/search/SearchIndexableResourcesImpl.java
index decfe33..3e4e0be6 100644
--- a/src/com/android/settings/search/SearchIndexableResourcesImpl.java
+++ b/src/com/android/settings/search/SearchIndexableResourcesImpl.java
@@ -57,6 +57,7 @@
 import com.android.settings.gestures.DoubleTapPowerSettings;
 import com.android.settings.gestures.DoubleTapScreenSettings;
 import com.android.settings.gestures.DoubleTwistGestureSettings;
+import com.android.settings.gestures.SwipeUpGestureSettings;
 import com.android.settings.gestures.GestureSettings;
 import com.android.settings.gestures.PickupGestureSettings;
 import com.android.settings.gestures.SwipeToNotificationSettings;
@@ -132,6 +133,7 @@
         addIndex(DoubleTapScreenSettings.class);
         addIndex(DoubleTapPowerSettings.class);
         addIndex(DoubleTwistGestureSettings.class);
+        addIndex(SwipeUpGestureSettings.class);
         addIndex(SwipeToNotificationSettings.class);
         addIndex(GestureSettings.class);
         addIndex(LanguageAndInputSettings.class);
diff --git a/src/com/android/settings/widget/DisabledCheckBoxPreference.java b/src/com/android/settings/widget/DisabledCheckBoxPreference.java
new file mode 100644
index 0000000..482cff3
--- /dev/null
+++ b/src/com/android/settings/widget/DisabledCheckBoxPreference.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.widget;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+
+import android.support.v7.preference.CheckBoxPreference;
+import android.support.v7.preference.PreferenceViewHolder;
+
+/**
+ * A CheckboxPreference with a disabled checkbox. Differs from CheckboxPreference.setDisabled()
+ * in that the text is not dimmed.
+ */
+public class DisabledCheckBoxPreference extends CheckBoxPreference {
+
+    public DisabledCheckBoxPreference(Context context, AttributeSet attrs,
+            int defStyleAttr, int defStyleRes) {
+        super(context, attrs, defStyleAttr, defStyleRes);
+    }
+
+    public DisabledCheckBoxPreference(Context context, AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+    }
+
+    public DisabledCheckBoxPreference(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    public DisabledCheckBoxPreference(Context context) {
+        super(context);
+    }
+
+    @Override
+    public void onBindViewHolder(PreferenceViewHolder holder) {
+        super.onBindViewHolder(holder);
+
+        View view = holder.findViewById(android.R.id.checkbox);
+        view.setEnabled(false);
+        holder.itemView.setEnabled(false);
+    }
+
+    @Override
+    protected void performClick(View view) {
+        // Do nothing
+    }
+}
diff --git a/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceController.java b/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceController.java
index 8eab9f4..b38558c 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceController.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceController.java
@@ -21,7 +21,6 @@
 import android.support.v7.preference.EditTextPreference;
 import android.support.v7.preference.Preference;
 import android.text.TextUtils;
-import android.util.Log;
 
 import com.android.settings.R;
 import com.android.settings.widget.ValidatedEditTextPreference;
@@ -52,7 +51,6 @@
         final WifiConfiguration config = mWifiManager.getWifiApConfiguration();
         if (config != null) {
             mPassword = config.preSharedKey;
-            Log.d(TAG, "Updating password in Preference, " + mPassword);
         } else {
             mPassword = generateRandomPassword();
         }
diff --git a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
index c751462..66fa212 100644
--- a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
@@ -23,6 +23,8 @@
 import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_NOTIFICATION;
 import static com.google.common.truth.Truth.assertThat;
 
+import static junit.framework.Assert.assertEquals;
+
 import static org.mockito.ArgumentMatchers.anyBoolean;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyInt;
@@ -303,6 +305,23 @@
         verify(holder, never()).updateSwitch(any(), anyBoolean(), anyBoolean());
     }
 
+    @Test
+    public void sortOrderSavedOnRebuild() {
+        ManageApplications manageApplications = mock(ManageApplications.class);
+        manageApplications.mListType = LIST_TYPE_NOTIFICATION;
+        manageApplications.mSortOrder = -1;
+        ManageApplications.ApplicationsAdapter adapter =
+                new ManageApplications.ApplicationsAdapter(mState,
+                        manageApplications, mock(AppFilterItem.class),
+                        mock(Bundle.class));
+
+        adapter.rebuild(mSortRecent.getItemId());
+        assertThat(manageApplications.mSortOrder).isEqualTo(mSortRecent.getItemId());
+
+        adapter.rebuild(mSortFrequent.getItemId());
+        assertThat(manageApplications.mSortOrder).isEqualTo(mSortFrequent.getItemId());
+    }
+
     private void setUpOptionMenus() {
         when(mMenu.findItem(anyInt())).thenAnswer(invocation -> {
             final Object[] args = invocation.getArguments();
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/AnomalyConfigJobServiceTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/AnomalyConfigJobServiceTest.java
index 90af7b1..35b6531 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/AnomalyConfigJobServiceTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/AnomalyConfigJobServiceTest.java
@@ -104,7 +104,8 @@
     }
 
     @Test
-    public void checkAnomalyConfig_newConfigExist_removeOldConfig() {
+    public void checkAnomalyConfig_newConfigExist_removeOldConfig()
+            throws StatsManager.StatsUnavailableException{
         Settings.Global.putInt(application.getContentResolver(),
                 Settings.Global.ANOMALY_CONFIG_VERSION, ANOMALY_CONFIG_VERSION);
         Settings.Global.putString(application.getContentResolver(), Settings.Global.ANOMALY_CONFIG,
@@ -112,11 +113,12 @@
 
         mJobService.checkAnomalyConfig(mStatsManager);
 
-        verify(mStatsManager).removeConfiguration(StatsManagerConfig.ANOMALY_CONFIG_KEY);
+        verify(mStatsManager).removeConfig(StatsManagerConfig.ANOMALY_CONFIG_KEY);
     }
 
     @Test
-    public void checkAnomalyConfig_newConfigExist_uploadNewConfig() {
+    public void checkAnomalyConfig_newConfigExist_uploadNewConfig()
+            throws StatsManager.StatsUnavailableException{
         Settings.Global.putInt(application.getContentResolver(),
                 Settings.Global.ANOMALY_CONFIG_VERSION, ANOMALY_CONFIG_VERSION);
         Settings.Global.putString(application.getContentResolver(), Settings.Global.ANOMALY_CONFIG,
@@ -124,7 +126,7 @@
 
         mJobService.checkAnomalyConfig(mStatsManager);
 
-        verify(mStatsManager).addConfiguration(eq(StatsManagerConfig.ANOMALY_CONFIG_KEY), any());
+        verify(mStatsManager).addConfig(eq(StatsManagerConfig.ANOMALY_CONFIG_KEY), any());
     }
 
 }
diff --git a/tests/robotests/src/com/android/settings/gestures/SwipeUpPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/SwipeUpPreferenceControllerTest.java
new file mode 100644
index 0000000..f9a6e9c
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/gestures/SwipeUpPreferenceControllerTest.java
@@ -0,0 +1,72 @@
+/*
+ * 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.gestures;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.hardware.Sensor;
+import android.hardware.SensorManager;
+import android.os.UserManager;
+import android.provider.Settings;
+
+import com.android.settings.R;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class SwipeUpPreferenceControllerTest {
+
+    private Context mContext;
+    private SwipeUpPreferenceController mController;
+    private static final String KEY_SWIPE_UP = "gesture_swipe_up";
+
+    @Before
+    public void setUp() {
+        mContext = RuntimeEnvironment.application;
+        mController = new SwipeUpPreferenceController(mContext, KEY_SWIPE_UP);
+    }
+
+    @Test
+    public void testIsChecked_configIsSet_shouldReturnTrue() {
+        // Set the setting to be enabled.
+        mController.setChecked(true);
+        assertThat(mController.isChecked()).isTrue();
+    }
+
+    @Test
+    public void testIsChecked_configIsNotSet_shouldReturnFalse() {
+        // Set the setting to be disabled.
+        mController.setChecked(false);
+        assertThat(mController.isChecked()).isFalse();
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/widget/DisabledCheckBoxPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/DisabledCheckBoxPreferenceTest.java
new file mode 100644
index 0000000..5ab7013
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/widget/DisabledCheckBoxPreferenceTest.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.widget;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+
+import android.support.v7.preference.R;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceViewHolder;
+import android.widget.LinearLayout;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class DisabledCheckBoxPreferenceTest {
+
+    private Context mContext;
+    private View mRootView;
+    private DisabledCheckBoxPreference mPref;
+    private PreferenceViewHolder mHolder;
+
+    @Before
+    public void setUp() {
+        mContext = RuntimeEnvironment.application;
+        mRootView = View.inflate(mContext, R.layout.preference, null /* parent */);
+        mHolder = PreferenceViewHolder.createInstanceForTests(mRootView);
+        mPref = new DisabledCheckBoxPreference(mContext);
+    }
+
+    private void inflatePreference() {
+        final LayoutInflater inflater = LayoutInflater.from(mContext);
+        final LinearLayout widgetView = mHolder.itemView.findViewById(android.R.id.widget_frame);
+        assertThat(widgetView).isNotNull();
+        inflater.inflate(R.layout.preference_widget_checkbox, widgetView, true);
+        mPref.onBindViewHolder(mHolder);
+    }
+
+    @Test
+    public void onBindViewHolder_checkboxDisabled() {
+        inflatePreference();
+        assertThat(mRootView.findViewById(android.R.id.checkbox).isEnabled()).isFalse();
+    }
+
+    @Test
+    public void checkboxOnClick_doesNothing() {
+        Preference.OnPreferenceClickListener onClick =
+                mock(Preference.OnPreferenceClickListener.class);
+        mPref.setOnPreferenceClickListener(onClick);
+        inflatePreference();
+
+        mPref.performClick(mRootView);
+
+        verify(onClick, never()).onPreferenceClick(any());
+    }
+}