Merge "Add string needed by new device suggestion"
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 9f87d03..5e7ee7e 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -94,6 +94,10 @@
 
     <attr name="footerPreferenceStyle" format="reference" />
 
+    <declare-styleable name="FixedLineSummaryPreference">
+        <attr name="summaryLineCount" format="integer" />
+    </declare-styleable>
+
     <!-- For Search -->
     <declare-styleable name="Preference">
         <attr name="keywords" format="string" />
@@ -155,7 +159,7 @@
     </declare-styleable>
 
     <declare-styleable name="TintablePreference">
-        <attr name="android:tint" format="color|reference"/>
+        <attr name="android:tint" format="color|reference" />
     </declare-styleable>
 
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5ad67e5..01a4764 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -8432,7 +8432,7 @@
     <!-- Preference menu title for accessing the deletion helper from the storage manager settings. [CHAR LIMIT=30]-->
     <string name="deletion_helper_preference_title">Free up space now</string>
 
-    <!-- Preference title for gesture settings [CHAR LIMIT=25]-->
+    <!-- Preference title for gesture settings [CHAR LIMIT=40]-->
     <string name="gesture_preference_title">Gesture shortcuts</string>
 
     <!-- Preference summary for gesture settings (phone) [CHAR LIMIT=NONE]-->
@@ -8495,7 +8495,7 @@
     <string name="camera_lift_trigger_summary">To open the camera automatically, lift up your phone into a photo-taking position (landscape or portrait). Works when your phone is asleep or locked.</string>
 
     <!-- Settings suggestion summary text for opening camera when lifting the phone to a photo-taking position [CHAR LIMIT=60]-->
-    <string name="camera_lift_trigger_suggestion_summary">Take photos from lock screen</string>
+    <string name="camera_lift_trigger_suggestion_summary">Take photos when phone is asleep or locked</string>
 
     <!-- Title text for the assist gesture [CHAR LIMIT=60]-->
     <string name="assist_gesture_title">Assist gesture</string>
diff --git a/res/xml/installed_app_details.xml b/res/xml/installed_app_details.xml
index 12f0442..865f41f 100644
--- a/res/xml/installed_app_details.xml
+++ b/res/xml/installed_app_details.xml
@@ -15,7 +15,9 @@
   limitations under the License.
   -->
 
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto">
 
     <com.android.settings.applications.LayoutPreference
         android:key="header_view"
@@ -40,11 +42,12 @@
         android:title="@string/notifications_label"
         android:selectable="true"/>
 
-    <com.android.settings.widget.SingleLineSummaryPreference
+    <com.android.settings.widget.FixedLineSummaryPreference
         android:key="permission_settings"
         android:title="@string/permissions_label"
-        android:summary="@string/summary_placeholder"
-        android:selectable="true"/>
+        android:summary="@string/summary_two_lines_placeholder"
+        android:selectable="true"
+        app:summaryLineCount="2" />
 
     <Preference
         android:key="storage_settings"
diff --git a/res/xml/location_settings.xml b/res/xml/location_settings.xml
index e063d13..77063bd 100644
--- a/res/xml/location_settings.xml
+++ b/res/xml/location_settings.xml
@@ -24,7 +24,7 @@
             android:key="location_mode"
             android:title="@string/location_mode_title"
             settings:keywords="@string/keywords_location_mode"
-            android:summary="@string/location_mode_location_off_title" />
+            android:summary="@string/summary_placeholder" />
 
         <!-- This preference category gets removed if there is no managed profile -->
         <com.android.settingslib.RestrictedSwitchPreference
diff --git a/src/com/android/settings/applications/AdvancedAppSettings.java b/src/com/android/settings/applications/AdvancedAppSettings.java
index cce8b7d..b623801 100644
--- a/src/com/android/settings/applications/AdvancedAppSettings.java
+++ b/src/com/android/settings/applications/AdvancedAppSettings.java
@@ -18,8 +18,8 @@
 import android.app.Activity;
 import android.content.Context;
 import android.provider.SearchIndexableResource;
-
 import android.text.TextUtils;
+
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.R;
 import com.android.settings.applications.defaultapps.DefaultBrowserPreferenceController;
