Merge "Set default display timeout if current value is disabled by admin."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 7094d8e..3b6d4f8 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -148,12 +148,15 @@
                 android:taskAffinity="com.android.settings"
                 android:parentActivityName="Settings" />
 
-        <activity android:name=".shortcut.CreateShortcut"
+        <activity android:name=".Settings$CreateShortcutActivity"
                   android:label="@string/settings_shortcut">
             <intent-filter>
-                <action android:name="android.intent.action.CREATE_SHORTCUT"/>
-                <category android:name="android.intent.category.DEFAULT"/>
+                <action android:name="android.intent.action.CREATE_SHORTCUT" />
+                <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
+            <meta-data
+                android:name="com.android.settings.FRAGMENT_CLASS"
+                android:value="com.android.settings.shortcut.CreateShortcut" />
         </activity>
 
         <!-- Wireless Controls -->
@@ -241,10 +244,8 @@
                 <action android:name="android.settings.WIFI_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
+            <intent-filter android:priority="1">
                 <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-                <category android:name="android.intent.category.VOICE_LAUNCH" />
                 <category android:name="com.android.settings.SHORTCUT" />
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
@@ -261,10 +262,6 @@
                 <action android:name="android.net.wifi.PICK_WIFI_NETWORK" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
                 android:value="true" />
         </activity>
@@ -302,10 +299,6 @@
                 <action android:name="android.settings.WIFI_SAVED_NETWORK_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.wifi.SavedAccessPointsWifiSettings" />
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
@@ -396,9 +389,8 @@
             android:label="@string/devices_title"
             android:targetActivity=".Settings$ConnectedDeviceDashboardActivity"
             android:exported="true">
-            <intent-filter>
+            <intent-filter android:priority="10">
                 <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
                 <category android:name="com.android.settings.SHORTCUT" />
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
@@ -461,12 +453,29 @@
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.DEFAULT" />
                 <category android:name="android.intent.category.VOICE_LAUNCH" />
-                <category android:name="com.android.settings.SHORTCUT" />
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.TetherSettings" />
         </activity>
 
+        <activity
+            android:name="Settings$WifiTetherSettingsActivity"
+            android:label="@string/wifi_hotspot_checkbox_text"
+            android:icon="@drawable/ic_wifi_tethering"
+            android:parentActivityName="Settings">
+            <intent-filter>
+                <action android:name="com.android.settings.WIFI_TETHER_SETTINGS" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+            <intent-filter android:priority="4">
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="com.android.settings.SHORTCUT" />
+            </intent-filter>
+            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+                android:value="com.android.settings.wifi.tether.WifiTetherSettings" />
+        </activity>
+
+
         <!-- Keep compatibility with old shortcuts. -->
         <activity-alias android:name=".TetherSettings"
                   android:label="@string/tether_settings_title_all"
@@ -500,10 +509,8 @@
                 <action android:name="android.net.vpn.SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
+            <intent-filter android:priority="5">
                 <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-                <category android:name="android.intent.category.VOICE_LAUNCH" />
                 <category android:name="com.android.settings.SHORTCUT" />
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
@@ -603,21 +610,14 @@
                 <action android:name="android.settings.VOICE_INPUT_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.applications.assist.ManageAssist" />
         </activity>
 
         <activity android:name="Settings$KeyboardLayoutPickerActivity"
             android:label="@string/keyboard_layout_picker_title"
-            android:clearTaskOnLaunch="true">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
+            android:clearTaskOnLaunch="true"
+            android:exported="true">
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.inputmethod.KeyboardLayoutPickerFragment" />
         </activity>
@@ -629,10 +629,6 @@
                 <action android:name="android.settings.HARD_KEYBOARD_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.inputmethod.PhysicalKeyboardFragment" />
         </activity>
@@ -727,9 +723,8 @@
                 <action android:name="android.settings.ZEN_MODE_PRIORITY_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
+            <intent-filter android:priority="41">
                 <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
                 <category android:name="com.android.settings.SHORTCUT" />
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
@@ -866,10 +861,6 @@
                 <action android:name="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.notification.ZenModeEventRuleSettings" />
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
@@ -887,10 +878,8 @@
                 <action android:name="android.settings.DISPLAY_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
+            <intent-filter android:priority="30">
                 <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-                <category android:name="android.intent.category.VOICE_LAUNCH" />
                 <category android:name="com.android.settings.SHORTCUT" />
             </intent-filter>
             <intent-filter android:priority="7">
@@ -906,15 +895,6 @@
                 android:resource="@string/display_dashboard_summary"/>
         </activity>
 
-        <!-- Keep compatibility with old shortcuts. -->
-        <activity-alias android:name="DisplaySettings"
-                android:label="@string/display_settings"
-                android:exported="true"
-                android:targetActivity="Settings$DisplaySettingsActivity">
-            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
-                android:value="com.android.settings.DisplaySettings" />
-        </activity-alias>
-
         <activity
             android:name="Settings$NightDisplaySettingsActivity"
             android:label="@string/night_display_title"
@@ -922,9 +902,8 @@
             android:icon="@drawable/ic_settings_night_display"
             android:taskAffinity="com.android.settings"
             android:parentActivityName="Settings">
-            <intent-filter>
+            <intent-filter android:priority="32">
                 <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
                 <category android:name="com.android.settings.SHORTCUT" />
             </intent-filter>
             <intent-filter android:priority="1">
@@ -967,10 +946,9 @@
                 <action android:name="android.settings.DEVICE_NAME" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
+            <intent-filter android:priority="71">
                 <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-                <category android:name="android.intent.category.VOICE_LAUNCH" />
+                <category android:name="com.android.settings.SHORTCUT" />
             </intent-filter>
             <intent-filter android:priority="270">
                 <action android:name="com.android.settings.action.SETTINGS" />
@@ -1010,10 +988,8 @@
                 <action android:name="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
+            <intent-filter android:priority="20">
                 <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-                <category android:name="android.intent.category.VOICE_LAUNCH" />
                 <category android:name="com.android.settings.SHORTCUT" />
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
@@ -1044,17 +1020,6 @@
                        android:value="com.android.settings.applications.managedomainurls.ManageDomainUrls" />
         </activity>
 
-        <activity android:name="Settings$MemorySettingsActivity"
-                android:label="@string/memory_settings_title"
-                android:icon="@drawable/ic_settings_memory">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="com.android.settings.SHORTCUT" />
-            </intent-filter>
-            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
-                android:value="com.android.settings.applications.ProcessStatsSummary" />
-        </activity>
-
         <activity android:name="Settings$AppMemoryUsageActivity"
                   android:label="@string/app_list_memory_use"
                   android:icon="@drawable/ic_settings_memory">
@@ -1209,9 +1174,8 @@
             android:label="@string/notification_log_title"
             android:taskAffinity="com.android.settings"
             android:parentActivityName="Settings">
-            <intent-filter>
+            <intent-filter android:priority="22">
                 <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
                 <category android:name="com.android.settings.SHORTCUT" />
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
@@ -1228,17 +1192,6 @@
             </intent-filter>
         </activity>
 
-        <activity android:name="Settings$BackgroundCheckSummaryActivity"
-                android:label="@string/background_check_title"
-                android:enabled="false">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
-            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
-                android:value="com.android.settings.applications.appops.BackgroundCheckSummary" />
-        </activity>
-
         <activity
             android:name="Settings$LocationSettingsActivity"
             android:label="@string/location_settings_title"
@@ -1250,10 +1203,8 @@
                 <action android:name="android.settings.LOCATION_SOURCE_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
+            <intent-filter android:priority="52">
                 <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-                <category android:name="android.intent.category.VOICE_LAUNCH" />
                 <category android:name="com.android.settings.SHORTCUT" />
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
@@ -1315,10 +1266,6 @@
                 <action android:name="com.android.settings.MONITORING_CERT_INFO" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
         </activity>
 
         <activity
@@ -1421,10 +1368,6 @@
                 <action android:name="android.settings.USAGE_ACCESS_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.applications.manageapplications.ManageApplications" />
         </activity>
@@ -1452,10 +1395,8 @@
                 <action android:name="android.settings.ACCESSIBILITY_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
+            <intent-filter android:priority="60">
                 <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-                <category android:name="android.intent.category.VOICE_LAUNCH" />
                 <category android:name="com.android.settings.SHORTCUT" />
             </intent-filter>
             <intent-filter android:priority="2">
@@ -1522,10 +1463,6 @@
                 <action android:name="android.settings.CAPTIONING_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.accessibility.CaptionPropertiesFragment" />
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
@@ -1787,10 +1724,9 @@
                 <action android:name="android.settings.MEMORY_CARD_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
+            <intent-filter android:priority="50">
                 <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-                <category android:name="android.intent.category.VOICE_LAUNCH" />
+                <category android:name="com.android.settings.SHORTCUT" />
             </intent-filter>
             <intent-filter android:priority="5">
                 <action android:name="com.android.settings.action.SETTINGS" />
@@ -2091,10 +2027,6 @@
                 <action android:name="android.settings.NFCSHARING_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.nfc.AndroidBeam" />
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
@@ -2111,10 +2043,6 @@
                 <action android:name="android.settings.CAST_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
             <intent-filter android:priority="6">
                 <action android:name="com.android.settings.action.SETTINGS"/>
             </intent-filter>
@@ -2146,10 +2074,6 @@
         </activity>
 
         <activity android:name="Settings$TestingSettingsActivity" android:label="@string/testing">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.TestingSettings" />
         </activity>
@@ -2202,9 +2126,8 @@
                 <action android:name="android.intent.action.POWER_USAGE_SUMMARY" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
