Merge "Always show wifi wake setting."
diff --git a/res/color/preference_highligh_color.xml b/res/color/preference_highligh_color.xml
new file mode 100644
index 0000000..0a8f770
--- /dev/null
+++ b/res/color/preference_highligh_color.xml
@@ -0,0 +1,20 @@
+<?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.
+  -->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:alpha="0.1" android:color="?android:attr/colorAccent" />
+</selector>
\ No newline at end of file
diff --git a/res/values/bools.xml b/res/values/bools.xml
index ab8a6fd..617ab7b 100644
--- a/res/values/bools.xml
+++ b/res/values/bools.xml
@@ -158,4 +158,13 @@
 
     <!-- Whether system_update_settings should be shown or not. -->
     <bool name="config_show_system_update_settings">true</bool>
+
+    <!-- Whether device_model should be shown or not. -->
+    <bool name="config_show_device_model">true</bool>
+
+    <!-- Whether wifi_ip_address should be shown or not. -->
+    <bool name="config_show_wifi_ip_address">true</bool>
+
+    <!-- Whether wifi_mac_address should be shown or not. -->
+    <bool name="config_show_wifi_mac_address">true</bool>
 </resources>
diff --git a/res/values/ids.xml b/res/values/ids.xml
index dcf279a..66af163 100644
--- a/res/values/ids.xml
+++ b/res/values/ids.xml
@@ -17,7 +17,7 @@
 */
 -->
 <resources>
-    <item type="id" name="preference_highlight_key" />
+    <item type="id" name="preference_highlighted" />
 
     <item type="id" name="lock_none" />
     <item type="id" name="lock_pin" />
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9a6ff90..4b2c673 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -6145,7 +6145,7 @@
     <!-- User settings -->
     <skip/>
 
-    <!-- User settings screen title [CHAR LIMIT=25] -->
+    <!-- User settings screen title [CHAR LIMIT=40] -->
     <string name="user_settings_title">Multiple users</string>
     <!-- User settings header for list of users and profiles [CHAR LIMIT=40] -->
     <string name="user_list_title">Users &amp; profiles</string>
@@ -8429,7 +8429,7 @@
     <string name="condition_airplane_summary">Wi-Fi, Bluetooth, and mobile network are turned off. You can\'t make phone calls or connect to the internet.</string>
 
     <!-- Title of condition that do not disturb is on [CHAR LIMIT=30] -->
-    <string name="condition_zen_title">Do not disturb is on (<xliff:g name="zen_mode_type" example="Alarms only">%1$s</xliff:g>)</string>
+    <string name="condition_zen_title">Do Not Disturb is on</string>
 
     <!-- Title of condition that battery saver is on [CHAR LIMIT=30] -->
     <string name="condition_battery_title">Battery Saver is on</string>
diff --git a/src/com/android/settings/SettingsPreferenceFragment.java b/src/com/android/settings/SettingsPreferenceFragment.java
index c5d477a..2a593c2 100644
--- a/src/com/android/settings/SettingsPreferenceFragment.java
+++ b/src/com/android/settings/SettingsPreferenceFragment.java
@@ -30,9 +30,7 @@
 import android.support.annotation.XmlRes;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceGroup;
-import android.support.v7.preference.PreferenceGroupAdapter;
 import android.support.v7.preference.PreferenceScreen;
-import android.support.v7.preference.PreferenceViewHolder;
 import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
 import android.text.TextUtils;
@@ -49,6 +47,7 @@
 import com.android.settings.search.actionbar.SearchMenuController;
 import com.android.settings.support.actionbar.HelpMenuController;
 import com.android.settings.support.actionbar.HelpResourceProvider;
+import com.android.settings.widget.HighlightablePreferenceGroupAdapter;
 import com.android.settings.widget.LoadingViewController;
 import com.android.settingslib.CustomDialogPreference;
 import com.android.settingslib.CustomEditTextPreference;
@@ -65,9 +64,6 @@
 
     private static final String TAG = "SettingsPreference";
 
-    @VisibleForTesting
-    static final int DELAY_HIGHLIGHT_DURATION_MILLIS = 600;
-
     private static final String SAVE_HIGHLIGHTED_KEY = "android:preference_highlighted";
 
     protected final FooterPreferenceMixin mFooterPreferenceMixin =
@@ -75,14 +71,11 @@
 
 
     private static final int ORDER_FIRST = -1;
-    private static final int ORDER_LAST = Integer.MAX_VALUE -1;
 
     private SettingsDialogFragment mDialogFragment;
     // Cache the content resolver for async callbacks
     private ContentResolver mContentResolver;
 
-    private String mPreferenceKey;
-
     private RecyclerView.Adapter mCurrentRootAdapter;
     private boolean mIsDataSetObserverRegistered = false;
     private RecyclerView.AdapterDataObserver mDataSetObserver =