@@ -57,6 +57,15 @@
 
     @Override
     protected List<PreferenceController> getPreferenceControllers(Context context) {
+        return buildPreferenceControllers(context);
+    }
+
+    @Override
+    public int getMetricsCategory() {
+        return MetricsEvent.APPLICATIONS_ADVANCED;
+    }
+
+    private static List<PreferenceController> buildPreferenceControllers(Context context) {
         final List<PreferenceController> controllers = new ArrayList<>();
         controllers.add(new DefaultBrowserPreferenceController(context));
         controllers.add(new DefaultWorkBrowserPreferenceController(context));
@@ -68,11 +77,6 @@
         return controllers;
     }
 
-    @Override
-    public int getMetricsCategory() {
-        return MetricsEvent.APPLICATIONS_ADVANCED;
-    }
-
     public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
             new BaseSearchIndexProvider() {
                 @Override
@@ -94,6 +98,11 @@
                             .getPreferenceKey());
                     return keys;
                 }
+
+                @Override
+                public List<PreferenceController> getPreferenceControllers(Context context) {
+                    return buildPreferenceControllers(context);
+                }
             };
 
     static class SummaryProvider implements SummaryLoader.SummaryProvider {
@@ -118,10 +127,10 @@
                 return;
             }
             CharSequence summary = concatSummaryText(
-                mDefaultSmsPreferenceController.getDefaultAppLabel(),
-                mDefaultBrowserPreferenceController.getDefaultAppLabel());
+                    mDefaultSmsPreferenceController.getDefaultAppLabel(),
+                    mDefaultBrowserPreferenceController.getDefaultAppLabel());
             summary = concatSummaryText(summary,
-                mDefaultPhonePreferenceController.getDefaultAppLabel());
+                    mDefaultPhonePreferenceController.getDefaultAppLabel());
             if (!TextUtils.isEmpty(summary)) {
                 mSummaryLoader.setSummary(this, summary);
             }
@@ -139,11 +148,11 @@
     }
 
     public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY =
-        new SummaryLoader.SummaryProviderFactory() {
-            @Override
-            public SummaryLoader.SummaryProvider createSummaryProvider(Activity activity,
-                    SummaryLoader summaryLoader) {
-                return new AdvancedAppSettings.SummaryProvider(activity, summaryLoader);
-            }
-        };
+            new SummaryLoader.SummaryProviderFactory() {
+                @Override
+                public SummaryLoader.SummaryProvider createSummaryProvider(Activity activity,
+                        SummaryLoader summaryLoader) {
+                    return new AdvancedAppSettings.SummaryProvider(activity, summaryLoader);
+                }
+            };
 }
diff --git a/src/com/android/settings/widget/SingleLineSummaryPreference.java b/src/com/android/settings/widget/FixedLineSummaryPreference.java
similarity index 61%
rename from src/com/android/settings/widget/SingleLineSummaryPreference.java
rename to src/com/android/settings/widget/FixedLineSummaryPreference.java
index 36d9e80..c83dff4 100644
--- a/src/com/android/settings/widget/SingleLineSummaryPreference.java
+++ b/src/com/android/settings/widget/FixedLineSummaryPreference.java
@@ -15,19 +15,36 @@
 package com.android.settings.widget;
 
 import android.content.Context;
+import android.content.res.TypedArray;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceViewHolder;
 import android.text.TextUtils.TruncateAt;
 import android.util.AttributeSet;
 import android.widget.TextView;
 
+import com.android.settings.R;
+
 /**
  * A preference whose summary text will only span one single line.
  */
