Fix some animation janks during code start.

- Create a   summary placeholder for preferences with summary.
- Create a totally empty summary for prefernces without summary.
- For all dynamic prefs that has *no* SummaryLoader, add meta to set
their summary to empty.
- Other dynamic perfs has   as initial summary.

By doing this, all dynamic pref's height is fixed and will not change as
we update summaries, thus eliminating jank during cold start in each
page.

Also removed DashboardAlias for notification preference and default apps as a side fix.

Change-Id: Iec98b7ffef4e920bf573b2244ad04124c1c5d154
Fix: 36414481
Test: make RunSettingsRoboTests
(cherry picked from commit 320d60f0ad275d555e0b68d15160f12c166b3a8e)
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 791be09..661b668 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -564,11 +564,13 @@
                 <action android:name="com.android.settings.action.SETTINGS"/>
             </intent-filter>
             <meta-data android:name="com.android.settings.category"
-                android:value="com.android.settings.category.ia.system"/>
+                       android:value="com.android.settings.category.ia.system"/>
+            <meta-data android:name="com.android.settings.summary"
+                       android:resource="@string/summary_empty"/>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
-                android:value="com.android.settings.language.LanguageAndInputSettings"/>
+                       android:value="com.android.settings.language.LanguageAndInputSettings"/>
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
-                android:value="true"/>
+                       android:value="true"/>
         </activity>
 
         <activity android:name="Settings$AvailableVirtualKeyboardActivity"
@@ -1889,6 +1891,8 @@
             </intent-filter>
             <meta-data android:name="com.android.settings.category"
                 android:value="com.android.settings.category.ia.system" />
+            <meta-data android:name="com.android.settings.summary"
+                android:resource="@string/summary_empty"/>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.development.DevelopmentSettings" />
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
@@ -2388,6 +2392,8 @@
             </intent-filter>
             <meta-data android:name="com.android.settings.category"
                 android:value="com.android.settings.category.ia.accounts" />
+            <meta-data android:name="com.android.settings.summary"
+                android:resource="@string/summary_empty"/>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.users.UserSettings" />
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
@@ -2531,6 +2537,13 @@
                 <category android:name="android.intent.category.DEFAULT" />
                 <category android:name="com.android.settings.SHORTCUT" />
             </intent-filter>
+            <intent-filter android:priority="120">
+                <action android:name="com.android.settings.action.SETTINGS"/>
+            </intent-filter>
+            <meta-data android:name="com.android.settings.category"
+                android:value="com.android.settings.category.ia.apps"/>
+            <meta-data android:name="com.android.settings.summary"
+                android:resource="@string/summary_empty"/>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.notification.ConfigureNotificationSettings" />
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
@@ -2885,16 +2898,25 @@
 
         <activity android:name="Settings$AdvancedAppsActivity"
                   android:taskAffinity=""
-                  android:exported="true">
+                  android:exported="true"
+                  android:label="@string/app_default_dashboard_title"
+                  android:icon="@drawable/ic_adb">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.MANAGE_DEFAULT_APPS_SETTINGS" />
                 <action android:name="android.settings.HOME_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
+            <intent-filter android:priority="130">
+                <action android:name="com.android.settings.action.SETTINGS"/>
+            </intent-filter>
+            <meta-data android:name="com.android.settings.category"
+                       android:value="com.android.settings.category.ia.apps"/>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                        android:value="com.android.settings.applications.AdvancedAppSettings" />
+            <meta-data android:name="com.android.settings.summary"
+                       android:resource="@string/summary_empty"/>
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
-                        android:value="true" />
+                       android:value="true" />
         </activity>
 
         <!-- Keep compatibility with old WebView-picker implementation -->
@@ -2933,6 +2955,8 @@
             </intent-filter>
             <meta-data android:name="com.android.settings.category"
                        android:value="com.android.settings.category.ia.system" />
+            <meta-data android:name="com.android.settings.summary"
+                       android:resource="@string/summary_empty"/>
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
                        android:value="true" />
         </activity>