@@ -146,8 +139,9 @@
 
         // Check if we should keep the preferences expanded.
         if (arguments != null) {
-            mPreferenceKey = arguments.getString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY);
-            if (!TextUtils.isEmpty(mPreferenceKey)) {
+            final String highlightKey =
+                    arguments.getString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY);
+            if (!TextUtils.isEmpty(highlightKey)) {
                 final PreferenceScreen screen = getPreferenceScreen();
                 if (screen != null) {
                     screen.setInitialExpandedChildrenCount(Integer.MAX_VALUE);
@@ -205,7 +199,9 @@
     public void onSaveInstanceState(Bundle outState) {
         super.onSaveInstanceState(outState);
 
-        outState.putBoolean(SAVE_HIGHLIGHTED_KEY, mPreferenceHighlighted);
+        if (mAdapter != null) {
+            outState.putBoolean(SAVE_HIGHLIGHTED_KEY, mAdapter.isHighlightRequested());
+        }
     }
 
     @Override
@@ -217,10 +213,7 @@
     @Override
     public void onResume() {
         super.onResume();
-
-        if (mPreferenceKey != null) {
-            highlightPreferenceIfNeeded();
-        }
+        highlightPreferenceIfNeeded();
     }
 
     @Override
@@ -263,13 +256,11 @@
     }
 
     public void highlightPreferenceIfNeeded() {
-        if (isAdded() && !mPreferenceHighlighted &&!TextUtils.isEmpty(mPreferenceKey)) {
-            getView().postDelayed(new Runnable() {
-                @Override
-                public void run() {
-                    highlightPreference(mPreferenceKey);
-                }
-            }, DELAY_HIGHLIGHT_DURATION_MILLIS);
+        if (!isAdded()) {
+            return;
+        }
+        if (mAdapter != null) {
+            mAdapter.requestHighlight(getView(), getListView());
         }
     }
 
@@ -340,24 +331,6 @@
         return mEmptyView;
     }
 
-    /**
-     * Return a valid ListView position or -1 if none is found
-     */
-    private int canUseListViewForHighLighting(String key) {
-        if (getListView() == null) {
-            return -1;
-        }
-
-        RecyclerView listView = getListView();
-        RecyclerView.Adapter adapter = listView.getAdapter();
-
-        if (adapter != null && adapter instanceof PreferenceGroupAdapter) {
-            return findListPositionFromKey((PreferenceGroupAdapter) adapter, key);
-        }
-
-        return -1;
-    }
-
     @Override
     public RecyclerView.LayoutManager onCreateLayoutManager() {
         mLayoutManager = new LinearLayoutManager(getContext());
@@ -366,7 +339,9 @@
 
     @Override
     protected RecyclerView.Adapter onCreateAdapter(PreferenceScreen preferenceScreen) {
-        mAdapter = new HighlightablePreferenceGroupAdapter(preferenceScreen);
+        mAdapter = new HighlightablePreferenceGroupAdapter(preferenceScreen,
+                getArguments().getString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY),
+                mPreferenceHighlighted);
         return mAdapter;
     }
 
@@ -375,7 +350,7 @@
     }
 
     protected void cacheRemoveAllPrefs(PreferenceGroup group) {
-        mPreferenceCache = new ArrayMap<String, Preference>();
+        mPreferenceCache = new ArrayMap<>();
         final int N = group.getPreferenceCount();
         for (int i = 0; i < N; i++) {
             Preference p = group.getPreference(i);
@@ -401,29 +376,6 @@
         return mPreferenceCache != null ? mPreferenceCache.size() : 0;
     }
 
-    private void highlightPreference(String key) {
-        final int position = canUseListViewForHighLighting(key);
-        if (position < 0) {
-            return;
-        }
-
-        mPreferenceHighlighted = true;
-        mLayoutManager.scrollToPosition(position);
-        mAdapter.highlight(position);
-    }
-
-    private int findListPositionFromKey(PreferenceGroupAdapter adapter, String key) {
-        final int count = adapter.getItemCount();
-        for (int n = 0; n < count; n++) {
-            final Preference preference = adapter.getItem(n);
-            final String preferenceKey = preference.getKey();
-            if (preferenceKey != null && preferenceKey.equals(key)) {
-                return n;
-            }
-        }
-        return -1;
-    }
-
     protected boolean removePreference(String key) {
         return removePreference(getPreferenceScreen(), key);
     }
@@ -692,11 +644,11 @@
     }
 
     protected boolean hasNextButton() {
-        return ((ButtonBarHandler)getActivity()).hasNextButton();
+        return ((ButtonBarHandler) getActivity()).hasNextButton();
     }
 
     protected Button getNextButton() {
-        return ((ButtonBarHandler)getActivity()).getNextButton();
+        return ((ButtonBarHandler) getActivity()).getNextButton();
     }
 
     public void finish() {
@@ -741,45 +693,10 @@
         } else {
             Log.w(TAG,
                     "Parent isn't SettingsActivity nor PreferenceActivity, thus there's no way to "
-                    + "launch the given Fragment (name: " + fragmentClass
-                    + ", requestCode: " + requestCode + ")");
+                            + "launch the given Fragment (name: " + fragmentClass
+                            + ", requestCode: " + requestCode + ")");
             return false;
         }
     }
 
-    public static class HighlightablePreferenceGroupAdapter extends PreferenceGroupAdapter {
-
-        @VisibleForTesting(otherwise=VisibleForTesting.NONE)
-        int initialHighlightedPosition = -1;
-
-        private int mHighlightPosition = -1;
-
-        public HighlightablePreferenceGroupAdapter(PreferenceGroup preferenceGroup) {
-            super(preferenceGroup);
-        }
-
-        public void highlight(int position) {
-            mHighlightPosition = position;
-            initialHighlightedPosition = position;
-            notifyDataSetChanged();
-        }
-
-        @Override
-        public void onBindViewHolder(PreferenceViewHolder holder, int position) {
-            super.onBindViewHolder(holder, position);
-            if (position == mHighlightPosition) {
-                View v = holder.itemView;
-                v.post(() -> {
-                    if (v.getBackground() != null) {
-                        final int centerX = v.getWidth() / 2;
-                        final int centerY = v.getHeight() / 2;
-                        v.getBackground().setHotspot(centerX, centerY);
-                    }
-                    v.setPressed(true);
-                    v.setPressed(false);
-                    mHighlightPosition = -1;
-                });
-            }
-        }
-    }
 }
