Merge "Hide Set Wallpaper in Settings suggestion if it is not allowed" into nyc-mr1-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 3a3f567..cd988b0 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1708,7 +1708,7 @@
             <meta-data android:name="com.android.settings.require_feature"
                 android:value="android.hardware.fingerprint" />
             <meta-data android:name="com.android.settings.title"
-                android:resource="@string/suggested_lock_settings_title" />
+                android:resource="@string/suggested_fingerprint_lock_settings_title" />
             <meta-data android:name="com.android.settings.summary"
                 android:resource="@string/suggested_fingerprint_lock_settings_summary" />
         </activity>
diff --git a/res/layout/support_offline_escalation_options.xml b/res/layout/support_offline_escalation_options.xml
index d1e77a3..4f6940c 100644
--- a/res/layout/support_offline_escalation_options.xml
+++ b/res/layout/support_offline_escalation_options.xml
@@ -64,6 +64,5 @@
         style="@style/SupportSecondaryButton"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_marginBottom="16dp"
         android:minHeight="48dp"/>
 </LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 8c3532d..388120a 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -988,11 +988,14 @@
     <!-- Security Picker --><skip />
 
     <!-- Title for suggested actions for screen lock -->
-    <string name="suggested_lock_settings_title">Screen lock</string>
+    <string name="suggested_lock_settings_title">Set screen lock</string>
 
     <!-- Summary for suggested actions for screen lock -->
     <string name="suggested_lock_settings_summary">Protect your device</string>
 
+    <!-- Title for suggested actions for settings up a fingerprint lock -->
+    <string name="suggested_fingerprint_lock_settings_title">Use fingerprint</string>
+
     <!-- Summary for suggested actions for settings up a fingerprint lock -->
     <string name="suggested_fingerprint_lock_settings_summary">Unlock with your fingerprint</string>
 
@@ -2007,7 +2010,7 @@
     <!-- Sound settings screen, music effects title [CHAR LIMIT=30]-->
     <string name="musicfx_title">Music effects</string>
     <!-- Sound settings screen, setting option name -->
-    <string name="ring_volume_title">Ringer volume</string>
+    <string name="ring_volume_title">Ring volume</string>
     <!-- Sound settings screen, setting option name checkbox -->
     <string name="vibrate_in_silent_title">Vibrate when silent</string>
     <!-- Sound settings screen, setting option name -->
@@ -2051,7 +2054,7 @@
     <string name="volume_notification_description">Notifications</string>
     <!-- Volume description for alarm volume -->
     <string name="volume_alarm_description">Alarms</string>
-    <!-- Image description for ringer volume mute button. -->
+    <!-- Image description for ring volume mute button. -->
     <string name="volume_ring_mute">Mute ringtone &amp; notifications</string>
     <!-- Image description for media volume mute button. -->
     <string name="volume_media_mute">Mute music &amp; other media</string>
@@ -2133,10 +2136,10 @@
     <!-- Sound & display settings screen, setting option summary to enable adaptive brightness [CHAR LIMIT=100] -->
     <string name="auto_brightness_summary">Optimize brightness level for available light</string>
 
-    <!-- Night display screen, setting option name to enable night display. [CHAR LIMIT=30] -->
-    <string name="night_display_title">Night display</string>
-    <!-- Night display screen, description of night display feature. [CHAR LIMIT=NONE] -->
-    <string name="night_display_text">Night display tints your screen red at night. This makes it easier to look at your screen in dim light and may help you fall asleep more easily.</string>
+    <!-- Night display screen, setting option name to enable night display (renamed "Night Light" with title caps). [CHAR LIMIT=30] -->
+    <string name="night_display_title">Night Light</string>
+    <!-- Night display screen, description of night display feature (renamed "Night Light" with title caps). [CHAR LIMIT=NONE] -->
+    <string name="night_display_text">Night Light tints your screen red at night. This makes it easier to look at your screen or read in dim light, and may help you fall asleep more easily.</string>
     <!-- Night display screen, setting option name to configure whether night display turn on/off automatically. [CHAR LIMIT=30] -->
     <string name="night_display_auto_mode_title">Turn on automatically</string>
     <!-- Night display screen, setting option value for night display to *never* turn on/off automatically. [CHAR LIMIT=30] -->
@@ -3059,8 +3062,8 @@
     <string name="manual">Manual</string>
     <!-- About phone settings screen, setting option name to show regulatory labels [CHAR LIMIT=25] -->
     <string name="regulatory_labels">Regulatory labels</string>
