Merge "Stop logging hotspot password change in logcat." into pi-dev
diff --git a/res/drawable-nodpi/aab_brightness b/res/drawable-nodpi/aab_brightness
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/res/drawable-nodpi/aab_brightness
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/aab_brightness.mp4 b/res/raw/aab_brightness.mp4
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/res/raw/aab_brightness.mp4
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9d0e2a9..43d5563 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1592,7 +1592,7 @@
     <!-- Bluetooth settings: The sub heading for devices which have already been paired with this device. [CHAR LIMIT=40] -->
     <string name="bluetooth_preference_paired_devices">Paired devices</string>
     <!-- Bluetooth settings: The sub heading for available devices during and after scanning. [CHAR LIMIT=40] -->
-    <string name="bluetooth_preference_found_media_devices">Available media devices</string>
+    <string name="bluetooth_preference_found_media_devices">Available devices</string>
     <!-- Bluetooth settings: The message displayed if no Bluetooth devices were found. [CHAR LIMIT=40] -->
     <string name="bluetooth_preference_no_found_devices">No devices available</string>
     <!-- Bluetooth settings.  Context menu item for a device.  Action will connect to all profiles on the device. -->
@@ -6664,6 +6664,8 @@
     <string name="help_url_font_size" translatable="false"></string>
     <!-- Help URL, Display size [DO NOT TRANSLATE] -->
     <string name="help_url_display_size" translatable="false"></string>
+    <!-- Help URL, Auto brightness [DO NOT TRANSLATE] -->
+    <string name="help_url_auto_brightness" translatable="false" />
 
     <string name="help_url_network_dashboard" translatable="false"></string>
     <string name="help_url_connected_devices" translatable="false"></string>
diff --git a/res/xml/auto_brightness_detail.xml b/res/xml/auto_brightness_detail.xml
new file mode 100644
index 0000000..aca9f14
--- /dev/null
+++ b/res/xml/auto_brightness_detail.xml
@@ -0,0 +1,38 @@
+<?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:settings="http://schemas.android.com/apk/res-auto"
+    android:key="auto_brightness_detail"
+    android:title="@string/auto_brightness_title"
+    settings:keywords="@string/keywords_display_auto_brightness">
+
+    <com.android.settings.widget.VideoPreference
+        android:key="auto_brightness_video"
+        settings:animation="@raw/aab_brightness"
+        settings:preview="@drawable/aab_brightness"/>
+
+    <!-- Cross-listed item, if you change this, also change it in power_usage_summary.xml -->
+    <com.android.settingslib.RestrictedSwitchPreference
+        android:key="auto_brightness"
+        android:title="@string/auto_brightness_title"
+        settings:controller="com.android.settings.display.AutoBrightnessPreferenceController"
+        settings:useAdminDisabledSummary="true"
+        settings:userRestriction="no_config_brightness" />
+
+</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index eaa4a6b..90198ae 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -39,15 +39,12 @@
         settings:widgetLayout="@null"
         settings:keywords="@string/keywords_display_night_display" />
 
-    <!-- Cross-listed item, if you change this, also change it in power_usage_summary.xml -->
-    <com.android.settingslib.RestrictedSwitchPreference
-        android:key="auto_brightness"
+    <Preference
+        android:key="auto_brightness_entry"
         android:title="@string/auto_brightness_title"
         android:summary="@string/auto_brightness_summary"
-        settings:keywords="@string/keywords_display_auto_brightness"
-        settings:controller="com.android.settings.display.AutoBrightnessPreferenceController"
-        settings:useAdminDisabledSummary="true"
-        settings:userRestriction="no_config_brightness" />
+        android:fragment="com.android.settings.display.AutoBrightnessSettings"
+        settings:controller="com.android.settings.display.AutoBrightnessPreferenceController" />
 
     <com.android.settingslib.RestrictedPreference
         android:key="wallpaper"
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..9c9ae7b
--- /dev/null
+++ b/res/xml/swipe_up_gesture_settings.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2018 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:key="gesture_swipe_up_screen"
+    android:title="@string/swipe_up_to_switch_apps_title">
+
+    <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/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java
index d8bd447..fef56ad 100644
--- a/src/com/android/settings/DisplaySettings.java
+++ b/src/com/android/settings/DisplaySettings.java
@@ -23,7 +23,6 @@
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.display.AmbientDisplayPreferenceController;
-import com.android.settings.display.AutoRotatePreferenceController;
 import com.android.settings.display.BrightnessLevelPreferenceController;
 import com.android.settings.display.CameraGesturePreferenceController;
 import com.android.settings.display.ColorModePreferenceController;