-public class SingleLineSummaryPreference extends Preference {
+public class FixedLineSummaryPreference extends Preference {
 
-    public SingleLineSummaryPreference(Context context, AttributeSet attrs) {
+    private int mSummaryLineCount;
+
+    public FixedLineSummaryPreference(Context context, AttributeSet attrs) {
         super(context, attrs);
+        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FixedLineSummaryPreference,
+                0, 0);
+        if (a.hasValue(R.styleable.FixedLineSummaryPreference_summaryLineCount)) {
+            mSummaryLineCount = a.getInteger(
+                    R.styleable.FixedLineSummaryPreference_summaryLineCount, 1);
+        } else {
+            mSummaryLineCount = 1;
+        }
+    }
+
+    public void setSummaryLineCount(int count) {
+        mSummaryLineCount = count;
     }
 
     @Override
@@ -35,7 +52,8 @@
         super.onBindViewHolder(holder);
         TextView summary = (TextView) holder.findViewById(android.R.id.summary);
         if (summary != null) {
-            summary.setSingleLine();
+            summary.setMinLines(mSummaryLineCount);
+            summary.setMaxLines(mSummaryLineCount);
             summary.setEllipsize(TruncateAt.END);
         }
     }
diff --git a/src/com/android/settings/widget/SettingsAppWidgetProvider.java b/src/com/android/settings/widget/SettingsAppWidgetProvider.java
index 38fed94..7dacaf5 100644
--- a/src/com/android/settings/widget/SettingsAppWidgetProvider.java
+++ b/src/com/android/settings/widget/SettingsAppWidgetProvider.java
@@ -395,7 +395,10 @@
                     int wifiApState = wifiManager.getWifiApState();
                     if (desiredState && ((wifiApState == WifiManager.WIFI_AP_STATE_ENABLING) ||
                                          (wifiApState == WifiManager.WIFI_AP_STATE_ENABLED))) {
-                        wifiManager.setWifiApEnabled(null, false);
+                        final ConnectivityManager connectivityManager =
+                                (ConnectivityManager) context.getSystemService(
+                                        Context.CONNECTIVITY_SERVICE);
+                        connectivityManager.stopTethering(ConnectivityManager.TETHERING_WIFI);
                     }
 
                     wifiManager.setWifiEnabled(desiredState);
diff --git a/tests/robotests/assets/grandfather_not_sharing_pref_controllers_with_search_provider b/tests/robotests/assets/grandfather_not_sharing_pref_controllers_with_search_provider
index 1712f19..b329072 100644
--- a/tests/robotests/assets/grandfather_not_sharing_pref_controllers_with_search_provider
+++ b/tests/robotests/assets/grandfather_not_sharing_pref_controllers_with_search_provider
@@ -1,2 +1 @@
-com.android.settings.applications.AdvancedAppSettings
 com.android.settings.fuelgauge.PowerUsageSummary
diff --git a/tests/robotests/src/com/android/settings/widget/SingleLineSummaryPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/FixedLineSummaryPreferenceTest.java
similarity index 77%
rename from tests/robotests/src/com/android/settings/widget/SingleLineSummaryPreferenceTest.java
rename to tests/robotests/src/com/android/settings/widget/FixedLineSummaryPreferenceTest.java
index d4c5392..e1dc7f0 100644
--- a/tests/robotests/src/com/android/settings/widget/SingleLineSummaryPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/widget/FixedLineSummaryPreferenceTest.java
@@ -15,19 +15,16 @@
  */
 package com.android.settings.widget;
 
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
 import android.content.Context;
 import android.support.v7.preference.PreferenceViewHolder;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.widget.LinearLayout;
 import android.widget.TextView;
+
 import com.android.settings.SettingsRobolectricTestRunner;
 import com.android.settings.TestConfig;
-import com.android.settings.widget.SingleLineSummaryPreference;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -36,25 +33,30 @@
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
 
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class SingleLineSummaryPreferenceTest {
+public class FixedLineSummaryPreferenceTest {
 
-    @Mock private TextView mSummary;
+    @Mock
+    private TextView mSummary;
 
     private Context mContext;
     private PreferenceViewHolder mHolder;
-    private SingleLineSummaryPreference mPreference;
+    private FixedLineSummaryPreference mPreference;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
 
         mContext = RuntimeEnvironment.application;
-        mPreference = new SingleLineSummaryPreference(mContext, null);
+        mPreference = new FixedLineSummaryPreference(mContext, null);
         LayoutInflater inflater = LayoutInflater.from(mContext);
         final View view = inflater.inflate(mPreference.getLayoutResource(),
-            new LinearLayout(mContext), false);
+                new LinearLayout(mContext), false);
         mHolder = spy(PreferenceViewHolder.createInstanceForTests(view));
         when(mHolder.findViewById(android.R.id.summary)).thenReturn(mSummary);
     }
@@ -62,8 +64,17 @@
     @Test
     public void onBindViewHolder_shouldSetSingleLine() {
         mPreference.onBindViewHolder(mHolder);
-        final TextView summary = (TextView) mHolder.findViewById(android.R.id.summary);
 
-        verify(mSummary).setSingleLine();
+        verify(mSummary).setMinLines(1);
+        verify(mSummary).setMaxLines(1);
+    }
+
+    @Test
+    public void onBindViewHolder_TwoLineSummary_shouldSetTwoLines() {
+        mPreference.setSummaryLineCount(2);
+        mPreference.onBindViewHolder(mHolder);
+
+        verify(mSummary).setMinLines(2);
+        verify(mSummary).setMaxLines(2);
     }
 }