-    <!-- About phone settings screen, setting option name to show safety and regulatory information [CHAR LIMIT=40] -->
-    <string name="safety_and_regulatory_info">Safety &amp; regulatory information</string>
+    <!-- About phone settings screen, setting option name to show the safety and regulatory manual [CHAR LIMIT=40] -->
+    <string name="safety_and_regulatory_info">Safety &amp; regulatory manual</string>
     <!-- Note: this may be replaced by a more-specific title of the activity that will get launched --> <skip />
     <!-- About phone settings screen, setting option name to see copyright-related info -->
     <string name="copyright_title">Copyright</string>
@@ -5916,10 +5919,10 @@
 
     <!-- Sounds and Notification -->
     <!-- Sound: Dashboard summary. [CHAR LIMIT=100] -->
-    <string name="sound_settings_summary">Ringer volume at <xliff:g id="percentage" example="2">%1$s</xliff:g></string>
+    <string name="sound_settings_summary">Ring volume at <xliff:g id="percentage" example="2">%1$s</xliff:g></string>
 
     <!-- Sound: Dashboard summary example used in Setup Wizard preview screen. [CHAR LIMIT=100] -->
-    <string name="sound_settings_example_summary">Ringer volume at 80%</string>
+    <string name="sound_settings_example_summary">Ring volume at 80%</string>
 
     <!-- Sound: Title for the option managing media volume. [CHAR LIMIT=30] -->
     <string name="media_volume_option_title">Media volume</string>
@@ -5927,7 +5930,7 @@
     <!-- Sound: Title for the option managing alarm volume. [CHAR LIMIT=30] -->
     <string name="alarm_volume_option_title">Alarm volume</string>
 
-    <!-- Sound: Title for the option managing ringer volume. [CHAR LIMIT=30] -->
+    <!-- Sound: Title for the option managing ring volume. [CHAR LIMIT=30] -->
     <string name="ring_volume_option_title">Ring volume</string>
 
     <!-- Sound: Title for the option managing notification volume. [CHAR LIMIT=30] -->
@@ -7399,7 +7402,7 @@
     <string name="suggestion_additional_fingerprints">Add another fingerprint</string>
 
     <!-- Summary for suggestion adding more fingerprints [CHAR LIMIT=60] -->
-    <string name="suggestion_additional_fingerprints_summary">Unlock with a different fingerprint</string>
+    <string name="suggestion_additional_fingerprints_summary">Unlock with a different finger</string>
 
     <!-- Summary of battery saver when on [CHAR LIMIT=NONE] -->
     <string name="battery_saver_on_summary">On / <xliff:g name="automatic_state" example="Never turn on automatically">%1$s</xliff:g></string>
@@ -7540,6 +7543,11 @@
     <!-- Title text for connecting to 24/7 available customer support [CHAR LIMIT=80]-->
     <string name="support_escalation_24_7_title">We\'re here for you 24/7</string>
 
+    <!-- Content description for connecting customer support. The "24 7" part indicates
+    support is available 24 hours a day, 7 days a week. It's used by screenreaders so it
+    cannot contain any symbol other that space. [CHAR LIMIT=80]-->
+    <string name="support_escalation_24_7_content_description">We\'re here for you 24 7</string>
+
     <!-- Summary text for connecting to customer support [CHAR LIMIT=NONE]-->
     <string name="support_escalation_summary">Our support team is here to help address any issues</string>
 
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index e96a050..a3305a2 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -81,10 +81,15 @@
         <PreferenceScreen
                 android:key="doze"
                 android:title="@string/doze_title"
-                android:summary="@string/doze_summary"
-                android:fragment="com.android.settings.gestures.GestureSettings" >
+                android:summary="@string/doze_summary" >
                 <extra android:name="gesture_scroll_to_preference"
                        android:value="gesture_pick_up_and_nudge" />