diff --git a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
index a99ba65..7cc5d1a 100755
--- a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
+++ b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
@@ -162,13 +162,12 @@
         mUserManager = (UserManager) activity.getSystemService(Context.USER_SERVICE);
         mPm = activity.getPackageManager();
 
-        retrieveAppEntry();
-        startListeningToPackageRemove();
-
         if (!ensurePackageInfoAvailable(activity)) {
             return;
         }
 
+        startListeningToPackageRemove();
+
         mForceStopOptionsMenuController =
             new ForceStopOptionsMenuController(activity, this /* parent */, mDpm,
                 mMetricsFeatureProvider, getLifecycle());
@@ -205,6 +204,10 @@
 
     @Override
     protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
+        retrieveAppEntry();
+        if (mPackageInfo == null) {
+            return null;
+        }
         final String packageName = getPackageName();
         final List<AbstractPreferenceController> controllers = new ArrayList<>();
         final Lifecycle lifecycle = getLifecycle();
@@ -262,9 +265,6 @@
     }
 
     ApplicationsState.AppEntry getAppEntry() {
-        if (mAppEntry == null) {
-            retrieveAppEntry();
-        }
         return mAppEntry;
     }
 
@@ -273,9 +273,6 @@
     }
 
     PackageInfo getPackageInfo() {
-        if (mAppEntry == null) {
-            retrieveAppEntry();
-        }
         return mPackageInfo;
     }
 
@@ -361,7 +358,12 @@
                             PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER)
                             .execute((Object) null);
                 }
-                // continue with following operations
+                if (!refreshUi()) {
+                    onPackageRemoved();
+                } else {
+                    startListeningToPackageRemove();
+                }
+                break;
             case REQUEST_REMOVE_DEVICE_ADMIN:
                 if (!refreshUi()) {
                     setIntentAndFinish(true, true);
@@ -622,7 +624,8 @@
         return mPackageName;
     }
 