@@ -3013,34 +3037,6 @@
                        android:resource="@string/support_summary"/>
         </activity>
 
-        <activity-alias android:name="ConfigureNotificationDashboardAlias"
-                  android:targetActivity="Settings$ConfigureNotificationSettingsActivity">
-            <intent-filter android:priority="120">
-                <action android:name="com.android.settings.action.SETTINGS"/>
-            </intent-filter>
-            <meta-data android:name="com.android.settings.category"
-                       android:value="com.android.settings.category.ia.apps"/>
-            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
-                       android:value="com.android.settings.notification.ConfigureNotificationSettings" />
-            <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
-                       android:value="true" />
-        </activity-alias>
-
-        <activity-alias android:name="AppDefaultDashboardAlias"
-                        android:targetActivity="Settings$AdvancedAppsActivity"
-                        android:label="@string/app_default_dashboard_title"
-                        android:icon="@drawable/ic_adb">
-            <intent-filter android:priority="130">
-                <action android:name="com.android.settings.action.SETTINGS"/>
-            </intent-filter>
-            <meta-data android:name="com.android.settings.category"
-                       android:value="com.android.settings.category.ia.apps"/>
-            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
-                       android:value="com.android.settings.applications.AdvancedAppSettings" />
-            <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
-                       android:value="true" />
-        </activity-alias>
-
         <!-- End of information architecture host activities -->
 
         <service
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 2520722..bdee446 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2078,8 +2078,10 @@
     <string name="display_settings_title">Display</string>
     <!-- Sound settings screen heading -->
     <string name="sound_settings">Sound</string>
-    <!-- Sound settings screen, setting option summary text -->
-    <string name="ringtone_summary">&#160;</string>
+    <!-- DO NOT TRANSLATE Summary placeholder -->
+    <string name="summary_placeholder" translatable="false">&#160;</string>
+    <!-- DO NOT TRANSLATE Empty summary for dynamic preferences -->
+    <string name="summary_empty" translatable="false"></string>
     <!-- Sound settings screen, volume title -->
     <string name="all_volume_title">Volumes</string>
     <!-- Sound settings screen, music effects title [CHAR LIMIT=30]-->
diff --git a/res/xml/network_and_internet.xml b/res/xml/network_and_internet.xml
index d7a6355..7feffca 100644
--- a/res/xml/network_and_internet.xml
+++ b/res/xml/network_and_internet.xml
@@ -23,6 +23,7 @@
         android:fragment="com.android.settings.wifi.WifiSettings"
         android:key="toggle_wifi"
         android:title="@string/wifi_settings"
+        android:summary="@string/summary_placeholder"
         android:icon="@drawable/ic_settings_wireless"
         android:order="-30">
         <intent
@@ -30,13 +31,6 @@
             android:targetClass="Settings$WifiSettingsActivity"/>
     </com.android.settings.widget.MasterSwitchPreference>
 
-    <SwitchPreference
-        android:key="toggle_airplane"
-        android:title="@string/airplane_mode"
-        android:icon="@drawable/ic_airplanemode_active"
-        android:disableDependentsState="true"
-        android:order="5"/>
-
     <com.android.settingslib.RestrictedPreference
         android:key="mobile_network_settings"
         android:title="@string/network_settings_title"
@@ -58,6 +52,7 @@
         android:title="@string/tether_settings_title_all"
         android:icon="@drawable/ic_wifi_tethering"
         android:order="-5"
+        android:summary="@string/summary_placeholder"
         settings:userRestriction="no_config_tethering"
         settings:useAdminDisabledSummary="true"/>
 
@@ -67,6 +62,7 @@
         android:title="@string/vpn_settings_title"
         android:icon="@drawable/ic_vpn_key"
         android:order="0"
+        android:summary="@string/summary_placeholder"
         settings:userRestriction="no_config_vpn"
         settings:useAdminDisabledSummary="true"/>
 
@@ -77,6 +73,13 @@
         settings:userRestriction="no_config_mobile_networks"
         settings:useAdminDisabledSummary="true"/>
 