+            <intent-filter android:priority="51">
                 <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
                 <category android:name="com.android.settings.SHORTCUT" />
             </intent-filter>
             <intent-filter android:priority="8">
@@ -2252,10 +2175,6 @@
                 <action android:name="android.settings.ACCOUNT_SYNC_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.accounts.AccountSyncSettings" />
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
@@ -2286,10 +2205,6 @@
                 <action android:name="android.settings.ADD_ACCOUNT_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
                 android:value="true" />
         </activity>
@@ -2350,10 +2265,6 @@
                 <action android:name="android.app.action.START_ENCRYPTION" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.security.CryptKeeperSettings" />
         </activity>
@@ -2368,9 +2279,8 @@
                 <action android:name="android.settings.DATA_USAGE_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
+            <intent-filter android:priority="3">
                 <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
                 <category android:name="com.android.settings.SHORTCUT" />
             </intent-filter>
             <intent-filter android:priority="10">
@@ -2404,11 +2314,6 @@
                 <action android:name="android.settings.DREAM_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-                <category android:name="com.android.settings.SHORTCUT" />
-            </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.dream.DreamSettings" />
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
@@ -2425,10 +2330,6 @@
                 <action android:name="android.settings.USER_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
             <intent-filter  android:priority="45">
                 <action android:name="com.android.settings.action.SETTINGS" />
             </intent-filter>
@@ -2497,10 +2398,6 @@
                 <action android:name="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                        android:value="com.android.settings.notification.NotificationAccessSettings" />
         </activity>
@@ -2514,10 +2411,6 @@
                 <action android:name="android.settings.VR_LISTENER_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                        android:value="com.android.settings.applications.VrListenerSettings" />
         </activity>
@@ -2562,10 +2455,6 @@
                 <action android:name="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                        android:value="com.android.settings.notification.ZenAccessSettings" />
         </activity>
@@ -2574,15 +2463,13 @@
             android:name="Settings$ConfigureNotificationSettingsActivity"
             android:label="@string/configure_notification_settings"
             android:exported="true"
-            android:taskAffinity="com.android.settings"
             android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.NOTIFICATION_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
+            <intent-filter android:priority="21">
                 <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
                 <category android:name="com.android.settings.SHORTCUT" />
             </intent-filter>
             <intent-filter android:priority="160">
@@ -2598,7 +2485,6 @@
                 android:value="true" />
         </activity>
 
-        <!-- Keep compatibility with old shortcuts. -->
         <activity
             android:name="Settings$SoundSettingsActivity"
             android:label="@string/sound_settings"
@@ -2612,10 +2498,8 @@
                 <action android:name="android.settings.ACTION_OTHER_SOUND_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
+            <intent-filter android:priority="40">
                 <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-                <category android:name="android.intent.category.VOICE_LAUNCH" />
                 <category android:name="com.android.settings.SHORTCUT" />
             </intent-filter>
             <intent-filter android:priority="6">
@@ -2655,10 +2539,6 @@
                 <action android:name="android.settings.APP_NOTIFICATION_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.notification.AppNotificationSettings" />
         </activity>
@@ -2666,10 +2546,6 @@
         <!-- Show channel group-level notification settings (group passed in as extras) -->
         <activity android:name="Settings$ChannelGroupNotificationSettingsActivity"
                   android:exported="true">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                        android:value="com.android.settings.notification.ChannelGroupNotificationSettings" />
         </activity>
@@ -2682,10 +2558,6 @@
                 <action android:name="android.settings.CHANNEL_NOTIFICATION_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                        android:value="com.android.settings.notification.ChannelNotificationSettings" />
         </activity>
@@ -2780,10 +2652,6 @@
                 <action android:name="com.android.settings.sim.SIM_SUB_INFO_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
             <intent-filter android:priority="2">
                 <action android:name="com.android.settings.action.SETTINGS" />
             </intent-filter>
@@ -2905,7 +2773,6 @@
         <activity
             android:name="Settings$AppDrawOverlaySettingsActivity"
             android:label="@string/draw_overlay"
-            android:taskAffinity="com.android.settings"
             android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.action.MANAGE_OVERLAY_PERMISSION" />
@@ -3083,6 +2950,10 @@
                 <action android:name="android.settings.SYNC_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
+            <intent-filter android:priority="53">
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="com.android.settings.SHORTCUT" />
+            </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                        android:value="com.android.settings.accounts.AccountDashboardFragment"/>
             <meta-data android:name="com.android.settings.category"
@@ -3100,6 +2971,10 @@
             <intent-filter android:priority="-1">
                 <action android:name="com.android.settings.action.SETTINGS"/>
             </intent-filter>
+            <intent-filter android:priority="70">
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="com.android.settings.SHORTCUT" />
+            </intent-filter>
             <meta-data android:name="com.android.settings.category"
                        android:value="com.android.settings.category.ia.homepage"/>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
diff --git a/res/layout/activity_list.xml b/res/layout/activity_list.xml
deleted file mode 100644
index ca9e12b..0000000
--- a/res/layout/activity_list.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  Copyright (C) 2016 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.
-  -->
-
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
-             android:layout_width="match_parent"
-             android:layout_height="match_parent">
-
-    <ListView
-        android:id="@android:id/list"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"/>
-
-    <TextView
-        android:id="@android:id/empty"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:gravity="center"
-        android:text="@string/activity_list_empty"
-        android:visibility="gone"
-        android:textAppearance="?android:attr/textAppearanceMedium"/>
-
-</FrameLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d0c076e..d799ea5 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -689,8 +689,6 @@
     <string name="settings_label_launcher">Settings</string>
     <!-- Label for option to select a settings panel as a shortcut -->
     <string name="settings_shortcut">Settings shortcut</string>
-    <!-- Shown in create shortcut activity when there is no shortcut that can be created. [CHAR_LIMIT=None] -->
-    <string name="activity_list_empty">No matching activities found.</string>
     <!-- Wireless controls settings screen, setting check box label -->
     <string name="airplane_mode">Airplane mode</string>
     <!-- Main Settings screen settings title for things like airplane mode, tethering, NFC, VPN.  This will take you to another screen with those settings.  [CHAR LIMIT=30] -->
@@ -2502,11 +2500,11 @@
     <string name="color_mode_option_boosted">Boosted</string>
     <!-- Display settings screen, Color mode option for "Saturated color"  [CHAR LIMIT=45] -->
     <string name="color_mode_option_saturated">Saturated</string>
-    <!-- Display settings screen, Color mode option for "Automatic color"  [CHAR LIMIT=45] -->
-    <string name="color_mode_option_automatic">Automatic</string>
+    <!-- Display settings screen, Color mode option for "Adaptive color"  [CHAR LIMIT=45] -->
+    <string name="color_mode_option_automatic">Adaptive</string>
     <!-- Display settings screen, "natural(sRGB) color" setting option summary [CHAR LIMIT=NONE] -->
     <string name="color_mode_summary_natural">Use accurate colors only</string>
-    <!-- Display settings screen, "Automatic color" setting option summary [CHAR LIMIT=NONE] -->
+    <!-- Display settings screen, "Adaptive color" setting option summary [CHAR LIMIT=NONE] -->
     <string name="color_mode_summary_automatic">Adjust between vivid and accurate colors</string>
 
     <!-- Sound & display settings screen, accelerometer-based rotation summary text when check box is selected -->
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index 060868e..bef1351 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -14,7 +14,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:settings="http://schemas.android.com/apk/res-auto"
         android:key="accessibility_settings_screen"
         android:title="@string/accessibility_settings"
         android:persistent="true">
@@ -136,6 +138,7 @@
                 android:title="@string/accessibility_display_inversion_preference_title"
                 android:summary="@string/accessibility_display_inversion_preference_subtitle"
                 android:persistent="false"
-                android:icon="@drawable/ic_color_inversion"/>
+                android:icon="@drawable/ic_color_inversion"
+                settings:controller="com.android.settings.accessibility.ColorInversionPreferenceController"/>
     </PreferenceCategory>
 </PreferenceScreen>
diff --git a/res/xml/create_shortcut.xml b/res/xml/create_shortcut.xml
new file mode 100644
index 0000000..15b3835
--- /dev/null
+++ b/res/xml/create_shortcut.xml
@@ -0,0 +1,23 @@
+<?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:title="@string/settings_shortcut"
+    android:key="create_shortcut_screen"
+    settings:controller="com.android.settings.shortcut.CreateShortcutPreferenceController" />
\ No newline at end of file
diff --git a/res/xml/device_admin_settings.xml b/res/xml/device_admin_settings.xml
index 999d790..09e0724 100644
--- a/res/xml/device_admin_settings.xml
+++ b/res/xml/device_admin_settings.xml
@@ -19,11 +19,5 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:settings="http://schemas.android.com/apk/res-auto"
     android:title="@string/manage_device_admin"
-    android:key="device_admin_settings">
-
-    <PreferenceCategory
-        android:key="device_admin_list"
-        android:title="@string/summary_placeholder"
-        settings:controller="com.android.settings.applications.specialaccess.deviceadmin.DeviceAdminListPreferenceController" />
-
-</PreferenceScreen>
\ No newline at end of file
+    android:key="device_admin_settings"
+    settings:controller="com.android.settings.applications.specialaccess.deviceadmin.DeviceAdminListPreferenceController" />
\ No newline at end of file
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 0d85062..99d7d47 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -30,8 +30,10 @@
     */
     public static class AssistGestureSettingsActivity extends SettingsActivity { /* empty */}
     public static class BluetoothSettingsActivity extends SettingsActivity { /* empty */ }
+    public static class CreateShortcutActivity extends SettingsActivity { /* empty */ }
     public static class SimSettingsActivity extends SettingsActivity { /* empty */ }
     public static class TetherSettingsActivity extends SettingsActivity { /* empty */ }