+                <intent
+                    android:targetPackage="com.android.settings"
+                    android:targetClass="com.android.settings.Settings$GestureSettingsActivity" >
+                    <extra android:name="show_drawer_menu"
+                           android:value="true" />
+                </intent>
         </PreferenceScreen>
 
         <SwitchPreference
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index db6a373b..4697f43 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -1016,16 +1016,12 @@
             mEnableOemUnlock.setDisabledByAdmin(null);
             mEnableOemUnlock.setEnabled(enableOemUnlockPreference());
             if (mEnableOemUnlock.isEnabled()) {
-                // mEnableOemUnlock is enabled as device's flash lock is unlocked.
-                if (RestrictedLockUtils.hasBaseUserRestriction(getActivity(),
-                        UserManager.DISALLOW_FACTORY_RESET, UserHandle.myUserId())) {
-                    // Set mEnableOemUnlock to disabled as restriction is set, but not by admin.
-                    mEnableOemUnlock.setEnabled(false);
-                } else {
-                    // Check restriction, disable mEnableOemUnlock and apply policy transparency.
-                    mEnableOemUnlock
-                            .checkRestrictionAndSetDisabled(UserManager.DISALLOW_FACTORY_RESET);
-                }
+                // Check restriction, disable mEnableOemUnlock and apply policy transparency.
+                mEnableOemUnlock.checkRestrictionAndSetDisabled(UserManager.DISALLOW_FACTORY_RESET);
+            }
+            if (mEnableOemUnlock.isEnabled()) {
+                // Check restriction, disable mEnableOemUnlock and apply policy transparency.
+                mEnableOemUnlock.checkRestrictionAndSetDisabled(UserManager.DISALLOW_OEM_UNLOCK);
             }
         }
     }
@@ -2175,8 +2171,8 @@
             } else if (isSimLockedDevice()) {
                 oemUnlockSummary = R.string.oem_unlock_enable_disabled_summary_sim_locked_device;
             } else if (!isOemUnlockAllowed()) {
-                // If the device isn't SIM-locked but OEM unlock is disabled by Global setting, this
-                // means the device hasn't been able to confirm whether SIM-lock or any other
+                // If the device isn't SIM-locked but OEM unlock is disabled by user restriction,
+                // this means the device hasn't been able to confirm whether SIM-lock or any other
                 // restrictions apply (or hasn't been able to apply such restrictions yet). Ask the
                 // user to connect to the internet in order to retrieve all restrictions.
                 oemUnlockSummary = R.string.oem_unlock_enable_disabled_summary_connectivity;
@@ -2209,11 +2205,13 @@
     }
 
     /**
-     * Returns {@code true} if OEM unlock is not disabled by Global policy. Otherwise, returns
-     * {@code false}.
+     * Returns {@code true} if OEM unlock is disallowed by user restriction
+     * {@link UserManager#DISALLOW_FACTORY_RESET} or {@link UserManager#DISALLOW_OEM_UNLOCK}.
+     * Otherwise, returns {@code false}.
      */
     private boolean isOemUnlockAllowed() {
-        return Settings.Global.getInt(getActivity().getContentResolver(),
-                Settings.Global.OEM_UNLOCK_DISALLOWED, 0) == 0;
+        UserHandle userHandle = UserHandle.of(UserHandle.myUserId());
+        return !(mUm.hasBaseUserRestriction(UserManager.DISALLOW_OEM_UNLOCK, userHandle)
+                || mUm.hasBaseUserRestriction(UserManager.DISALLOW_FACTORY_RESET, userHandle));
     }
 }
diff --git a/src/com/android/settings/dashboard/DashboardAdapter.java b/src/com/android/settings/dashboard/DashboardAdapter.java
index 7c76794..b49bb7b 100644
--- a/src/com/android/settings/dashboard/DashboardAdapter.java
+++ b/src/com/android/settings/dashboard/DashboardAdapter.java
@@ -20,6 +20,7 @@
 import android.content.pm.PackageManager;
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.Icon;
+import android.os.Bundle;
 import android.support.v7.widget.PopupMenu;
 import android.support.v7.widget.RecyclerView;
 import android.text.TextUtils;