-    private void retrieveAppEntry() {
+    @VisibleForTesting
+    void retrieveAppEntry() {
         final Activity activity = getActivity();
         if (activity == null) {
             return;
diff --git a/src/com/android/settings/dashboard/conditional/DndCondition.java b/src/com/android/settings/dashboard/conditional/DndCondition.java
index a60c362..6498db6 100644
--- a/src/com/android/settings/dashboard/conditional/DndCondition.java
+++ b/src/com/android/settings/dashboard/conditional/DndCondition.java
@@ -15,9 +15,7 @@
  */
 package com.android.settings.dashboard.conditional;
 
-import android.app.ActivityManager;
 import android.app.NotificationManager;
-import android.app.StatusBarManager;
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
@@ -31,6 +29,8 @@
 
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.R;
+import com.android.settings.Utils;
+import com.android.settings.notification.ZenModeSettings;
 
 public class DndCondition extends Condition {
 
@@ -80,19 +80,6 @@
         mZen = bundle.getInt(KEY_STATE, Global.ZEN_MODE_OFF);
     }
 
-    private CharSequence getZenState() {
-        switch (mZen) {
-            case Settings.Global.ZEN_MODE_ALARMS:
-                return mManager.getContext().getString(R.string.zen_mode_option_alarms);
-            case Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
-                return mManager.getContext().getString(
-                        R.string.zen_mode_option_important_interruptions);
-            case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
-                return mManager.getContext().getString(R.string.zen_mode_option_no_interruptions);
-        }
-        return null;
-    }
-
     @Override
     public Icon getIcon() {
         return Icon.createWithResource(mManager.getContext(), R.drawable.ic_zen);
@@ -100,17 +87,13 @@
 
     @Override
     public CharSequence getTitle() {
-        return mManager.getContext().getString(R.string.condition_zen_title, getZenState());
+        return mManager.getContext().getString(R.string.condition_zen_title);
     }
 
     @Override
     public CharSequence getSummary() {
-        final boolean isForever = mConfig != null && mConfig.manualRule != null
-                && mConfig.manualRule.conditionId == null;
-        return isForever ? mManager.getContext().getString(com.android.internal.R.string.zen_mode_forever_dnd)
-                : ZenModeConfig.getConditionSummary(mManager.getContext(), mConfig,
-                ActivityManager.getCurrentUser(),
-                false);
+        return ZenModeConfig.getDescription(mManager.getContext(), mZen != Global.ZEN_MODE_OFF,
+                mConfig);
     }
 
     @Override
@@ -120,8 +103,9 @@
 
     @Override
     public void onPrimaryClick() {
-        StatusBarManager statusBar = mManager.getContext().getSystemService(StatusBarManager.class);
-        statusBar.expandSettingsPanel("dnd");
+        Utils.startWithFragment(mManager.getContext(), ZenModeSettings.class.getName(), null,
+                null, 0, R.string.zen_mode_settings_title, null,
+                MetricsEvent.NOTIFICATION_ZEN_MODE);
     }
 
     @Override
diff --git a/src/com/android/settings/dashboard/suggestions/SuggestionAdapter.java b/src/com/android/settings/dashboard/suggestions/SuggestionAdapter.java
index 070e758..9bcf2a2 100644
--- a/src/com/android/settings/dashboard/suggestions/SuggestionAdapter.java
+++ b/src/com/android/settings/dashboard/suggestions/SuggestionAdapter.java
@@ -116,7 +116,7 @@
         mConfig.setCardLayout(holder, suggestionCount, position);
         final Icon icon = suggestion.getIcon();
         final Drawable drawable = mCache.getIcon(icon);
-        if (drawable != null && TextUtils.equals(icon.getResPackage(), mContext.getPackageName())) {
+        if ((suggestion.getFlags() & Suggestion.FLAG_ICON_TINTABLE) != 0) {
             drawable.setTint(Utils.getColorAccent(mContext));
         }
         holder.icon.setImageDrawable(drawable);
diff --git a/src/com/android/settings/deviceinfo/DeviceModelPreferenceController.java b/src/com/android/settings/deviceinfo/DeviceModelPreferenceController.java
index ee069da..831c630 100644
--- a/src/com/android/settings/deviceinfo/DeviceModelPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/DeviceModelPreferenceController.java
@@ -41,7 +41,7 @@
 
     @Override
     public boolean isAvailable() {
-        return true;
+        return mContext.getResources().getBoolean(R.bool.config_show_device_model);
     }
 
     @Override
diff --git a/src/com/android/settings/deviceinfo/IpAddressPreferenceController.java b/src/com/android/settings/deviceinfo/IpAddressPreferenceController.java
index f4e2f8c..1af6397 100644
--- a/src/com/android/settings/deviceinfo/IpAddressPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/IpAddressPreferenceController.java
@@ -19,6 +19,8 @@
 import android.content.Context;
 
 import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.R;
+
 import com.android.settingslib.core.lifecycle.Lifecycle;
 import com.android.settingslib.deviceinfo.AbstractIpAddressPreferenceController;
 
@@ -31,5 +33,10 @@
         super(context, lifecycle);
     }
 
+    @Override
+    public boolean isAvailable() {
+        return mContext.getResources().getBoolean(R.bool.config_show_wifi_ip_address);
+    }
+
     // This space intentionally left blank
 }
diff --git a/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java b/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java
index 93f75bf..4eb2ddd 100644
--- a/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/PhoneNumberPreferenceController.java
@@ -58,7 +58,7 @@
 
     @Override
     public boolean isAvailable() {
-        return true;
+        return mTelephonyManager.isVoiceCapable();
     }
 
     @Override
diff --git a/src/com/android/settings/deviceinfo/WifiMacAddressPreferenceController.java b/src/com/android/settings/deviceinfo/WifiMacAddressPreferenceController.java
index 92390d7..8375310 100644
--- a/src/com/android/settings/deviceinfo/WifiMacAddressPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/WifiMacAddressPreferenceController.java
@@ -19,6 +19,7 @@
 import android.content.Context;
 
 import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.R;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 import com.android.settingslib.deviceinfo.AbstractWifiMacAddressPreferenceController;
 
@@ -31,5 +32,10 @@
         super(context, lifecycle);
     }
 
+    @Override
+    public boolean isAvailable() {
+        return mContext.getResources().getBoolean(R.bool.config_show_wifi_mac_address);
+    }
+
     // This space intentionally left blank
 }
diff --git a/src/com/android/settings/inputmethod/PhysicalKeyboardPreferenceController.java b/src/com/android/settings/inputmethod/PhysicalKeyboardPreferenceController.java
index ec0aecd..f80b68f 100644
--- a/src/com/android/settings/inputmethod/PhysicalKeyboardPreferenceController.java
+++ b/src/com/android/settings/inputmethod/PhysicalKeyboardPreferenceController.java
@@ -66,12 +66,12 @@
 
     @Override
     public void onPause() {
-        mIm.registerInputDeviceListener(this, null);
+        mIm.unregisterInputDeviceListener(this);
     }
 
     @Override
     public void onResume() {
-        mIm.unregisterInputDeviceListener(this);
+        mIm.registerInputDeviceListener(this, null);
     }
 
     @Override
diff --git a/src/com/android/settings/location/LocationEnabler.java b/src/com/android/settings/location/LocationEnabler.java
index 30ecf2e..fd557a3 100644
--- a/src/com/android/settings/location/LocationEnabler.java
+++ b/src/com/android/settings/location/LocationEnabler.java
@@ -169,7 +169,7 @@
 
         if (admin == null) {
             admin = RestrictedLockUtils.checkIfRestrictionEnforced(
-                    mContext, UserManager.DISALLOW_CONFIG_LOCATION_MODE, userId);
+                    mContext, UserManager.DISALLOW_CONFIG_LOCATION, userId);
         }
         return admin;
     }
diff --git a/src/com/android/settings/users/UserCapabilities.java b/src/com/android/settings/users/UserCapabilities.java
index 084a5db..f1bfae9 100644
--- a/src/com/android/settings/users/UserCapabilities.java
+++ b/src/com/android/settings/users/UserCapabilities.java
@@ -34,6 +34,7 @@
     boolean mCanAddGuest;
     boolean mDisallowAddUser;
     boolean mDisallowAddUserSetByAdmin;