+    public static class WifiTetherSettingsActivity extends SettingsActivity { /* empty */ }
     public static class VpnSettingsActivity extends SettingsActivity { /* empty */ }
     public static class DateTimeSettingsActivity extends SettingsActivity { /* empty */ }
     public static class PrivateVolumeForgetActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/SettingsInitialize.java b/src/com/android/settings/SettingsInitialize.java
index b4b6d73..a66207e 100644
--- a/src/com/android/settings/SettingsInitialize.java
+++ b/src/com/android/settings/SettingsInitialize.java
@@ -34,7 +34,7 @@
 import android.os.UserManager;
 import android.util.Log;
 
-import com.android.settings.shortcut.CreateShortcut;
+import com.android.settings.Settings.CreateShortcutActivity;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -101,7 +101,8 @@
         pm.setComponentEnabledSetting(settingsComponentName,
                 PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
         // Disable shortcut picker.
-        ComponentName shortcutComponentName = new ComponentName(context, CreateShortcut.class);
+        ComponentName shortcutComponentName = new ComponentName(
+                context, CreateShortcutActivity.class);
         pm.setComponentEnabledSetting(shortcutComponentName,
                 PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
     }
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 3464fd9..61f2672 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -224,6 +224,7 @@
     private Preference mDisplayDaltonizerPreferenceScreen;
     private Preference mVibrationPreferenceScreen;
     private SwitchPreference mToggleInversionPreference;
+    private ColorInversionPreferenceController mInversionPreferenceController;
 
     private int mLongPressTimeoutDefault;
 
@@ -304,9 +305,6 @@
         if (mSelectLongPressTimeoutPreference == preference) {
             handleLongPressTimeoutPreferenceChange((String) newValue);
             return true;
-        } else if (mToggleInversionPreference == preference) {
-            handleToggleInversionPreferenceChange((Boolean) newValue);
-            return true;
         }
         return false;
     }
@@ -318,11 +316,6 @@
                 mLongPressTimeoutValueToTitleMap.get(stringValue));
     }
 
-    private void handleToggleInversionPreferenceChange(boolean checked) {
-        Settings.Secure.putInt(getContentResolver(),
-                Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, (checked ? 1 : 0));
-    }
-
     @Override
     public boolean onPreferenceTreeClick(Preference preference) {
         if (mToggleHighTextContrastPreference == preference) {
@@ -412,7 +405,9 @@
 
         // Display inversion.
         mToggleInversionPreference = (SwitchPreference) findPreference(TOGGLE_INVERSION_PREFERENCE);
-        mToggleInversionPreference.setOnPreferenceChangeListener(this);
+        mInversionPreferenceController =
+                new ColorInversionPreferenceController(getContext(), TOGGLE_INVERSION_PREFERENCE);
+        mInversionPreferenceController.displayPreference(getPreferenceScreen());
 
         // Power button ends calls.
         mTogglePowerButtonEndsCallPreference =
@@ -652,8 +647,7 @@
                         Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, 0) == 1);
 
         // If the quick setting is enabled, the preference MUST be enabled.
-        mToggleInversionPreference.setChecked(Settings.Secure.getInt(getContentResolver(),
-                Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, 0) == 1);
+        mInversionPreferenceController.updateState(mToggleInversionPreference);
 
         // Power button ends calls.
         if (KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POWER)