+    <SwitchPreference
+        android:key="toggle_airplane"
+        android:title="@string/airplane_mode"
+        android:icon="@drawable/ic_airplanemode_active"
+        android:disableDependentsState="true"
+        android:order="5"/>
+
     <Preference
         android:fragment="com.android.settings.ProxySelector"
         android:key="proxy_settings"
diff --git a/res/xml/sound_settings.xml b/res/xml/sound_settings.xml
index a34d875..0aaaff1 100644
--- a/res/xml/sound_settings.xml
+++ b/res/xml/sound_settings.xml
@@ -67,7 +67,7 @@
                     android:key="ringtone"
                     android:title="@string/ringtone_title"
                     android:dialogTitle="@string/ringtone_title"
-                    android:summary="@string/ringtone_summary"
+                    android:summary="@string/summary_placeholder"
                     android:ringtoneType="ringtone" />
 
                 <!-- Default notification ringtone -->
@@ -75,7 +75,7 @@
                     android:key="notification_ringtone"
                     android:title="@string/notification_ringtone_title"
                     android:dialogTitle="@string/notification_ringtone_title"
-                    android:summary="@string/ringtone_summary"
+                    android:summary="@string/summary_placeholder"
                     android:ringtoneType="notification" />
 
                 <!-- Default alarm ringtone -->
@@ -83,7 +83,7 @@
                     android:key="alarm_ringtone"
                     android:title="@string/alarm_ringtone_title"
                     android:dialogTitle="@string/alarm_ringtone_title"
-                    android:summary="@string/ringtone_summary"
+                    android:summary="@string/summary_placeholder"
                     android:persistent="false"
                     android:ringtoneType="alarm" />
 
diff --git a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
index 722f9e1..78d6122 100644
--- a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
@@ -28,6 +28,7 @@
 import android.util.Log;
 
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.R;
 import com.android.settings.SettingsActivity;
 import com.android.settings.core.instrumentation.MetricsFeatureProvider;
 import com.android.settings.overlay.FeatureFactory;
@@ -124,7 +125,11 @@
         } else {
             pref.setKey(getDashboardKeyForTile(tile));
         }
-        pref.setSummary(tile.summary);
+        if (tile.summary != null) {
+            pref.setSummary(tile.summary);
+        } else {
+            pref.setSummary(R.string.summary_placeholder);
+        }
         if (tile.icon != null) {
             pref.setIcon(tile.icon.loadDrawable(activity));
         }
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
index 4eea05e..28bed3e 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
@@ -28,6 +28,7 @@
 import android.support.v7.preference.Preference;
 
 import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
 import com.android.settings.SettingsActivity;
 import com.android.settings.SettingsRobolectricTestRunner;
 import com.android.settings.TestConfig;
@@ -217,6 +218,32 @@
     }
 
     @Test
+    public void bindPreference_noSummary_shouldSetSummaryToPlaceholder() {
+        final Preference preference = new Preference(RuntimeEnvironment.application);
+        final Tile tile = new Tile();
+        tile.intent = new Intent();
+        tile.intent.setComponent(new ComponentName("pkg", "class"));
+        mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
+                preference, tile, null /*key */, Preference.DEFAULT_ORDER);
+
+        assertThat(preference.getSummary())
+                .isEqualTo(RuntimeEnvironment.application.getString(R.string.summary_placeholder));
+    }
+
+    @Test
+    public void bindPreference_hasSummary_shouldSetSummary() {
+        final Preference preference = new Preference(RuntimeEnvironment.application);
+        final Tile tile = new Tile();
+        tile.summary = "test";
+        tile.intent = new Intent();
+        tile.intent.setComponent(new ComponentName("pkg", "class"));
+        mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
+                preference, tile, null /*key */, Preference.DEFAULT_ORDER);
+
+        assertThat(preference.getSummary()).isEqualTo(tile.summary);
+    }
+
+    @Test
     public void bindPreference_withNullKeyTileKey_shouldUseTileKey() {
         final Preference preference = new Preference(RuntimeEnvironment.application);
         final Tile tile = new Tile();