+    boolean mDisallowSwitchUser;
     RestrictedLockUtils.EnforcedAdmin mEnforcedAdmin;
 
     private UserCapabilities() {}
@@ -79,6 +80,9 @@
         final boolean canAddUsersWhenLocked = mIsAdmin || Settings.Global.getInt(
                 context.getContentResolver(), Settings.Global.ADD_USERS_WHEN_LOCKED, 0) == 1;
         mCanAddGuest = !mIsGuest && !mDisallowAddUser && canAddUsersWhenLocked;
+
+        UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
+        mDisallowSwitchUser = userManager.hasUserRestriction(UserManager.DISALLOW_USER_SWITCH);
     }
 
     public boolean isAdmin() {
@@ -109,6 +113,7 @@
                 ", mCanAddGuest=" + mCanAddGuest +
                 ", mDisallowAddUser=" + mDisallowAddUser +
                 ", mEnforcedAdmin=" + mEnforcedAdmin +
+                ", mDisallowSwitchUser=" + mDisallowSwitchUser +
                 '}';
     }
 }
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index fcb8aef..f6bacd8 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -309,7 +309,7 @@
     public void onDestroy() {
         super.onDestroy();
 
-        if (!mUserCaps.mEnabled) {
+        if (mUserCaps == null || !mUserCaps.mEnabled) {
             return;
         }
 
@@ -757,8 +757,12 @@
                     synchronized (mUserLock) {
                         if (userType == USER_TYPE_USER) {
                             mHandler.sendEmptyMessage(MESSAGE_UPDATE_LIST);
-                            mHandler.sendMessage(mHandler.obtainMessage(
-                                    MESSAGE_SETUP_USER, user.id, user.serialNumber));
+                            // Skip setting up user which results in user switching when the
+                            // restriction is set.
+                            if (!mUserCaps.mDisallowSwitchUser) {
+                                mHandler.sendMessage(mHandler.obtainMessage(
+                                        MESSAGE_SETUP_USER, user.id, user.serialNumber));
+                            }
                         } else {
                             mHandler.sendMessage(mHandler.obtainMessage(
                                     MESSAGE_CONFIG_USER, user.id, user.serialNumber));
@@ -845,8 +849,12 @@
                 } else {
                     pref.setSummary(R.string.user_summary_not_set_up);
                 }
-                pref.setOnPreferenceClickListener(this);
-                pref.setSelectable(true);
+                // Disallow setting up user which results in user switching when the restriction is
+                // set.
+                if (!mUserCaps.mDisallowSwitchUser) {
+                    pref.setOnPreferenceClickListener(this);
+                    pref.setSelectable(true);
+                }
             } else if (user.isRestricted()) {
                 pref.setSummary(R.string.user_summary_restricted_profile);
             }
@@ -885,8 +893,13 @@
             pref.setTitle(R.string.user_guest);
             pref.setIcon(getEncircledDefaultIcon());
             userPreferences.add(pref);
-            pref.setDisabledByAdmin(
-                    mUserCaps.mDisallowAddUser ? mUserCaps.mEnforcedAdmin : null);
+            if (mUserCaps.mDisallowAddUser) {
+                pref.setDisabledByAdmin(mUserCaps.mEnforcedAdmin);
+            } else if (mUserCaps.mDisallowSwitchUser) {
+                pref.setDisabledByAdmin(RestrictedLockUtils.getDeviceOwner(context));
+            } else {
+                pref.setDisabledByAdmin(null);
+            }
             int finalGuestId = guestId;
             pref.setOnPreferenceClickListener(preference -> {
                 int id = finalGuestId;
diff --git a/src/com/android/settings/widget/HighlightablePreferenceGroupAdapter.java b/src/com/android/settings/widget/HighlightablePreferenceGroupAdapter.java
new file mode 100644
index 0000000..e1999ef
--- /dev/null
+++ b/src/com/android/settings/widget/HighlightablePreferenceGroupAdapter.java
@@ -0,0 +1,102 @@
+/*
+ * 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.widget;
+
+import android.content.Context;
+import android.support.annotation.VisibleForTesting;
+import android.support.v7.preference.PreferenceGroup;
+import android.support.v7.preference.PreferenceGroupAdapter;
+import android.support.v7.preference.PreferenceViewHolder;
+import android.support.v7.widget.RecyclerView;
+import android.text.TextUtils;
+import android.util.TypedValue;
+import android.view.View;
+
+import com.android.settings.R;
+
+public class HighlightablePreferenceGroupAdapter extends PreferenceGroupAdapter {
+
+    @VisibleForTesting
+    static final long DELAY_HIGHLIGHT_DURATION_MILLIS = 600L;
+    private static final long HIGHLIGHT_DURATION = 5000L;
+
+    private final int mHighlightColor;
+    private final int mNormalBackgroundRes;
+    private final String mHighlightKey;
+
+    private boolean mHighlightRequested;
+    private int mHighlightPosition = RecyclerView.NO_POSITION;
+
+    public HighlightablePreferenceGroupAdapter(PreferenceGroup preferenceGroup, String key,
+            boolean highlightRequested) {
+        super(preferenceGroup);
+        mHighlightKey = key;
+        mHighlightRequested = highlightRequested;
+        final Context context = preferenceGroup.getContext();
+        final TypedValue outValue = new TypedValue();
+        context.getTheme().resolveAttribute(android.R.attr.selectableItemBackground,
+                outValue, true /* resolveRefs */);
+        mNormalBackgroundRes = outValue.resourceId;
+        mHighlightColor = context.getColor(R.color.preference_highligh_color);
+    }
+
+    @Override
+    public void onBindViewHolder(PreferenceViewHolder holder, int position) {
+        super.onBindViewHolder(holder, position);
+        updateBackground(holder, position);
+    }
+
+    @VisibleForTesting
+    void updateBackground(PreferenceViewHolder holder, int position) {
+        View v = holder.itemView;
+        if (position == mHighlightPosition) {
+            v.setBackgroundColor(mHighlightColor);
+            v.setTag(R.id.preference_highlighted, true);
+            v.postDelayed(() -> {
+                mHighlightPosition = RecyclerView.NO_POSITION;
+                removeHighlightBackground(v);
+            }, HIGHLIGHT_DURATION);
+        } else if (Boolean.TRUE.equals(v.getTag(R.id.preference_highlighted))) {
+            removeHighlightBackground(v);
+        }
+    }
+
+    public void requestHighlight(View root, RecyclerView recyclerView) {
+        if (mHighlightRequested || recyclerView == null || TextUtils.isEmpty(mHighlightKey)) {
+            return;
+        }
+        root.postDelayed(() -> {
+            final int position = getPreferenceAdapterPosition(mHighlightKey);
+            if (position < 0) {
+                return;
+            }
+            mHighlightRequested = true;
+            recyclerView.getLayoutManager().scrollToPosition(position);
+            mHighlightPosition = position;
+            notifyItemChanged(position);
+        }, DELAY_HIGHLIGHT_DURATION_MILLIS);
+    }
+
+    public boolean isHighlightRequested() {
+        return mHighlightRequested;
+    }
+
+    private void removeHighlightBackground(View v) {
+        v.setBackgroundResource(mNormalBackgroundRes);
+        v.setTag(R.id.preference_highlighted, false);
+    }
+}
diff --git a/tests/robotests/res/values-mcc999/config.xml b/tests/robotests/res/values-mcc999/config.xml
index e755f27..137a089 100644
--- a/tests/robotests/res/values-mcc999/config.xml
+++ b/tests/robotests/res/values-mcc999/config.xml
@@ -57,4 +57,7 @@
     <bool name="config_show_color_inversion_preference">false</bool>
     <bool name="config_show_system_update_settings">false</bool>
     <bool name="config_wifi_support_connected_mac_randomization">false</bool>
+    <bool name="config_show_device_model">false</bool>
+    <bool name="config_show_wifi_ip_address">false</bool>
+    <bool name="config_show_wifi_mac_address">false</bool>
 </resources>
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java
index 87b82ad..fabf9ae 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java
@@ -19,6 +19,7 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.nullable;
+import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
@@ -191,6 +192,22 @@
     }
 
     @Test