@@ -45,10 +46,13 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 
 public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.DashboardItemHolder>
         implements View.OnClickListener {
     public static final String TAG = "DashboardAdapter";
+    private static final String STATE_SUGGESTION_LIST = "suggestion_list";
+    private static final String STATE_CATEGORY_LIST = "category_list";
     private static final int NS_SPACER = 0;
     private static final int NS_SUGGESTION = 1000;
     private static final int NS_ITEMS = 2000;
@@ -80,13 +84,20 @@
     private Condition mExpandedCondition = null;
     private SuggestionParser mSuggestionParser;
 
-    public DashboardAdapter(Context context, SuggestionParser parser) {
+    public DashboardAdapter(Context context, SuggestionParser parser, Bundle savedInstanceState,
+                List<Condition> conditions) {
         mContext = context;
         mCache = new IconCache(context);
         mSuggestionParser = parser;
+        mConditions = conditions;
 
         setHasStableIds(true);
         setShowingAll(true);
+
+        if (savedInstanceState != null) {
+            mSuggestions = savedInstanceState.getParcelableArrayList(STATE_SUGGESTION_LIST);
+            mCategories = savedInstanceState.getParcelableArrayList(STATE_CATEGORY_LIST);
+        }
     }
 
     public List<Tile> getSuggestions() {
@@ -94,8 +105,10 @@
     }
 
     public void setSuggestions(List<Tile> suggestions) {
-        mSuggestions = suggestions;
-        recountItems();
+        if (!Objects.equals(mSuggestions, suggestions)) {
+            mSuggestions = suggestions;
+            recountItems();
+        }
     }
 
     public Tile getTile(ComponentName component) {
@@ -111,6 +124,9 @@
     }
 
     public void setCategories(List<DashboardCategory> categories) {
+        if (Objects.equals(mCategories, categories)) {
+            return;
+        }
         mCategories = categories;
 
         // TODO: Better place for tinting?
@@ -133,8 +149,10 @@
     }
 
     public void setConditions(List<Condition> conditions) {
-        mConditions = conditions;
-        recountItems();
+        if (!Objects.equals(mConditions, conditions)) {
+            mConditions = conditions;
+            recountItems();
+        }
     }
 
     public boolean isShowingAll() {
@@ -422,6 +440,12 @@
         return packageName;
     }
 
+    void onSaveInstanceState(Bundle outState) {
+        outState.putParcelableArrayList(STATE_SUGGESTION_LIST, new ArrayList<Tile>(mSuggestions));
+        outState.putParcelableArrayList(STATE_CATEGORY_LIST,
+                new ArrayList<DashboardCategory>(mCategories));
+    }
+
     private static class IconCache {
 
         private final Context mContext;
diff --git a/src/com/android/settings/dashboard/DashboardSummary.java b/src/com/android/settings/dashboard/DashboardSummary.java
index e04b255..24b5aee 100644
--- a/src/com/android/settings/dashboard/DashboardSummary.java
+++ b/src/com/android/settings/dashboard/DashboardSummary.java
@@ -165,6 +165,9 @@
         super.onSaveInstanceState(outState);
         if (mLayoutManager == null) return;
         outState.putInt(EXTRA_SCROLL_POSITION, mLayoutManager.findFirstVisibleItemPosition());
+        if (mAdapter != null) {
+            mAdapter.onSaveInstanceState(outState);
+        }
     }
 
     @Override
@@ -181,14 +184,13 @@
         mDashboard.setHasFixedSize(true);
         mDashboard.setListener(this);
         mDashboard.addItemDecoration(new DashboardDecorator(getContext()));
-        mAdapter = new DashboardAdapter(getContext(), mSuggestionParser);
-        mAdapter.setConditions(mConditionManager.getConditions());
+        mAdapter = new DashboardAdapter(getContext(), mSuggestionParser, bundle,
+                mConditionManager.getConditions());
         mDashboard.setAdapter(mAdapter);
         mSummaryLoader.setAdapter(mAdapter);
         ConditionAdapterUtils.addDismiss(mDashboard);
         if (DEBUG_TIMING) Log.d(TAG, "onViewCreated took "
                 + (System.currentTimeMillis() - startTime) + " ms");
-
         rebuildUI();
     }
 
diff --git a/src/com/android/settings/dashboard/SupportItemAdapter.java b/src/com/android/settings/dashboard/SupportItemAdapter.java
index 1d4e99a..c5ff2a6 100644
--- a/src/com/android/settings/dashboard/SupportItemAdapter.java
+++ b/src/com/android/settings/dashboard/SupportItemAdapter.java
@@ -148,7 +148,7 @@
     public void setHasInternet(boolean hasInternet) {
         if (mHasInternet != hasInternet) {
             mHasInternet = hasInternet;
-            refreshData();
+            refreshEscalationCards();
         }
     }
 
@@ -156,7 +156,7 @@
         if (!Objects.equals(mAccount, account)) {
             mAccount = account;
             mSupportFeatureProvider.refreshOperationRules();
-            refreshData();
+            refreshEscalationCards();
         }
     }
 
@@ -170,18 +170,42 @@
      */
     private void refreshData() {
         mSupportData.clear();
-        if (mAccount == null) {
-            addSignInPromo();
-        } else if (mHasInternet) {
-            addEscalationCards();
-        } else {
-            addOfflineEscalationCards();
-        }
+        addEscalationCards();
         addMoreHelpItems();
         notifyDataSetChanged();
     }
 