diff --git a/src/com/android/settings/accessibility/ColorInversionPreferenceController.java b/src/com/android/settings/accessibility/ColorInversionPreferenceController.java
new file mode 100644
index 0000000..091f109
--- /dev/null
+++ b/src/com/android/settings/accessibility/ColorInversionPreferenceController.java
@@ -0,0 +1,54 @@
+/*
+ * 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.accessibility;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import com.android.settings.core.TogglePreferenceController;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+public class ColorInversionPreferenceController extends TogglePreferenceController {
+    @VisibleForTesting
+    static final int ON = 1;
+    @VisibleForTesting
+    static final int OFF = 0;
+
+    public ColorInversionPreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey);
+    }
+
+    @Override
+    public boolean isChecked() {
+        return Settings.Secure.getInt(mContext.getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, OFF) == ON;
+    }
+
+    @Override
+    public boolean setChecked(boolean isChecked) {
+        return Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, (isChecked ? ON : OFF));
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+}
diff --git a/src/com/android/settings/applications/AppStateNotificationBridge.java b/src/com/android/settings/applications/AppStateNotificationBridge.java
index 205c92d..d06aeb1 100644
--- a/src/com/android/settings/applications/AppStateNotificationBridge.java
+++ b/src/com/android/settings/applications/AppStateNotificationBridge.java
@@ -23,6 +23,7 @@
 import android.os.UserManager;
 import android.text.format.DateUtils;
 import android.util.ArrayMap;
+import android.util.Log;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.Switch;
@@ -46,6 +47,8 @@
  */
 public class AppStateNotificationBridge extends AppStateBaseBridge {
 
+    private final String TAG = "AppStateNotificationBridge";
+    private final boolean DEBUG = true;
     private final Context mContext;
     private IUsageStatsManager mUsageStatsManager;
     protected List<Integer> mUserIds;
@@ -70,7 +73,12 @@
     @Override
     protected void loadAllExtraInfo() {
         ArrayList<AppEntry> apps = mAppSession.getAllApps();
-        if (apps == null) return;
+        if (apps == null) {
+            if (DEBUG) {
+                Log.d(TAG, "No apps.  No extra info loaded");
+            }
+            return;
+        }
 
         final Map<String, NotificationsSentState> map = getAggregatedUsageEvents();
         for (AppEntry entry : apps) {
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index 06503c20..262281d 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -16,7 +16,6 @@
 
 package com.android.settings.applications.manageapplications;
 
-import static androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_IDLE;
 import static com.android.settings.applications.manageapplications.AppFilterRegistry
         .FILTER_APPS_ALL;
 import static com.android.settings.applications.manageapplications.AppFilterRegistry
@@ -38,6 +37,8 @@
 import static com.android.settings.applications.manageapplications.AppFilterRegistry
         .FILTER_APPS_WORK;
 
+import static androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_IDLE;
+
 import android.annotation.Nullable;
 import android.annotation.StringRes;
 import android.app.Activity;
@@ -141,7 +142,7 @@
         implements View.OnClickListener, OnItemSelectedListener {
 
     static final String TAG = "ManageApplications";
-    static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
+    static final boolean DEBUG = true;
 
     // Intent extras.
     public static final String EXTRA_CLASSNAME = "classname";
@@ -721,7 +722,9 @@
         mFilter = mFilterAdapter.getFilter(position);
         mApplications.setFilter(mFilter);
 
-        if (DEBUG) Log.d(TAG, "Selecting filter " + mFilter);
+        if (DEBUG) {
+            Log.d(TAG, "Selecting filter " + getContext().getText(mFilter.getTitle()));
+        }
     }
 
     @Override
@@ -784,7 +787,7 @@
                 return;
             }
             if (DEBUG) {
-                Log.d(TAG, "Enabling filter " + filter);
+                Log.d(TAG, "Enabling filter " + mContext.getText(filter.getTitle()));
             }
             mFilterOptions.add(filter);
             Collections.sort(mFilterOptions);
@@ -793,7 +796,8 @@
             notifyDataSetChanged();
             if (mFilterOptions.size() == 1) {
                 if (DEBUG) {
-                    Log.d(TAG, "Auto selecting filter " + filter);
+                    Log.d(TAG, "Auto selecting filter " + filter + " " + mContext.getText(
+                            filter.getTitle()));
                 }
                 mManageApplications.mFilterSpinner.setSelection(0);
                 mManageApplications.onItemSelected(null, null, 0, 0);
@@ -816,7 +820,8 @@
                 return;
             }
             if (DEBUG) {
-                Log.d(TAG, "Disabling filter " + filter);
+                Log.d(TAG, "Disabling filter " + filter + " " + mContext.getText(
+                        filter.getTitle()));
             }
             Collections.sort(mFilterOptions);
             mManageApplications.mSpinnerHeader.setVisibility(
@@ -825,7 +830,8 @@
             if (mManageApplications.mFilter == filter) {
                 if (mFilterOptions.size() > 0) {
                     if (DEBUG) {
-                        Log.d(TAG, "Auto selecting filter " + mFilterOptions.get(0));
+                        Log.d(TAG, "Auto selecting filter " + mFilterOptions.get(0)
+                            + mContext.getText(mFilterOptions.get(0).getTitle()));
                     }
                     mManageApplications.mFilterSpinner.setSelection(0);
                     mManageApplications.onItemSelected(null, null, 0, 0);
@@ -1035,6 +1041,12 @@
             if (!mHasReceivedLoadEntries
                     || (mExtraInfoBridge != null && !mHasReceivedBridgeCallback)) {
                 // Don't rebuild the list until all the app entries are loaded.
+                if (DEBUG) {
+                    Log.d(TAG, "Not rebuilding until all the app entries loaded."
+                            + " !mHasReceivedLoadEntries=" + !mHasReceivedLoadEntries
+                            + " !mExtraInfoBridgeNull=" + (mExtraInfoBridge != null)
+                            + " !mHasReceivedBridgeCallback=" + !mHasReceivedBridgeCallback);
+                }
                 return;
             }
             ApplicationsState.AppFilter filterObj;
@@ -1140,6 +1152,9 @@
 
         @Override
         public void onRebuildComplete(ArrayList<AppEntry> entries) {
+            if (DEBUG) {
+                Log.d(TAG, "onRebuildComplete");
+            }
             final int filterType = mAppFilter.getFilterType();
             if (filterType == FILTER_APPS_POWER_WHITELIST ||
                     filterType == FILTER_APPS_POWER_WHITELIST_ALL) {
diff --git a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java
index 52d186b..2c94acc 100644
--- a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java
+++ b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java
@@ -173,8 +173,12 @@
         final Context prefContext = mPreferenceGroup.getContext();
         final int childrenCount = mPreferenceGroup.getPreferenceCount();
         for (int i = 0; i < childrenCount; i++) {
-            SwitchPreference pref = (SwitchPreference) mPreferenceGroup.getPreference(i);
-            preferenceCache.put(pref.getKey(), pref);
+            final Preference pref = mPreferenceGroup.getPreference(i);
+            if (!(pref instanceof SwitchPreference)) {
+                continue;
+            }
+            final SwitchPreference appSwitch = (SwitchPreference) pref;
+            preferenceCache.put(appSwitch.getKey(), appSwitch);
         }
         for (DeviceAdminListItem item : mAdmins) {
             final String key = item.getKey();
diff --git a/src/com/android/settings/connecteddevice/PreviouslyConnectedDevicePreferenceController.java b/src/com/android/settings/connecteddevice/PreviouslyConnectedDevicePreferenceController.java
index 0234647..eff97c3 100644
--- a/src/com/android/settings/connecteddevice/PreviouslyConnectedDevicePreferenceController.java
+++ b/src/com/android/settings/connecteddevice/PreviouslyConnectedDevicePreferenceController.java
@@ -59,7 +59,9 @@
         super.displayPreference(screen);
         if (isAvailable()) {
             mPreference = screen.findPreference(getPreferenceKey());
-            mBluetoothDeviceUpdater.setPrefContext(screen.getContext());
+            final Context context = screen.getContext();
+            mBluetoothDeviceUpdater.setPrefContext(context);
+            mSavedDockUpdater.setPreferenceContext(context);
         }
     }
 
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 4d24ad3..64afd94 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -115,6 +115,7 @@
 import com.android.settings.security.CryptKeeperSettings;
 import com.android.settings.security.LockscreenDashboardFragment;
 import com.android.settings.security.SecuritySettings;
+import com.android.settings.shortcut.CreateShortcut;
 import com.android.settings.sim.SimSettings;
 import com.android.settings.support.SupportDashboardActivity;
 import com.android.settings.system.ResetDashboardFragment;
@@ -132,6 +133,7 @@
 import com.android.settings.wifi.WifiSettings;
 import com.android.settings.wifi.calling.WifiCallingSettings;
 import com.android.settings.wifi.p2p.WifiP2pSettings;
+import com.android.settings.wifi.tether.WifiTetherSettings;
 
 public class SettingsGateway {
 
@@ -141,12 +143,14 @@
      */
     public static final String[] ENTRY_FRAGMENTS = {
             AdvancedConnectedDeviceDashboardFragment.class.getName(),
+            CreateShortcut.class.getName(),
             WifiSettings.class.getName(),
             ConfigureWifiSettings.class.getName(),
             SavedAccessPointsWifiSettings.class.getName(),
             SimSettings.class.getName(),
             TetherSettings.class.getName(),
             WifiP2pSettings.class.getName(),
+            WifiTetherSettings.class.getName(),
             BackgroundCheckSummary.class.getName(),
             VpnSettings.class.getName(),
             DateTimeSettings.class.getName(),
diff --git a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
index 48bd295..a443355 100644
--- a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
@@ -60,7 +60,6 @@
 public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
 
     private static final String TAG = "DashboardFeatureImpl";
-
     private static final String DASHBOARD_TILE_PREF_KEY_PREFIX = "dashboard_tile_pref_";
     private static final String META_DATA_KEY_INTENT_ACTION = "com.android.settings.intent.action";
     @VisibleForTesting
@@ -277,7 +276,8 @@
             return;
         }
         ProfileSelectDialog.updateUserHandlesIfNeeded(mContext, tile);
-        if (tile.userHandle == null) {
+
+        if (tile.userHandle == null || tile.isPrimaryProfileOnly()) {
             mMetricsFeatureProvider.logDashboardStartIntent(mContext, intent, sourceMetricCategory);
             activity.startActivityForResult(intent, 0);
         } else if (tile.userHandle.size() == 1) {
diff --git a/src/com/android/settings/display/BatteryPercentagePreferenceController.java b/src/com/android/settings/display/BatteryPercentagePreferenceController.java
index 1840d85..0bd4445 100644
--- a/src/com/android/settings/display/BatteryPercentagePreferenceController.java
+++ b/src/com/android/settings/display/BatteryPercentagePreferenceController.java
@@ -20,6 +20,7 @@
 import android.content.Context;
 import android.provider.Settings;
 
+import com.android.internal.R;
 import com.android.settings.core.PreferenceControllerMixin;
 import com.android.settingslib.core.AbstractPreferenceController;
 
@@ -41,7 +42,8 @@
 
     @Override
     public boolean isAvailable() {
-        return true;
+        return mContext.getResources()
+                .getBoolean(R.bool.config_battery_percentage_setting_available);
     }
 
     @Override
diff --git a/src/com/android/settings/localepicker/LocaleDragAndDropAdapter.java b/src/com/android/settings/localepicker/LocaleDragAndDropAdapter.java
index 4fdbec2..b59fe78 100644
--- a/src/com/android/settings/localepicker/LocaleDragAndDropAdapter.java
+++ b/src/com/android/settings/localepicker/LocaleDragAndDropAdapter.java
@@ -32,7 +32,7 @@
 import com.android.internal.app.LocalePicker;
 import com.android.internal.app.LocaleStore;
 import com.android.settings.R;
-import com.android.settings.shortcut.CreateShortcut;
+import com.android.settings.shortcut.ShortcutsUpdateTask;
 
 import java.text.NumberFormat;
 import java.util.ArrayList;
@@ -294,7 +294,7 @@
 
                 LocalePicker.updateLocales(mLocalesToSetNext);
                 mLocalesSetLast = mLocalesToSetNext;
-                new CreateShortcut.ShortcutsUpdateTask(mContext).execute();
+                new ShortcutsUpdateTask(mContext).execute();
 
                 mLocalesToSetNext = null;
 
diff --git a/src/com/android/settings/shortcut/CreateShortcut.java b/src/com/android/settings/shortcut/CreateShortcut.java
index 953dfc0..b5b6438 100644
--- a/src/com/android/settings/shortcut/CreateShortcut.java
+++ b/src/com/android/settings/shortcut/CreateShortcut.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 The Android Open Source Project
+ * 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.
@@ -16,212 +16,57 @@
 
 package com.android.settings.shortcut;
 
-import android.app.LauncherActivity;
-import android.content.ComponentName;
+import static com.android.settings.search.actionbar.SearchMenuController
+        .NEED_SEARCH_ICON_IN_ACTION_BAR;
+
 import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ActivityInfo;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.content.pm.ShortcutInfo;
-import android.content.pm.ShortcutManager;
-import android.graphics.Bitmap;
-import android.graphics.Bitmap.Config;
-import android.graphics.Canvas;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.Icon;
-import android.graphics.drawable.LayerDrawable;
-import android.net.ConnectivityManager;
-import android.os.AsyncTask;
-import android.util.Log;
-import android.view.ContextThemeWrapper;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.View.MeasureSpec;
-import android.widget.ImageView;
-import android.widget.ListView;
+import android.os.Bundle;
 
 import com.android.internal.logging.nano.MetricsProto;
 import com.android.settings.R;
-import com.android.settings.Settings.TetherSettingsActivity;
-import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.dashboard.DashboardFragment;
 
-import java.util.ArrayList;
-import java.util.List;
-
-import androidx.annotation.VisibleForTesting;
-
-public class CreateShortcut extends LauncherActivity {
+/**
+ * UI for create widget/shortcut screen.
+ */
+public class CreateShortcut extends DashboardFragment {
 
     private static final String TAG = "CreateShortcut";
-    @VisibleForTesting
-    static final String SHORTCUT_ID_PREFIX = "component-shortcut-";
 
     @Override
-    protected Intent getTargetIntent() {
-        return getBaseIntent().addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+        Bundle args = getArguments();
+        if (args == null) {
+            args = new Bundle();
+            setArguments(args);
+        }
+        args.putBoolean(NEED_SEARCH_ICON_IN_ACTION_BAR, false);
     }
 
     @Override
-    protected void onListItemClick(ListView l, View v, int position, long id) {
-        final ListItem item = itemForPosition(position);
-        logCreateShortcut(item.resolveInfo);
-        setResult(RESULT_OK, createResultIntent(intentForPosition(position),
-                item.resolveInfo, item.label));
-        finish();
-    }
-
-    @VisibleForTesting
-    Intent createResultIntent(Intent shortcutIntent, ResolveInfo resolveInfo,
-            CharSequence label) {
-        shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
-        ShortcutManager sm = getSystemService(ShortcutManager.class);
-        ActivityInfo activityInfo = resolveInfo.activityInfo;
-
-        Icon maskableIcon = activityInfo.icon != 0 && activityInfo.applicationInfo != null
-                ? Icon.createWithAdaptiveBitmap(
-                createIcon(activityInfo.applicationInfo, activityInfo.icon,
-                        R.layout.shortcut_badge_maskable,
-                        getResources().getDimensionPixelSize(R.dimen.shortcut_size_maskable)))
-                : Icon.createWithResource(this, R.drawable.ic_launcher_settings);
-        String shortcutId = SHORTCUT_ID_PREFIX +
-                shortcutIntent.getComponent().flattenToShortString();
-        ShortcutInfo info = new ShortcutInfo.Builder(this, shortcutId)
-                .setShortLabel(label)
-                .setIntent(shortcutIntent)
-                .setIcon(maskableIcon)
-                .build();
-        Intent intent = sm.createShortcutResultIntent(info);
-        if (intent == null) {
-            intent = new Intent();
-        }
-        intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
-                Intent.ShortcutIconResource.fromContext(this, R.mipmap.ic_launcher_settings));
-        intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
-        intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, label);
-
-        if (activityInfo.icon != 0) {
-            intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, createIcon(
-                    activityInfo.applicationInfo,
-                    activityInfo.icon,
-                    R.layout.shortcut_badge,
-                    getResources().getDimensionPixelSize(R.dimen.shortcut_size)));
-        }
-        return intent;
-    }
-
-    private void logCreateShortcut(ResolveInfo info) {
-        if (info == null || info.activityInfo == null) {
-            return;
-        }
-        FeatureFactory.getFactory(this).getMetricsFeatureProvider().action(
-                this, MetricsProto.MetricsEvent.ACTION_SETTINGS_CREATE_SHORTCUT,
-                info.activityInfo.name);
-    }
-
-    private Bitmap createIcon(ApplicationInfo app, int resource, int layoutRes, int size) {
-        final Context context = new ContextThemeWrapper(this, android.R.style.Theme_Material);
-        final View view = LayoutInflater.from(context).inflate(layoutRes, null);
-        final int spec = MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY);
-        view.measure(spec, spec);
-        final Bitmap bitmap = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(),
-                Config.ARGB_8888);
-        final Canvas canvas = new Canvas(bitmap);
-
-        Drawable iconDrawable = null;
-        try {
-            iconDrawable =
-                    getPackageManager().getResourcesForApplication(app).getDrawable(resource);
-            if (iconDrawable instanceof LayerDrawable) {
-                iconDrawable = ((LayerDrawable) iconDrawable).getDrawable(1);
-            }
-            ((ImageView) view.findViewById(android.R.id.icon)).setImageDrawable(iconDrawable);
-        } catch (PackageManager.NameNotFoundException e) {
-            Log.w(TAG, "Cannot load icon from app " + app + ", returning a default icon");
-            Icon icon = Icon.createWithResource(this, R.drawable.ic_launcher_settings);
-            ((ImageView) view.findViewById(android.R.id.icon)).setImageIcon(icon);
-        }
-
-        view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
-        view.draw(canvas);
-        return bitmap;
+    public void onAttach(Context context) {
+        super.onAttach(context);
+        use(CreateShortcutPreferenceController.class).setActivity(getActivity());
     }
 
     @Override
-    protected boolean onEvaluateShowIcons() {
-        return false;
+    protected int getPreferenceScreenResId() {
+        return R.xml.create_shortcut;
     }
 
     @Override
-    protected void onSetContentView() {
-        setContentView(R.layout.activity_list);
+    protected String getLogTag() {
+        return TAG;
     }
 
-    /**
-     * Perform query on package manager for list items.  The default
-     * implementation queries for activities.
-     */
     @Override
-    protected List<ResolveInfo> onQueryPackageManager(Intent queryIntent) {
-        List<ResolveInfo> activities = getPackageManager().queryIntentActivities(queryIntent,
-                PackageManager.GET_META_DATA);
-        final ConnectivityManager cm =
-                (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
-        if (activities == null) {
-            return null;
-        }
-        for (int i = activities.size() - 1; i >= 0; i--) {
-            ResolveInfo info = activities.get(i);
-            if (info.activityInfo.name.endsWith(TetherSettingsActivity.class.getSimpleName())) {
-                if (!cm.isTetheringSupported()) {
-                    activities.remove(i);
-                }
-            }
-            if (!info.activityInfo.applicationInfo.isSystemApp()) {
-                Log.d(TAG, "Skipping non-system app: " + info.activityInfo);
-                activities.remove(i);
-            }
-        }
-        return activities;
+    public int getMetricsCategory() {
+        return MetricsProto.MetricsEvent.SETTINGS_CREATE_SHORTCUT;
     }
 
-    @VisibleForTesting
-    static Intent getBaseIntent() {
-        return new Intent(Intent.ACTION_MAIN).addCategory("com.android.settings.SHORTCUT");
-    }
-
-    public static class ShortcutsUpdateTask extends AsyncTask<Void, Void, Void> {
-
-        private final Context mContext;
-
-        public ShortcutsUpdateTask(Context context) {
-            mContext = context;
-        }
-
-        @Override
-        public Void doInBackground(Void... params) {
-            ShortcutManager sm = mContext.getSystemService(ShortcutManager.class);
-            PackageManager pm = mContext.getPackageManager();
-
-            List<ShortcutInfo> updates = new ArrayList<>();
-            for (ShortcutInfo info : sm.getPinnedShortcuts()) {
-                if (!info.getId().startsWith(SHORTCUT_ID_PREFIX)) {
-                    continue;
-                }
-                ComponentName cn = ComponentName.unflattenFromString(
-                        info.getId().substring(SHORTCUT_ID_PREFIX.length()));
-                ResolveInfo ri = pm.resolveActivity(getBaseIntent().setComponent(cn), 0);
-                if (ri == null) {
-                    continue;
-                }
-                updates.add(new ShortcutInfo.Builder(mContext, info.getId())
-                        .setShortLabel(ri.loadLabel(pm)).build());
-            }
-            if (!updates.isEmpty()) {
-                sm.updateShortcuts(updates);
-            }
-            return null;
-        }
+    @Override
+    public int getHelpResource() {
+        return 0;
     }
 }
diff --git a/src/com/android/settings/shortcut/CreateShortcutPreferenceController.java b/src/com/android/settings/shortcut/CreateShortcutPreferenceController.java
new file mode 100644
index 0000000..4848bf6
--- /dev/null
+++ b/src/com/android/settings/shortcut/CreateShortcutPreferenceController.java
@@ -0,0 +1,261 @@
+/*
+ * 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.shortcut;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ActivityInfo;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.content.pm.ShortcutInfo;
+import android.content.pm.ShortcutManager;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.Icon;
+import android.graphics.drawable.LayerDrawable;
+import android.net.ConnectivityManager;
+import android.util.Log;
+import android.view.ContextThemeWrapper;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.ImageView;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
+import com.android.settings.Settings.TetherSettingsActivity;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.overlay.FeatureFactory;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceGroup;
+
+/**
+ * {@link BasePreferenceController} that populates a list of widgets that Settings app support.
+ */
+public class CreateShortcutPreferenceController extends BasePreferenceController {
+
+    private static final String TAG = "CreateShortcutPrefCtrl";
+
+    static final String SHORTCUT_ID_PREFIX = "component-shortcut-";
+    static final Intent SHORTCUT_PROBE = new Intent(Intent.ACTION_MAIN)
+            .addCategory("com.android.settings.SHORTCUT")
+            .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+
+    private final ShortcutManager mShortcutManager;
+    private final PackageManager mPackageManager;
+    private final ConnectivityManager mConnectivityManager;
+    private final MetricsFeatureProvider mMetricsFeatureProvider;
+    private Activity mHost;
+
+    public CreateShortcutPreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey);
+        mConnectivityManager =
+                (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+        mShortcutManager = context.getSystemService(ShortcutManager.class);
+        mPackageManager = context.getPackageManager();
+        mMetricsFeatureProvider = FeatureFactory.getFactory(context)
+                .getMetricsFeatureProvider();
+    }
+
+    public void setActivity(Activity host) {
+        mHost = host;
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE_UNSEARCHABLE;
+    }
+
+    @Override
+    public void updateState(Preference preference) {
+        if (!(preference instanceof PreferenceGroup)) {
+            return;
+        }
+        final PreferenceGroup group = (PreferenceGroup) preference;
+        group.removeAll();
+        final List<ResolveInfo> shortcuts = queryShortcuts();
+        final Context uiContext = preference.getContext();
+        if (shortcuts.isEmpty()) {
+            return;
+        }
+        PreferenceCategory category = new PreferenceCategory(uiContext);
+        group.addPreference(category);
+        int bucket = 0;
+        for (ResolveInfo info : shortcuts) {
+            // Priority is not consecutive (aka, jumped), add a divider between prefs.
+            final int currentBucket = info.priority / 10;
+            boolean needDivider = currentBucket != bucket;
+            bucket = currentBucket;
+            if (needDivider) {
+                // add a new Category
+                category = new PreferenceCategory(uiContext);
+                group.addPreference(category);
+            }
+
+            final Preference pref = new Preference(uiContext);
+            pref.setTitle(info.loadLabel(mPackageManager));
+            pref.setKey(info.activityInfo.getComponentName().flattenToString());
+            pref.setOnPreferenceClickListener(clickTarget -> {
+                if (mHost == null) {
+                    return false;
+                }
+                final Intent shortcutIntent = createResultIntent(
+                        buildShortcutIntent(info),
+                        info, clickTarget.getTitle());
+                mHost.setResult(Activity.RESULT_OK, shortcutIntent);
+                logCreateShortcut(info);
+                mHost.finish();
+                return true;
+            });
+            category.addPreference(pref);
+        }
+    }
+
+    /**
+     * Create {@link Intent} that will be consumed by ShortcutManager, which later generates a
+     * launcher widget using this intent.
+     */
+    @VisibleForTesting
+    Intent createResultIntent(Intent shortcutIntent, ResolveInfo resolveInfo,
+            CharSequence label) {
+        final ActivityInfo activityInfo = resolveInfo.activityInfo;
+
+        final Icon maskableIcon;
+        if (activityInfo.icon != 0 && activityInfo.applicationInfo != null) {
+            maskableIcon = Icon.createWithAdaptiveBitmap(createIcon(
+                    activityInfo.applicationInfo, activityInfo.icon,
+                    R.layout.shortcut_badge_maskable,
+                    mContext.getResources().getDimensionPixelSize(R.dimen.shortcut_size_maskable)));
+        } else {
+            maskableIcon = Icon.createWithResource(mContext, R.drawable.ic_launcher_settings);
+        }
+        final String shortcutId = SHORTCUT_ID_PREFIX +
+                shortcutIntent.getComponent().flattenToShortString();
+        ShortcutInfo info = new ShortcutInfo.Builder(mContext, shortcutId)
+                .setShortLabel(label)
+                .setIntent(shortcutIntent)
+                .setIcon(maskableIcon)
+                .build();
+        Intent intent = mShortcutManager.createShortcutResultIntent(info);
+        if (intent == null) {
+            intent = new Intent();
+        }
+        intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
+                Intent.ShortcutIconResource.fromContext(mContext, R.mipmap.ic_launcher_settings))
+                .putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent)
+                .putExtra(Intent.EXTRA_SHORTCUT_NAME, label);
+
+        if (activityInfo.icon != 0) {
+            intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, createIcon(
+                    activityInfo.applicationInfo,
+                    activityInfo.icon,
+                    R.layout.shortcut_badge,
+                    mContext.getResources().getDimensionPixelSize(R.dimen.shortcut_size)));
+        }
+        return intent;
+    }
+
+    /**
+     * Finds all shortcut supported by Settings.
+     */
+    @VisibleForTesting
+    List<ResolveInfo> queryShortcuts() {
+        final List<ResolveInfo> shortcuts = new ArrayList<>();
+        final List<ResolveInfo> activities = mPackageManager.queryIntentActivities(SHORTCUT_PROBE,
+                PackageManager.GET_META_DATA);
+
+        if (activities == null) {
+            return null;
+        }
+        for (ResolveInfo info : activities) {
+            if (info.activityInfo.name.endsWith(TetherSettingsActivity.class.getSimpleName())) {
+                if (!mConnectivityManager.isTetheringSupported()) {
+                    continue;
+                }
+            }
+            if (!info.activityInfo.applicationInfo.isSystemApp()) {
+                Log.d(TAG, "Skipping non-system app: " + info.activityInfo);
+                continue;
+            }
+            shortcuts.add(info);
+        }
+        Collections.sort(shortcuts, SHORTCUT_COMPARATOR);
+        return shortcuts;
+    }
+
+    private void logCreateShortcut(ResolveInfo info) {
+        if (info == null || info.activityInfo == null) {
+            return;
+        }
+        mMetricsFeatureProvider.action(
+                mContext, MetricsProto.MetricsEvent.ACTION_SETTINGS_CREATE_SHORTCUT,
+                info.activityInfo.name);
+    }
+
+    private Intent buildShortcutIntent(ResolveInfo info) {
+        return new Intent(SHORTCUT_PROBE)
+                .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP)
+                .setClassName(info.activityInfo.packageName, info.activityInfo.name);
+    }
+
+    private Bitmap createIcon(ApplicationInfo app, int resource, int layoutRes, int size) {
+        final Context context = new ContextThemeWrapper(mContext, android.R.style.Theme_Material);
+        final View view = LayoutInflater.from(context).inflate(layoutRes, null);
+        final int spec = View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY);
+        view.measure(spec, spec);
+        final Bitmap bitmap = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(),
+                Bitmap.Config.ARGB_8888);
+        final Canvas canvas = new Canvas(bitmap);
+
+        Drawable iconDrawable;
+        try {
+            iconDrawable = mPackageManager.getResourcesForApplication(app).getDrawable(resource);
+            if (iconDrawable instanceof LayerDrawable) {
+                iconDrawable = ((LayerDrawable) iconDrawable).getDrawable(1);
+            }
+            ((ImageView) view.findViewById(android.R.id.icon)).setImageDrawable(iconDrawable);
+        } catch (PackageManager.NameNotFoundException e) {
+            Log.w(TAG, "Cannot load icon from app " + app + ", returning a default icon");
+            Icon icon = Icon.createWithResource(mContext, R.drawable.ic_launcher_settings);
+            ((ImageView) view.findViewById(android.R.id.icon)).setImageIcon(icon);
+        }
+
+        view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
+        view.draw(canvas);
+        return bitmap;
+    }
+
+    private static final Comparator<ResolveInfo> SHORTCUT_COMPARATOR =
+            new Comparator<ResolveInfo>() {
+
+                @Override
+                public int compare(ResolveInfo i1, ResolveInfo i2) {
+                    return i1.priority - i2.priority;
+                }
+            };
+}
diff --git a/src/com/android/settings/shortcut/ShortcutsUpdateTask.java b/src/com/android/settings/shortcut/ShortcutsUpdateTask.java
new file mode 100644
index 0000000..54f7d1c
--- /dev/null
+++ b/src/com/android/settings/shortcut/ShortcutsUpdateTask.java
@@ -0,0 +1,66 @@
+/*
+ * 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.shortcut;
+
+import static com.android.settings.shortcut.CreateShortcutPreferenceController.SHORTCUT_ID_PREFIX;
+import static com.android.settings.shortcut.CreateShortcutPreferenceController.SHORTCUT_PROBE;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.content.pm.ShortcutInfo;
+import android.content.pm.ShortcutManager;
+import android.os.AsyncTask;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ShortcutsUpdateTask extends AsyncTask<Void, Void, Void> {
+
+    private final Context mContext;
+
+    public ShortcutsUpdateTask(Context context) {
+        mContext = context;
+    }
+
+    @Override
+    public Void doInBackground(Void... params) {
+        ShortcutManager sm = mContext.getSystemService(ShortcutManager.class);
+        PackageManager pm = mContext.getPackageManager();
+
+        List<ShortcutInfo> updates = new ArrayList<>();
+        for (ShortcutInfo info : sm.getPinnedShortcuts()) {
+            if (!info.getId().startsWith(SHORTCUT_ID_PREFIX)) {
+                continue;
+            }
+            ComponentName cn = ComponentName.unflattenFromString(
+                    info.getId().substring(SHORTCUT_ID_PREFIX.length()));
+            ResolveInfo ri = pm.resolveActivity(new Intent(SHORTCUT_PROBE).setComponent(cn), 0);
+            if (ri == null) {
+                continue;
+            }
+            updates.add(new ShortcutInfo.Builder(mContext, info.getId())
+                    .setShortLabel(ri.loadLabel(pm)).build());
+        }
+        if (!updates.isEmpty()) {
+            sm.updateShortcuts(updates);
+        }
+        return null;
+    }
+}
diff --git a/tests/robotests/assets/grandfather_not_implementing_index_provider b/tests/robotests/assets/grandfather_not_implementing_index_provider
index a55f024..6bbdca7 100644
--- a/tests/robotests/assets/grandfather_not_implementing_index_provider
+++ b/tests/robotests/assets/grandfather_not_implementing_index_provider
@@ -5,6 +5,7 @@
 com.android.settings.bluetooth.BluetoothPairingDetail
 com.android.settings.accounts.AccountDetailDashboardFragment
 com.android.settings.accounts.ManagedProfileSettings
+com.android.settings.shortcut.CreateShortcut
 com.android.settings.fuelgauge.PowerUsageAnomalyDetails
 com.android.settings.fuelgauge.AdvancedPowerUsageDetail
 com.android.settings.development.featureflags.FeatureFlagsDashboard
diff --git a/tests/robotests/src/com/android/settings/accessibility/ColorInversionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/ColorInversionPreferenceControllerTest.java
new file mode 100644
index 0000000..880cb9f
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/ColorInversionPreferenceControllerTest.java
@@ -0,0 +1,97 @@
+/*
+ * 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.accessibility;
+
+import static com.android.settings.accessibility.ColorInversionPreferenceController.OFF;
+import static com.android.settings.accessibility.ColorInversionPreferenceController.ON;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+
+import androidx.preference.SwitchPreference;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class ColorInversionPreferenceControllerTest {
+    private static final int UNKNOWN = -1;
+    private Context mContext;
+    private ColorInversionPreferenceController mController;
+    private SwitchPreference mPreference;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mContext = RuntimeEnvironment.application;
+        mController = new ColorInversionPreferenceController(mContext, "pref_key");
+        mPreference = new SwitchPreference(mContext);
+        mController.updateState(mPreference);
+    }
+
+    @Test
+    public void getAvailabilityStatus_available() {
+        assertThat(mController.getAvailabilityStatus()).isEqualTo(
+                BasePreferenceController.AVAILABLE);
+    }
+
+    @Test
+    public void isChecked_enabled() {
+        Settings.System.putInt(mContext.getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, ON);
+
+        mController.updateState(mPreference);
+
+        assertThat(mController.isChecked()).isTrue();
+        assertThat(mPreference.isChecked()).isTrue();
+    }
+
+    @Test
+    public void isChecked_disabled() {
+        Settings.System.putInt(mContext.getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, OFF);
+
+        mController.updateState(mPreference);
+
+        assertThat(mController.isChecked()).isFalse();
+        assertThat(mPreference.isChecked()).isFalse();
+    }
+
+    @Test
+    public void setChecked_enabled() {
+        mController.setChecked(true);
+
+        assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, UNKNOWN)).isEqualTo(ON);
+    }
+
+    @Test
+    public void setChecked_disabled() {
+        mController.setChecked(false);
+
+        assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, UNKNOWN)).isEqualTo(OFF);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
index 7cfdf32..7228a2f 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
@@ -16,12 +16,16 @@
 
 package com.android.settings.dashboard;
 
+import static com.android.settingslib.drawer.TileUtils.META_DATA_KEY_PROFILE;
+import static com.android.settingslib.drawer.TileUtils.PROFILE_ALL;
+import static com.android.settingslib.drawer.TileUtils.PROFILE_PRIMARY;
 import static com.google.common.truth.Truth.assertThat;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyInt;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyZeroInteractions;
@@ -39,7 +43,7 @@
 import android.os.Bundle;
 import android.os.UserHandle;
 import android.os.UserManager;
-
+import androidx.preference.Preference;
 import com.android.internal.logging.nano.MetricsProto;
 import com.android.settings.R;
 import com.android.settings.SettingsActivity;
@@ -55,6 +59,7 @@
 import com.android.settingslib.drawer.Tile;
 import com.android.settingslib.drawer.TileUtils;
 
+import java.util.ArrayList;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -68,10 +73,6 @@
 import org.robolectric.shadows.ShadowApplication;
 import org.robolectric.util.ReflectionHelpers;
 
-import java.util.ArrayList;
-
-import androidx.preference.Preference;
-
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(shadows = ShadowUserManager.class)
 public class DashboardFeatureProviderImplTest {
@@ -455,4 +456,56 @@
     public void testShouldTintIcon_disabledInResources_shouldBeFalse() {
         assertThat(mImpl.shouldTintIcon()).isFalse();
     }
+
+    @Test
+    public void openTileIntent_profileSelectionDialog_shouldShow() {
+        final Tile tile = new Tile();
+        tile.metaData = new Bundle();
+        tile.intent = new Intent();
+        tile.intent.setComponent(new ComponentName("pkg", "class"));
+        final ArrayList<UserHandle> handles = new ArrayList<>();
+        handles.add(new UserHandle(0));
+        handles.add(new UserHandle(10));
+        tile.userHandle = handles;
+        mImpl.openTileIntent(mActivity, tile);
+
+        verify(mActivity, never())
+            .startActivityForResult(any(Intent.class), eq(0));
+        verify(mActivity).getFragmentManager();
+    }
+
+    @Test
+    public void openTileIntent_profileSelectionDialog_explicitMetadataShouldShow() {
+        final Tile tile = new Tile();
+        tile.metaData = new Bundle();
+        tile.metaData.putString(META_DATA_KEY_PROFILE, PROFILE_ALL);
+        tile.intent = new Intent();
+        tile.intent.setComponent(new ComponentName("pkg", "class"));
+        final ArrayList<UserHandle> handles = new ArrayList<>();
+        handles.add(new UserHandle(0));
+        handles.add(new UserHandle(10));
+        tile.userHandle = handles;
+        mImpl.openTileIntent(mActivity, tile);
+
+        verify(mActivity, never())
+            .startActivityForResult(any(Intent.class), eq(0));
+        verify(mActivity).getFragmentManager();
+    }
+    @Test
+    public void openTileIntent_profileSelectionDialog_shouldNotShow() {
+        final Tile tile = new Tile();
+        tile.metaData = new Bundle();
+        tile.metaData.putString(META_DATA_KEY_PROFILE, PROFILE_PRIMARY);
+        tile.intent = new Intent();
+        tile.intent.setComponent(new ComponentName("pkg", "class"));
+        final ArrayList<UserHandle> handles = new ArrayList<>();
+        handles.add(new UserHandle(0));
+        handles.add(new UserHandle(10));
+        tile.userHandle = handles;
+        mImpl.openTileIntent(mActivity, tile);
+
+        verify(mActivity)
+            .startActivityForResult(any(Intent.class), eq(0));
+        verify(mActivity, never()).getFragmentManager();
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/shortcut/CreateShortcutPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/shortcut/CreateShortcutPreferenceControllerTest.java
new file mode 100644
index 0000000..6bccfe5
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/shortcut/CreateShortcutPreferenceControllerTest.java
@@ -0,0 +1,153 @@
+/*
+ * 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.shortcut;
+
+import static com.android.settings.shortcut.CreateShortcutPreferenceController.SHORTCUT_ID_PREFIX;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ActivityInfo;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.ResolveInfo;
+import android.content.pm.ShortcutInfo;
+import android.content.pm.ShortcutManager;
+
+import com.android.settings.Settings;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.ShadowConnectivityManager;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadow.api.Shadow;
+import org.robolectric.shadows.ShadowPackageManager;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Tests for {@link CreateShortcutPreferenceController}
+ */
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(shadows = ShadowConnectivityManager.class)
+public class CreateShortcutPreferenceControllerTest {
+
+    @Mock
+    private ShortcutManager mShortcutManager;
+    @Mock
+    private Activity mHost;
+
+    private Context mContext;
+    private ShadowConnectivityManager mShadowConnectivityManager;
+    private ShadowPackageManager mPackageManager;
+    private CreateShortcutPreferenceController mController;
+
+    @Before
+    public void setup() {
+        MockitoAnnotations.initMocks(this);
+        mContext = spy(RuntimeEnvironment.application);
+        doReturn(mShortcutManager).when(mContext).getSystemService(eq(Context.SHORTCUT_SERVICE));
+        mPackageManager = Shadow.extract(mContext.getPackageManager());
+        mShadowConnectivityManager = ShadowConnectivityManager.getShadow();
+        mShadowConnectivityManager.setTetheringSupported(true);
+
+        mController = new CreateShortcutPreferenceController(mContext, "key");
+        mController.setActivity(mHost);
+    }
+
+    @Test
+    public void createResultIntent() {
+        when(mShortcutManager.createShortcutResultIntent(any(ShortcutInfo.class)))
+                .thenReturn(new Intent().putExtra("d1", "d2"));
+
+        final Intent intent = new Intent(CreateShortcutPreferenceController.SHORTCUT_PROBE)
+                .setClass(mContext, Settings.ManageApplicationsActivity.class);
+        final ResolveInfo ri = mContext.getPackageManager().resolveActivity(intent, 0);
+        final Intent result = mController.createResultIntent(intent, ri, "dummy");
+
+        assertThat(result.getStringExtra("d1")).isEqualTo("d2");
+        assertThat((Object) result.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT)).isNotNull();
+
+        ArgumentCaptor<ShortcutInfo> infoCaptor = ArgumentCaptor.forClass(ShortcutInfo.class);
+        verify(mShortcutManager, times(1))
+                .createShortcutResultIntent(infoCaptor.capture());
+        assertThat(infoCaptor.getValue().getId())
+                .isEqualTo(SHORTCUT_ID_PREFIX + intent.getComponent().flattenToShortString());
+    }
+
+    @Test
+    public void queryShortcuts_shouldOnlyIncludeSystemApp() {
+        final ResolveInfo ri1 = new ResolveInfo();
+        ri1.activityInfo = new ActivityInfo();
+        ri1.activityInfo.name = "activity1";
+        ri1.activityInfo.applicationInfo = new ApplicationInfo();
+        ri1.activityInfo.applicationInfo.flags = 0;
+        final ResolveInfo ri2 = new ResolveInfo();
+        ri2.activityInfo = new ActivityInfo();
+        ri2.activityInfo.name = "activity2";
+        ri2.activityInfo.applicationInfo = new ApplicationInfo();
+        ri2.activityInfo.applicationInfo.flags = ApplicationInfo.FLAG_SYSTEM;
+
+        mPackageManager.addResolveInfoForIntent(
+                new Intent(CreateShortcutPreferenceController.SHORTCUT_PROBE),
+                Arrays.asList(ri1, ri2));
+
+        final List<ResolveInfo> info = mController.queryShortcuts();
+        assertThat(info).hasSize(1);
+        assertThat(info.get(0)).isEqualTo(ri2);
+    }
+
+    @Test
+    public void queryShortcuts_shouldSortBasedOnPriority() {
+        final ResolveInfo ri1 = new ResolveInfo();
+        ri1.priority = 100;
+        ri1.activityInfo = new ActivityInfo();
+        ri1.activityInfo.name = "activity1";
+        ri1.activityInfo.applicationInfo = new ApplicationInfo();
+        ri1.activityInfo.applicationInfo.flags = ApplicationInfo.FLAG_SYSTEM;
+
+        final ResolveInfo ri2 = new ResolveInfo();
+        ri1.priority = 50;
+        ri2.activityInfo = new ActivityInfo();
+        ri2.activityInfo.name = "activity2";
+        ri2.activityInfo.applicationInfo = new ApplicationInfo();
+        ri2.activityInfo.applicationInfo.flags = ApplicationInfo.FLAG_SYSTEM;
+
+        mPackageManager.addResolveInfoForIntent(
+                new Intent(CreateShortcutPreferenceController.SHORTCUT_PROBE),
+                Arrays.asList(ri1, ri2));
+
+        final List<ResolveInfo> info = mController.queryShortcuts();
+        assertThat(info).hasSize(2);
+        assertThat(info.get(0)).isEqualTo(ri2);
+        assertThat(info.get(1)).isEqualTo(ri1);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/shortcut/CreateShortcutTest.java b/tests/robotests/src/com/android/settings/shortcut/CreateShortcutTest.java
deleted file mode 100644
index c56819b..0000000
--- a/tests/robotests/src/com/android/settings/shortcut/CreateShortcutTest.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * 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.shortcut;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ActivityInfo;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.content.pm.ShortcutInfo;
-import android.content.pm.ShortcutManager;
-
-import com.android.settings.Settings;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.testutils.shadow.ShadowConnectivityManager;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Captor;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.Robolectric;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-import org.robolectric.shadow.api.Shadow;
-import org.robolectric.shadows.ShadowPackageManager;
-
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Tests for {@link CreateShortcutTest}
- */
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(shadows = ShadowConnectivityManager.class)
-public class CreateShortcutTest {
-
-    private static final String SHORTCUT_ID_PREFIX = CreateShortcut.SHORTCUT_ID_PREFIX;
-
-    private Context mContext;
-    private ShadowConnectivityManager mShadowConnectivityManager;
-    private ShadowPackageManager mPackageManager;
-
-    @Mock
-    private ShortcutManager mShortcutManager;
-    @Captor
-    private ArgumentCaptor<List<ShortcutInfo>> mListCaptor;
-
-    @Before
-    public void setup() {
-        MockitoAnnotations.initMocks(this);
-        mContext = RuntimeEnvironment.application;
-        mPackageManager = Shadow.extract(mContext.getPackageManager());
-        mShadowConnectivityManager = ShadowConnectivityManager.getShadow();
-        mShadowConnectivityManager.setTetheringSupported(true);
-    }
-
-    @Test
-    public void createResultIntent() {
-        CreateShortcut orgActivity = Robolectric.setupActivity(CreateShortcut.class);
-        CreateShortcut activity = spy(orgActivity);
-        doReturn(mShortcutManager).when(activity).getSystemService(eq(Context.SHORTCUT_SERVICE));
-
-        when(mShortcutManager.createShortcutResultIntent(any(ShortcutInfo.class)))
-                .thenReturn(new Intent().putExtra("d1", "d2"));
-
-        final Intent intent = CreateShortcut.getBaseIntent()
-                .setClass(activity, Settings.ManageApplicationsActivity.class);
-        final ResolveInfo ri = activity.getPackageManager().resolveActivity(intent, 0);
-        final Intent result = activity.createResultIntent(intent, ri, "dummy");
-
-        assertThat(result.getStringExtra("d1")).isEqualTo("d2");
-        assertThat((Object) result.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT)).isNotNull();
-
-        ArgumentCaptor<ShortcutInfo> infoCaptor = ArgumentCaptor.forClass(ShortcutInfo.class);
-        verify(mShortcutManager, times(1))
-                .createShortcutResultIntent(infoCaptor.capture());
-        assertThat(infoCaptor.getValue().getId())
-                .isEqualTo(SHORTCUT_ID_PREFIX + intent.getComponent().flattenToShortString());
-    }
-
-    @Test
-    public void shortcutsUpdateTask() {
-        mContext = spy(RuntimeEnvironment.application);
-        doReturn(mShortcutManager).when(mContext).getSystemService(eq(Context.SHORTCUT_SERVICE));
-        final Intent shortcut1 = CreateShortcut.getBaseIntent().setComponent(
-                new ComponentName(mContext, Settings.ManageApplicationsActivity.class));
-        final ResolveInfo ri1 = mock(ResolveInfo.class);
-        final Intent shortcut2 = CreateShortcut.getBaseIntent().setComponent(
-                new ComponentName(mContext, Settings.SoundSettingsActivity.class));
-        final ResolveInfo ri2 = mock(ResolveInfo.class);
-        when(ri1.loadLabel(any(PackageManager.class))).thenReturn("label1");
-        when(ri2.loadLabel(any(PackageManager.class))).thenReturn("label2");
-        mPackageManager.addResolveInfoForIntent(shortcut1, ri1);
-        mPackageManager.addResolveInfoForIntent(shortcut2, ri2);
-
-        final List<ShortcutInfo> pinnedShortcuts = Arrays.asList(
-                makeShortcut("d1"),
-                makeShortcut("d2"),
-                makeShortcut(Settings.ManageApplicationsActivity.class),
-                makeShortcut("d3"),
-                makeShortcut(Settings.SoundSettingsActivity.class));
-        when(mShortcutManager.getPinnedShortcuts()).thenReturn(pinnedShortcuts);
-
-        new CreateShortcut.ShortcutsUpdateTask(mContext).doInBackground();
-
-        verify(mShortcutManager, times(1)).updateShortcuts(mListCaptor.capture());
-
-        final List<ShortcutInfo> updates = mListCaptor.getValue();
-
-        assertThat(updates).hasSize(2);
-        assertThat(pinnedShortcuts.get(2).getId()).isEqualTo(updates.get(0).getId());
-        assertThat(pinnedShortcuts.get(4).getId()).isEqualTo(updates.get(1).getId());
-    }
-
-    @Test
-    public void queryActivities_shouldOnlyIncludeSystemApp() {
-        final ResolveInfo ri1 = new ResolveInfo();
-        ri1.activityInfo = new ActivityInfo();
-        ri1.activityInfo.name = "activity1";
-        ri1.activityInfo.applicationInfo = new ApplicationInfo();
-        ri1.activityInfo.applicationInfo.flags = 0;
-        final ResolveInfo ri2 = new ResolveInfo();
-        ri2.activityInfo = new ActivityInfo();
-        ri2.activityInfo.name = "activity2";
-        ri2.activityInfo.applicationInfo = new ApplicationInfo();
-        ri2.activityInfo.applicationInfo.flags = ApplicationInfo.FLAG_SYSTEM;
-
-        mPackageManager.addResolveInfoForIntent(CreateShortcut.getBaseIntent(),
-                Arrays.asList(ri1, ri2));
-
-        TestClass orgActivity = Robolectric.setupActivity(TestClass.class);
-        TestClass activity = spy(orgActivity);
-
-        List<ResolveInfo> info = activity.onQueryPackageManager(CreateShortcut.getBaseIntent());
-        assertThat(info).hasSize(1);
-        assertThat(info.get(0)).isEqualTo(ri2);
-    }
-
-    private ShortcutInfo makeShortcut(Class<?> className) {
-        ComponentName cn = new ComponentName(mContext, className);
-        return makeShortcut(SHORTCUT_ID_PREFIX + cn.flattenToShortString());
-    }
-
-    private ShortcutInfo makeShortcut(String id) {
-        return new ShortcutInfo.Builder(mContext, id).build();
-    }
-
-    private static class TestClass extends CreateShortcut {
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/shortcut/ShortcutsUpdateTaskTest.java b/tests/robotests/src/com/android/settings/shortcut/ShortcutsUpdateTaskTest.java
new file mode 100644
index 0000000..955e069
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/shortcut/ShortcutsUpdateTaskTest.java
@@ -0,0 +1,118 @@
+/*
+ * 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.shortcut;
+
+import static com.android.settings.shortcut.CreateShortcutPreferenceController.SHORTCUT_ID_PREFIX;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.content.pm.ShortcutInfo;
+import android.content.pm.ShortcutManager;
+
+import com.android.settings.Settings;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadow.api.Shadow;
+import org.robolectric.shadows.ShadowPackageManager;
+
+import java.util.Arrays;
+import java.util.List;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class ShortcutsUpdateTaskTest {
+
+    private Context mContext;
+    private ShadowPackageManager mPackageManager;
+
+    @Mock
+    private ShortcutManager mShortcutManager;
+    @Captor
+    private ArgumentCaptor<List<ShortcutInfo>> mListCaptor;
+
+    @Before
+    public void setup() {
+        MockitoAnnotations.initMocks(this);
+        mContext = RuntimeEnvironment.application;
+        mPackageManager = Shadow.extract(mContext.getPackageManager());
+    }
+
+    @Test
+    public void shortcutsUpdateTask() {
+        mContext = spy(RuntimeEnvironment.application);
+        doReturn(mShortcutManager).when(mContext).getSystemService(eq(Context.SHORTCUT_SERVICE));
+        final Intent shortcut1 = new Intent(CreateShortcutPreferenceController.SHORTCUT_PROBE)
+                .setComponent(new ComponentName(
+                        mContext, Settings.ManageApplicationsActivity.class));
+        final ResolveInfo ri1 = mock(ResolveInfo.class);
+        final Intent shortcut2 = new Intent(CreateShortcutPreferenceController.SHORTCUT_PROBE)
+                .setComponent(new ComponentName(
+                        mContext, Settings.SoundSettingsActivity.class));
+        final ResolveInfo ri2 = mock(ResolveInfo.class);
+        when(ri1.loadLabel(any(PackageManager.class))).thenReturn("label1");
+        when(ri2.loadLabel(any(PackageManager.class))).thenReturn("label2");
+        mPackageManager.addResolveInfoForIntent(shortcut1, ri1);
+        mPackageManager.addResolveInfoForIntent(shortcut2, ri2);
+
+        final List<ShortcutInfo> pinnedShortcuts = Arrays.asList(
+                makeShortcut("d1"),
+                makeShortcut("d2"),
+                makeShortcut(Settings.ManageApplicationsActivity.class),
+                makeShortcut("d3"),
+                makeShortcut(Settings.SoundSettingsActivity.class));
+        when(mShortcutManager.getPinnedShortcuts()).thenReturn(pinnedShortcuts);
+
+        new ShortcutsUpdateTask(mContext).doInBackground();
+
+        verify(mShortcutManager, times(1)).updateShortcuts(mListCaptor.capture());
+
+        final List<ShortcutInfo> updates = mListCaptor.getValue();
+
+        assertThat(updates).hasSize(2);
+        assertThat(pinnedShortcuts.get(2).getId()).isEqualTo(updates.get(0).getId());
+        assertThat(pinnedShortcuts.get(4).getId()).isEqualTo(updates.get(1).getId());
+    }
+
+    private ShortcutInfo makeShortcut(Class<?> className) {
+        ComponentName cn = new ComponentName(mContext, className);
+        return makeShortcut(SHORTCUT_ID_PREFIX + cn.flattenToShortString());
+    }
+
+
+    private ShortcutInfo makeShortcut(String id) {
+        return new ShortcutInfo.Builder(mContext, id).build();
+    }
+}