+    public void onActivityResult_packageUninstalled_shouldFinishAndRemoveTask() {
+        doReturn(false).when(mFragment).refreshUi();
+
+        mFragment.onActivityResult(mFragment.REQUEST_UNINSTALL, 0, mock(Intent.class));
+
+        verify(mActivity).finishAndRemoveTask();
+    }
+
+    @Test
+    public void getPreferenceControllers_noPackageInfo_shouldReturnNull() {
+        doNothing().when(mFragment).retrieveAppEntry();
+
+        assertThat(mFragment.getPreferenceControllers(mShadowContext)).isNull();
+    }
+
+    @Test
     public void getNumberOfUserWithPackageInstalled_twoUsersInstalled_shouldReturnTwo()
             throws PackageManager.NameNotFoundException{
         final String packageName = "Package1";
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java
index ebf3dc7..825aee9 100644
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java
@@ -215,11 +215,9 @@
     }
 
     @Test
-    public void onBindViewHolder_differentPackage_shouldNotTintIcon()
-        throws PendingIntent.CanceledException {
+    public void onBindViewHolder_iconNotTintable_shouldNotTintIcon()
+            throws PendingIntent.CanceledException {
         final Icon icon = mock(Icon.class);
-        when(icon.getResPackage()).thenReturn("pkg1");
-        when(mActivity.getPackageName()).thenReturn("pkg2");
         final Suggestion suggestion = new Suggestion.Builder("pkg1")
             .setPendingIntent(mock(PendingIntent.class))
             .setIcon(icon)
@@ -243,15 +241,14 @@
     }
 
     @Test
-    public void onBindViewHolder_samePackage_shouldTintIcon()
-        throws PendingIntent.CanceledException {
+    public void onBindViewHolder_iconTintable_shouldTintIcon()
+            throws PendingIntent.CanceledException {
         final Icon icon = mock(Icon.class);
-        final String packageName = "pkg1";
-        when(icon.getResPackage()).thenReturn(packageName);
-        when(mActivity.getPackageName()).thenReturn(packageName);
-        final Suggestion suggestion = new Suggestion.Builder(packageName)
+        final int FLAG_ICON_TINTABLE = 1 << 1;
+        final Suggestion suggestion = new Suggestion.Builder("pkg1")
             .setPendingIntent(mock(PendingIntent.class))
             .setIcon(icon)
+            .setFlags(FLAG_ICON_TINTABLE)
             .build();
         final List<Suggestion> suggestions = new ArrayList<>();
         suggestions.add(suggestion);
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/DeviceModelPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/DeviceModelPreferenceControllerTest.java
index 6a5c7fa..47bcf1c 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/DeviceModelPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/DeviceModelPreferenceControllerTest.java
@@ -69,11 +69,17 @@
     }
 
     @Test
-    public void isAlwaysAvailable() {
+    public void isAvailable_returnTrueIfVisible() {
         assertThat(mController.isAvailable()).isTrue();
     }
 
     @Test
+    @Config(qualifiers = "mcc999")
+    public void isAvailable_returnFalseIfNotVisible() {
+        assertThat(mController.isAvailable()).isFalse();
+    }
+
+    @Test
     public void displayPref_shouldSetSummary() {
         mController.displayPreference(mPreferenceScreen);
 
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java
index f30425b..0b83359 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/PhoneNumberPreferenceControllerTest.java
@@ -16,6 +16,9 @@
 
 package com.android.settings.deviceinfo;
 
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertTrue;
+
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.spy;
@@ -74,6 +77,20 @@
     }
 
     @Test
+    public void isAvailable_shouldBeTrueIfCallCapable() {
+        when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
+
+        assertTrue(mController.isAvailable());
+    }
+
+    @Test
+    public void isAvailable_shouldBeFalseIfNotCallCapable() {
+        when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
+
+        assertFalse(mController.isAvailable());
+    }
+
+    @Test
     public void displayPreference_multiSim_shouldAddSecondPreference() {
         when(mTelephonyManager.getPhoneCount()).thenReturn(2);
 
diff --git a/tests/robotests/src/com/android/settings/location/LocationEnablerTest.java b/tests/robotests/src/com/android/settings/location/LocationEnablerTest.java
index 1bae729..ca42b3a 100644
--- a/tests/robotests/src/com/android/settings/location/LocationEnablerTest.java
+++ b/tests/robotests/src/com/android/settings/location/LocationEnablerTest.java
@@ -252,7 +252,7 @@
         enforcingUsers.add(new UserManager.EnforcingUser(userId,
                 UserManager.RESTRICTION_SOURCE_PROFILE_OWNER));
         when(mUserManager.getUserRestrictionSources(
-                UserManager.DISALLOW_CONFIG_LOCATION_MODE, UserHandle.of(userId)))
+                UserManager.DISALLOW_CONFIG_LOCATION, UserHandle.of(userId)))
                 .thenReturn(enforcingUsers);
 
         assertThat(mEnabler.getShareLocationEnforcedAdmin(userId) != null).isTrue();
diff --git a/tests/robotests/src/com/android/settings/users/UserCapabilitiesTest.java b/tests/robotests/src/com/android/settings/users/UserCapabilitiesTest.java
new file mode 100644
index 0000000..4228ca0
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/users/UserCapabilitiesTest.java
@@ -0,0 +1,70 @@
+/*
+ * 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.users;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.os.UserManager;
+
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class UserCapabilitiesTest {
+
+    @Mock
+    private Context mContext;
+    @Mock
+    private UserManager mUserManager;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
+    }
+
+    @Test
+    public void disallowUserSwitchWhenRestrictionIsSet() {
+        when(mUserManager.hasUserRestriction(UserManager.DISALLOW_USER_SWITCH)).thenReturn(true);
+
+        UserCapabilities userCapabilities = UserCapabilities.create(mContext);
+        userCapabilities.updateAddUserCapabilities(mContext);
+
+        assertThat(userCapabilities.mDisallowSwitchUser).isTrue();
+    }
+
+    @Test
+    public void allowUserSwitchWhenRestrictionIsNotSet() {
+        when(mUserManager.hasUserRestriction(UserManager.DISALLOW_USER_SWITCH)).thenReturn(false);
+
+        UserCapabilities userCapabilities = UserCapabilities.create(mContext);
+        userCapabilities.updateAddUserCapabilities(mContext);
+
+        assertThat(userCapabilities.mDisallowSwitchUser).isFalse();
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/widget/HighlightablePreferenceGroupAdapterTest.java b/tests/robotests/src/com/android/settings/widget/HighlightablePreferenceGroupAdapterTest.java
new file mode 100644
index 0000000..e2fb6c1
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/widget/HighlightablePreferenceGroupAdapterTest.java
@@ -0,0 +1,127 @@
+/*
+ * 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.widget;
+
+
+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.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.graphics.drawable.ColorDrawable;
+import android.support.v7.preference.PreferenceCategory;
+import android.support.v7.preference.PreferenceViewHolder;
+import android.support.v7.widget.RecyclerView;
+import android.view.View;
+
+import com.android.settings.R;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class HighlightablePreferenceGroupAdapterTest {
+
+    private static final String TEST_KEY = "key";
+
+    @Mock
+    private View mRoot;
+    @Mock
+    private PreferenceCategory mPreferenceCatetory;
+    private Context mContext;
+    private HighlightablePreferenceGroupAdapter mAdapter;
+    private PreferenceViewHolder mViewHolder;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mContext = RuntimeEnvironment.application;
+        when(mPreferenceCatetory.getContext()).thenReturn(mContext);
+        mAdapter = new HighlightablePreferenceGroupAdapter(mPreferenceCatetory, TEST_KEY,
+                false /* highlighted*/);
+        mViewHolder = PreferenceViewHolder.createInstanceForTests(
+                View.inflate(mContext, R.layout.app_preference_item, null));
+    }
+
+    @Test
+    public void requestHighlight_hasKey_notHighlightedBefore_shouldRequest() {
+        mAdapter.requestHighlight(mRoot, mock(RecyclerView.class));
+
+        verify(mRoot).postDelayed(any(),
+                eq(HighlightablePreferenceGroupAdapter.DELAY_HIGHLIGHT_DURATION_MILLIS));
+    }
+
+    @Test
+    public void requestHighlight_noKey_highlightedBefore_noRecyclerView_shouldNotRequest() {
+        ReflectionHelpers.setField(mAdapter, "mHighlightKey", null);
+        ReflectionHelpers.setField(mAdapter, "mHighlightRequested", false);
+        mAdapter.requestHighlight(mRoot, mock(RecyclerView.class));
+
+        ReflectionHelpers.setField(mAdapter, "mHighlightKey", TEST_KEY);
+        ReflectionHelpers.setField(mAdapter, "mHighlightRequested", true);
+        mAdapter.requestHighlight(mRoot, mock(RecyclerView.class));
+
+        ReflectionHelpers.setField(mAdapter, "mHighlightKey", TEST_KEY);
+        ReflectionHelpers.setField(mAdapter, "mHighlightRequested", false);
+        mAdapter.requestHighlight(mRoot, null /* recyclerView */);
+
+        verifyZeroInteractions(mRoot);
+    }
+
+    @Test
+    public void updateBackground_notHighlightedRow_shouldNotSetHighlightedTag() {
+        ReflectionHelpers.setField(mAdapter, "mHighlightPosition", 10);
+
+        mAdapter.updateBackground(mViewHolder, 0);
+
+        assertThat(mViewHolder.itemView.getTag(R.id.preference_highlighted)).isNull();
+    }
+
+    @Test
+    public void updateBackground_highlight_shouldChangeBackgroundAndSetHighlightedTag() {
+        ReflectionHelpers.setField(mAdapter, "mHighlightPosition", 10);
+
+        mAdapter.updateBackground(mViewHolder, 10);
+        assertThat(mViewHolder.itemView.getBackground()).isInstanceOf(ColorDrawable.class);
+        assertThat(mViewHolder.itemView.getTag(R.id.preference_highlighted)).isEqualTo(true);
+    }
+
+    @Test
+    public void updateBackground_reuseHightlightedRowForNormalRow_shouldResetBackgroundAndTag() {
+        ReflectionHelpers.setField(mAdapter, "mHighlightPosition", 10);
+        mViewHolder.itemView.setTag(R.id.preference_highlighted, true);
+
+        mAdapter.updateBackground(mViewHolder, 0);
+
+        assertThat(mViewHolder.itemView.getBackground()).isNotInstanceOf(ColorDrawable.class);
+        assertThat(mViewHolder.itemView.getTag(R.id.preference_highlighted)).isEqualTo(false);
+    }
+
+}
diff --git a/tests/unit/src/com/android/settings/SettingsPreferenceFragmentTest.java b/tests/unit/src/com/android/settings/SettingsPreferenceFragmentTest.java
deleted file mode 100644
index 0e12e79..0000000
--- a/tests/unit/src/com/android/settings/SettingsPreferenceFragmentTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package com.android.settings;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.app.Instrumentation;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.filters.SmallTest;
-import android.support.test.runner.AndroidJUnit4;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceGroupAdapter;
-
-import com.android.settings.accessibility.AccessibilitySettings;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(AndroidJUnit4.class)
-@SmallTest
-public class SettingsPreferenceFragmentTest {
-
-    private Instrumentation mInstrumentation;
-    private Context mTargetContext;
-
-    @Before
-    public void setUp() throws Exception {
-        mInstrumentation = InstrumentationRegistry.getInstrumentation();
-        mTargetContext = mInstrumentation.getTargetContext();
-    }
-
-    @Test
-    public void testHighlightCaptions() throws InterruptedException {
-        final String prefKey = "captioning_preference_screen";
-        Bundle args = new Bundle();
-        args.putString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, prefKey);
-
-        Intent intent = new Intent(Intent.ACTION_MAIN);
-        intent.setClass(mTargetContext, SubSettings.class);
-        intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT,
-                "com.android.settings.accessibility.AccessibilitySettings");
-        intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS, args);
-
-        SettingsActivity activity  = (SettingsActivity) mInstrumentation.startActivitySync(intent);
-        AccessibilitySettings fragment = (AccessibilitySettings)
-                activity.getFragmentManager().getFragments().get(0);
-
-        // Allow time for highlight from post-delay.
-        Thread.sleep(SettingsPreferenceFragment.DELAY_HIGHLIGHT_DURATION_MILLIS);
-        if (!fragment.mPreferenceHighlighted) {
-            Thread.sleep(SettingsPreferenceFragment.DELAY_HIGHLIGHT_DURATION_MILLIS);
-        }
-
-        int prefPosition = -1;
-        PreferenceGroupAdapter adapter = (PreferenceGroupAdapter)
-                fragment.getListView().getAdapter();
-        for (int n = 0, count = adapter.getItemCount(); n < count; n++) {
-            final Preference preference = adapter.getItem(n);
-            final String preferenceKey = preference.getKey();
-            if (preferenceKey.equals(prefKey)) {
-                prefPosition = n;
-                break;
-            }
-        }
-
-        assertThat(fragment.mAdapter.initialHighlightedPosition).isEqualTo(prefPosition);
-    }
-}