+    /**
+     * Adds 1 escalation card. Based on current phone state, the escalation card can display
+     * different content.
+     */
     private void addEscalationCards() {
+        if (mAccount == null) {
+            addSignInPromo();
+        } else if (mHasInternet) {
+            addOnlineEscalationCards();
+        } else {
+            addOfflineEscalationCards();
+        }
+    }
+
+    /**
+     * Finds and refreshes escalation card data.
+     */
+    private void refreshEscalationCards() {
+        if (getItemCount() > 0) {
+            final int itemType = getItemViewType(0 /* position */);
+            if (itemType == TYPE_SIGN_IN_BUTTON
+                    || itemType == TYPE_ESCALATION_OPTIONS
+                    || itemType == TYPE_ESCALATION_OPTIONS_OFFLINE) {
+                mSupportData.remove(0 /* position */);
+                addEscalationCards();
+                notifyItemChanged(0 /* position */);
+            }
+        }
+    }
+
+    private void addOnlineEscalationCards() {
         final boolean hasPhoneOperation =
                 mSupportFeatureProvider.isSupportTypeEnabled(mActivity, PHONE);
         final boolean hasChatOperation =
@@ -195,6 +219,7 @@
                 || mSupportFeatureProvider.isAlwaysOperating(CHAT, null /* countryCode */)) {
             // Support is available.
             builder.setTileTitle(R.string.support_escalation_24_7_title)
+                    .setTileTitleDescription(R.string.support_escalation_24_7_content_description)
                     .setTileSummary(mActivity.getString(R.string.support_escalation_24_7_summary));
         } else if (mSupportFeatureProvider.isOperatingNow(PHONE)
                 || mSupportFeatureProvider.isOperatingNow(CHAT)) {
@@ -218,7 +243,7 @@
                     .setSummary2(mSupportFeatureProvider.getEstimatedWaitTime(mActivity, CHAT))
                     .setEnabled2(mSupportFeatureProvider.isOperatingNow(CHAT));
         }
-        mSupportData.add(builder.build());
+        mSupportData.add(0 /* index */, builder.build());
     }
 
     private void addOfflineEscalationCards() {
@@ -231,7 +256,7 @@
             operatingHours = mSupportFeatureProvider.getOperationHours(mActivity,
                     PHONE, mSelectedCountry, false /* hasInternet */);
         }