@@ -52,7 +51,7 @@
 
     private static final String KEY_SCREEN_TIMEOUT = "screen_timeout";
     private static final String KEY_AMBIENT_DISPLAY = "ambient_display";
-
+    private static final String KEY_AUTO_BRIGHTNESS = "auto_brightness_entry";
     private static final String KEY_NIGHT_DISPLAY = "night_display";
 
     @Override
@@ -122,6 +121,7 @@
                     keys.add(KEY_DISPLAY_SIZE);
                     keys.add(WallpaperPreferenceController.KEY_WALLPAPER);
                     keys.add(KEY_NIGHT_DISPLAY);
+                    keys.add(KEY_AUTO_BRIGHTNESS);
                     return keys;
                 }
 
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/display/AutoBrightnessSettings.java b/src/com/android/settings/display/AutoBrightnessSettings.java
new file mode 100644
index 0000000..778acf6
--- /dev/null
+++ b/src/com/android/settings/display/AutoBrightnessSettings.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.display;
+
+import android.content.Context;
+import android.os.Bundle;
+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.search.BaseSearchIndexProvider;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class AutoBrightnessSettings extends DashboardFragment {
+
+    private static final String TAG = "AutoBrightnessSettings";
+
+    @Override
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+        mFooterPreferenceMixin.createFooterPreference()
+                .setTitle(R.string.auto_brightness_description);
+    }
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.auto_brightness_detail;
+    }
+
+    @Override
+    protected String getLogTag() {
+        return TAG;
+    }
+
+    @Override
+    public int getMetricsCategory() {
+        return MetricsProto.MetricsEvent.SETTINGS_AUTO_BRIGHTNESS;
+    }
+
+    @Override
+    public int getHelpResource() {
+        return R.string.help_url_auto_brightness;
+    }
+
+    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.auto_brightness_detail;
+                    return Arrays.asList(sir);
+                }
+            };
+}
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/SmartBatterySettings.java b/src/com/android/settings/fuelgauge/SmartBatterySettings.java
index 43ac960..bcbac3f 100644
--- a/src/com/android/settings/fuelgauge/SmartBatterySettings.java
+++ b/src/com/android/settings/fuelgauge/SmartBatterySettings.java
@@ -27,7 +27,6 @@
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.widget.FooterPreferenceMixin;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -39,9 +38,6 @@
 public class SmartBatterySettings extends DashboardFragment {
     public static final String TAG = "SmartBatterySettings";
 
-    private final FooterPreferenceMixin mFooterPreferenceMixin =
-            new FooterPreferenceMixin(this, getLifecycle());
-
     @Override
     public void onCreate(Bundle icicle) {
         super.onCreate(icicle);
@@ -94,11 +90,6 @@
                 }
 
                 @Override
-                public List<String> getNonIndexableKeys(Context context) {
-                    return super.getNonIndexableKeys(context);
-                }
-
-                @Override
                 public List<AbstractPreferenceController> createPreferenceControllers(
                         Context context) {
                     return buildPreferenceControllers(context, null, null);
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..eb74e07
--- /dev/null
+++ b/src/com/android/settings/gestures/SwipeUpPreferenceController.java
@@ -0,0 +1,77 @@
+/*
+ * 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;
+
+    // TODO(77474484): Update when swipe up illustration video is ready
+    private static final String PREF_KEY_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/SearchIndexableResourcesImpl.java b/src/com/android/settings/search/SearchIndexableResourcesImpl.java
index 78b18a6..3e4e0be6 100644
--- a/src/com/android/settings/search/SearchIndexableResourcesImpl.java
+++ b/src/com/android/settings/search/SearchIndexableResourcesImpl.java
@@ -44,6 +44,7 @@
 import com.android.settings.deviceinfo.StorageDashboardFragment;
 import com.android.settings.deviceinfo.StorageSettings;
 import com.android.settings.display.AmbientDisplaySettings;
+import com.android.settings.display.AutoBrightnessSettings;
 import com.android.settings.display.NightDisplaySettings;
 import com.android.settings.display.ScreenZoomSettings;
 import com.android.settings.dream.DreamSettings;
@@ -56,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;
@@ -114,6 +116,7 @@
         addIndex(DataUsageSummaryLegacy.class);
         addIndex(ScreenZoomSettings.class);
         addIndex(DisplaySettings.class);
+        addIndex(AutoBrightnessSettings.class);
         addIndex(AmbientDisplaySettings.class);
         addIndex(WallpaperTypeSettings.class);
         addIndex(AppAndNotificationDashboardFragment.class);
@@ -130,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/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();
+    }
+}