-        mSupportData.add(new OfflineEscalationData.Builder(mActivity)
+        mSupportData.add(0 /* index */, new OfflineEscalationData.Builder(mActivity)
                 .setCountries(mSupportFeatureProvider.getPhoneSupportCountries())
                 .setTollFreePhone(mSupportFeatureProvider.getSupportPhones(
                         mSelectedCountry, true /* isTollFree */))
@@ -240,12 +265,15 @@
                 .setTileTitle(isPhoneSupportAlwaysOperating
                         ? R.string.support_escalation_24_7_title
                         : R.string.support_escalation_title)
+                .setTileTitleDescription(isPhoneSupportAlwaysOperating
+                        ? R.string.support_escalation_24_7_content_description
+                        : R.string.support_escalation_title)
                 .setTileSummary(operatingHours)
                 .build());
     }
 
     private void addSignInPromo() {
-        mSupportData.add(new EscalationData.Builder(mActivity, TYPE_SIGN_IN_BUTTON)
+        mSupportData.add(0 /* index */, new EscalationData.Builder(mActivity, TYPE_SIGN_IN_BUTTON)
                 .setText1(R.string.support_sign_in_button_text)
                 .setText2(R.string.support_sign_in_required_help)
                 .setTileTitle(R.string.support_sign_in_required_title)
@@ -271,6 +299,7 @@
 
     private void bindEscalationOptions(ViewHolder holder, EscalationData data) {
         holder.tileTitleView.setText(data.tileTitle);
+        holder.tileTitleView.setContentDescription(data.tileTitleDescription);
         holder.tileSummaryView.setText(data.tileSummary);
         if (data.text1 == 0) {
             holder.text1View.setVisibility(View.GONE);
@@ -290,17 +319,20 @@
         }
         if (holder.summary1View != null) {
             holder.summary1View.setText(data.summary1);
-            holder.summary1View.setVisibility(mHasInternet ? View.VISIBLE : View.GONE);
+            holder.summary1View.setVisibility(mHasInternet && !TextUtils.isEmpty(data.summary1)
+                    ? View.VISIBLE : View.GONE);
         }
         if (holder.summary2View != null) {
             holder.summary2View.setText(data.summary2);
-            holder.summary2View.setVisibility(mHasInternet ? View.VISIBLE : View.GONE);
+            holder.summary2View.setVisibility(mHasInternet && !TextUtils.isEmpty(data.summary2)
+                    ? View.VISIBLE : View.GONE);
         }
     }
 
     private void bindOfflineEscalationOptions(ViewHolder holder, OfflineEscalationData data) {
         // Bind Title
         holder.tileTitleView.setText(data.tileTitle);
+        holder.tileTitleView.setContentDescription(data.tileTitleDescription);
         holder.tileSummaryView.setText(data.tileSummary);
         // Bind spinner
         final Spinner spinner = (Spinner) holder.itemView.findViewById(R.id.spinner);
@@ -335,6 +367,7 @@
 
     private void bindSignInPromoTile(ViewHolder holder, EscalationData data) {
         holder.tileTitleView.setText(data.tileTitle);
+        holder.tileTitleView.setContentDescription(data.tileTitleDescription);
         holder.tileSummaryView.setText(data.tileSummary);
         holder.text1View.setText(data.text1);
         holder.text2View.setText(data.text2);
@@ -348,6 +381,7 @@
         }
         if (holder.tileTitleView != null) {
             holder.tileTitleView.setText(data.tileTitle);
+            holder.tileTitleView.setContentDescription(data.tileTitleDescription);
         }
         if (holder.tileSummaryView != null) {
             holder.tileSummaryView.setText(data.tileSummary);
@@ -437,7 +471,7 @@
             final String selectedCountry = countryCodes.get(position);
             if (!TextUtils.equals(selectedCountry, mSelectedCountry)) {
                 mSelectedCountry = selectedCountry;
-                refreshData();
+                refreshEscalationCards();
             }
         }
 
@@ -485,6 +519,7 @@
         final int icon;
         @StringRes
         final int tileTitle;
+        final CharSequence tileTitleDescription;
         final CharSequence tileSummary;
 
 
@@ -492,6 +527,7 @@
             this.type = builder.mType;
             this.icon = builder.mIcon;
             this.tileTitle = builder.mTileTitle;
+            this.tileTitleDescription = builder.mTileTitleDescription;
             this.tileSummary = builder.mTileSummary;
             this.intent = builder.mIntent;
             this.metricsEvent = builder.mMetricsEvent;
@@ -506,6 +542,7 @@
             private int mIcon;
             @StringRes
             private int mTileTitle;
+            private CharSequence mTileTitleDescription;
             private CharSequence mTileSummary;
             private Intent mIntent;
             private int mMetricsEvent = -1;
@@ -525,6 +562,11 @@
                 return this;
             }
 
+            Builder setTileTitleDescription(@StringRes int titleDescription) {
+                mTileTitleDescription = mContext.getString(titleDescription);
+                return this;
+            }
+
             Builder setTileSummary(@StringRes int summary) {
                 mTileSummary = mContext.getString(summary);
                 return this;
diff --git a/src/com/android/settings/deletionhelper/AutomaticStorageManagerSettings.java b/src/com/android/settings/deletionhelper/AutomaticStorageManagerSettings.java
index 1b64fc4..9f2fb42 100644
--- a/src/com/android/settings/deletionhelper/AutomaticStorageManagerSettings.java
+++ b/src/com/android/settings/deletionhelper/AutomaticStorageManagerSettings.java
@@ -35,6 +35,7 @@
 import android.support.v7.preference.Preference.OnPreferenceChangeListener;
 import android.support.v7.preference.PreferenceScreen;
 
+import com.android.internal.logging.MetricsLogger;
 import com.android.internal.logging.MetricsProto.MetricsEvent;
 import com.android.settings.SettingsActivity;
 import com.android.settings.SettingsPreferenceFragment;
@@ -120,6 +121,8 @@
         switch (preference.getKey()) {
             case KEY_STORAGE_MANAGER_SWITCH:
                 boolean checked = (boolean) newValue;
+                MetricsLogger.action(getContext(), MetricsEvent.ACTION_TOGGLE_STORAGE_MANAGER,
+                        checked);
                 mDaysToRetain.setEnabled(checked);
                 Settings.Secure.putInt(getContentResolver(),
                         Settings.Secure.AUTOMATIC_STORAGE_MANAGER_ENABLED, checked ? 1 : 0);