Merge "Fixed storage calculation when SD card is adopted as internal storage."
diff --git a/res/layout/condition_card.xml b/res/layout/condition_card.xml
index c911f03..c9d4829 100644
--- a/res/layout/condition_card.xml
+++ b/res/layout/condition_card.xml
@@ -25,7 +25,6 @@
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:orientation="vertical"
-        android:paddingStart="16dp"
         android:background="?android:attr/colorAccent"
         android:elevation="2dp"
         android:clickable="true"
@@ -35,6 +34,7 @@
             android:id="@+id/collapsed_group"
             android:layout_width="match_parent"
             android:layout_height="56dp"
+            android:background="?android:attr/selectableItemBackground"
             android:orientation="horizontal"
             android:gravity="center">
 
@@ -42,6 +42,7 @@
                 android:id="@android:id/icon"
                 android:layout_width="24dp"
                 android:layout_height="wrap_content"
+                android:layout_marginStart="16dp"
                 android:layout_marginEnd="32dp"
                 android:tint="?android:attr/textColorPrimaryInverse" />
 
@@ -58,10 +59,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="match_parent"
                 android:padding="16dp"
-                android:tint="?android:attr/textColorPrimaryInverse"
-                android:clickable="true"
-                android:focusable="true"
-                android:background="?android:attr/selectableItemBackground" />
+                android:tint="?android:attr/textColorPrimaryInverse"/>
 
         </LinearLayout>
 
@@ -69,7 +67,7 @@
             android:id="@+id/detail_group"
             android:layout_width="match_parent"
             android:layout_height="0dp"
-            android:paddingStart="56dp"
+            android:paddingStart="72dp"
             android:visibility="gone"
             android:orientation="vertical">
 
diff --git a/res/layout/support_offline_escalation_options.xml b/res/layout/support_offline_escalation_options.xml
index 6a54fba..08c52aa 100644
--- a/res/layout/support_offline_escalation_options.xml
+++ b/res/layout/support_offline_escalation_options.xml
@@ -41,6 +41,7 @@
         android:layout_height="wrap_content"
         android:orientation="horizontal">
         <TextView
+            android:id="@+id/support_text"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:paddingEnd="8dp"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 247dcc0..b4abee7 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1503,6 +1503,10 @@
     <string name="nfc_quick_toggle_summary" product="tablet">Allow data exchange when the tablet touches another device</string>
     <!-- Description of NFC in the 1st level settings screen, for a phone. [CHAR LIMIT=NONE] -->
     <string name="nfc_quick_toggle_summary" product="default">Allow data exchange when the phone touches another device</string>
+    <!-- Dialog title for NFC disclaimr [CHAR_LIMIT=40]-->
+    <string name="nfc_disclaimer_title">Turn on NFC</string>
+    <!-- Dialog title for NFC disclaimr [CHAR_LIMIT=NONE]-->
+    <string name="nfc_disclaimer_content">NFC exchanges data between this device and other nearby devices or targets, such as payment terminals, access readers, and interactive ads or tags.</string>
 
     <!-- Used to enter the Android Beam sharing preferences screen. This phrase is a trademark. [CHAR LIMIT=32] -->
     <string name="android_beam_settings_title">Android Beam</string>
@@ -6958,6 +6962,11 @@
     <!-- Summary for the "screenshot" preference to determine whether assist can access the screenshot of your screen [CHAR LIMIT=NONE] -->
     <string name="assist_access_screenshot_summary">Allow the assist app to access an image of the screen</string>
 
+    <!-- Title for the "flash" preference to determine whether a flash is shown on screen when an assistant accesses the contents of the screeen. [CHAR LIMIT=40] -->
+    <string name="assist_flash_title">Flash screen</string>
+
+    <!-- Summary for the "flash" preference to determine whether a flash is shown on screen when an assistant accesses the contents of the screeen. [CHAR LIMIT=NONE] -->
+    <string name="assist_flash_summary">Flash edges of screen when assist app accesses text from screen or screenshot</string>
 
     <!-- Footer text in the manage assist screen. [CHAR LIMIT=NONE] -->
     <string name="assist_footer">Assist apps can help you based on information from the screen you\u2019re viewing. Some apps support both launcher and voice input services to give you integrated assistance.</string>
diff --git a/res/xml/manage_assist.xml b/res/xml/manage_assist.xml
index 6984f88..7d4928d 100644
--- a/res/xml/manage_assist.xml
+++ b/res/xml/manage_assist.xml
@@ -36,6 +36,12 @@
         android:title="@string/assist_access_screenshot_title"
         android:summary="@string/assist_access_screenshot_summary"/>
 
+    <SwitchPreference
+            android:key="flash"
+            android:title="@string/assist_flash_title"
+            android:summary="@string/assist_flash_summary"
+    />
+
     <com.android.settings.voice.VoiceInputListPreference
             android:key="voice_input_settings"
             android:title="@string/voice_input_settings_title"
diff --git a/src/com/android/settings/applications/DefaultPhonePreference.java b/src/com/android/settings/applications/DefaultPhonePreference.java
index 5689c83..e151274 100644
--- a/src/com/android/settings/applications/DefaultPhonePreference.java
+++ b/src/com/android/settings/applications/DefaultPhonePreference.java
@@ -82,9 +82,13 @@
             return false;
         }
 
-        final UserManager um =
-                (UserManager) context.getSystemService(Context.USER_SERVICE);
-        return !um.hasUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS);
+        final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
+        final boolean hasUserRestriction =
+                um.hasUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS);
+        final CharSequence[] entries = getEntries();
+        return !hasUserRestriction
+                && entries != null
+                && entries.length > 0;
     }
 
     public static boolean hasPhonePreference(String pkg, Context context) {
diff --git a/src/com/android/settings/applications/ManageAssist.java b/src/com/android/settings/applications/ManageAssist.java
index 02875b6..9947aa2 100644
--- a/src/com/android/settings/applications/ManageAssist.java
+++ b/src/com/android/settings/applications/ManageAssist.java
@@ -24,6 +24,8 @@
 import android.provider.Settings;
 import android.support.v14.preference.SwitchPreference;
 import android.support.v7.preference.Preference;
+
+import com.android.internal.app.AssistUtils;
 import com.android.internal.logging.MetricsProto.MetricsEvent;
 import com.android.settings.R;
 import com.android.settings.SettingsPreferenceFragment;
@@ -39,10 +41,12 @@
     private static final String KEY_CONTEXT = "context";
     private static final String KEY_SCREENSHOT = "screenshot";
     private static final String KEY_VOICE_INPUT = "voice_input_settings";
+    private static final String KEY_FLASH = "flash";
 
     private DefaultAssistPreference mDefaultAssitPref;
     private SwitchPreference mContextPref;
     private SwitchPreference mScreenshotPref;
+    private SwitchPreference mFlashPref;
     private VoiceInputListPreference mVoiceInputPref;
     private Handler mHandler = new Handler();
 
@@ -62,6 +66,9 @@
         mScreenshotPref = (SwitchPreference) findPreference(KEY_SCREENSHOT);
         mScreenshotPref.setOnPreferenceChangeListener(this);
 
+        mFlashPref = (SwitchPreference) findPreference(KEY_FLASH);
+        mFlashPref.setOnPreferenceChangeListener(this);
+
         mVoiceInputPref = (VoiceInputListPreference) findPreference(KEY_VOICE_INPUT);
         updateUi();
     }
@@ -76,7 +83,10 @@
         if (preference == mContextPref) {
             Settings.Secure.putInt(getContentResolver(), Settings.Secure.ASSIST_STRUCTURE_ENABLED,
                     (boolean) newValue ? 1 : 0);
-            postGuardScreenshotPref();
+            mHandler.post(() -> {
+                guardScreenshotPref();
+                guardFlashPref();
+            });
             return true;
         }
         if (preference == mScreenshotPref) {
@@ -84,6 +94,11 @@
                     (boolean) newValue ? 1 : 0);
             return true;
         }
+        if (preference == mFlashPref) {
+            Settings.Secure.putInt(getContentResolver(), Settings.Secure.ASSIST_DISCLOSURE_ENABLED,
+                    (boolean) newValue ? 1 : 0);
+            return true;
+        }
         if (preference == mDefaultAssitPref) {
             String newAssitPackage = (String)newValue;
             if (newAssitPackage == null ||
@@ -101,15 +116,6 @@
         return false;
     }
 
-    private void postGuardScreenshotPref() {
-        mHandler.post(new Runnable() {
-            @Override
-            public void run() {
-                guardScreenshotPref();
-            }
-        });
-    }
-
     private void guardScreenshotPref() {
         boolean isChecked = mContextPref.isChecked();
         boolean screenshotPrefWasSet = Settings.Secure.getInt(
@@ -118,6 +124,17 @@
         mScreenshotPref.setChecked(isChecked && screenshotPrefWasSet);
     }
 
+    private void guardFlashPref() {
+        ComponentName assistant = mDefaultAssitPref.getCurrentAssist();
+
+        boolean isContextChecked = mContextPref.isChecked();
+        boolean willShowFlash = AssistUtils.shouldDisclose(getContext(), assistant);
+        boolean isSystemAssistant = AssistUtils.isPreinstalledAssistant(getContext(), assistant);
+
+        mFlashPref.setEnabled(isContextChecked && isSystemAssistant);
+        mFlashPref.setChecked(willShowFlash);
+    }
+
     private void updateUi() {
         mDefaultAssitPref.refreshAssistApps();
         mVoiceInputPref.refreshVoiceInputs();
@@ -130,6 +147,13 @@
         } else {
             getPreferenceScreen().removePreference(mContextPref);
             getPreferenceScreen().removePreference(mScreenshotPref);
+            getPreferenceScreen().removePreference(mFlashPref);
+        }
+
+        if (hasAssistant && AssistUtils.allowDisablingAssistDisclosure(getContext())) {
+            getPreferenceScreen().addPreference(mFlashPref);
+        } else {
+            getPreferenceScreen().removePreference(mFlashPref);
         }
 
         if (isCurrentAssistVoiceService()) {
@@ -140,6 +164,7 @@
         }
 
         guardScreenshotPref();
+        guardFlashPref();
     }
 
     private boolean isCurrentAssistVoiceService() {
diff --git a/src/com/android/settings/applications/ProcStatsEntry.java b/src/com/android/settings/applications/ProcStatsEntry.java
index 36d397e..90ef5d7 100644
--- a/src/com/android/settings/applications/ProcStatsEntry.java
+++ b/src/com/android/settings/applications/ProcStatsEntry.java
@@ -20,12 +20,13 @@
 import android.content.pm.PackageManager;
 import android.os.Parcel;
 import android.os.Parcelable;
+import android.text.TextUtils;
 import android.util.ArrayMap;
 import android.util.Log;
 import android.util.SparseArray;
 
-import com.android.internal.app.procstats.ProcessStats;
 import com.android.internal.app.procstats.ProcessState;
+import com.android.internal.app.procstats.ProcessStats;
 import com.android.internal.app.procstats.ServiceState;
 
 import java.util.ArrayList;
@@ -33,6 +34,7 @@
 import java.util.Comparator;
 
 public final class ProcStatsEntry implements Parcelable {
+
     private static final String TAG = "ProcStatsEntry";
     private static boolean DEBUG = ProcessStatsUi.DEBUG;
 
@@ -40,7 +42,7 @@
     final int mUid;
     final String mName;
     public CharSequence mLabel;
-    final ArrayList<String> mPackages = new ArrayList<String>();
+    final ArrayList<String> mPackages = new ArrayList<>();
     final long mBgDuration;
     final long mAvgBgMem;
     final long mMaxBgMem;
@@ -52,7 +54,7 @@
 
     String mBestTargetPackage;
 
-    ArrayMap<String, ArrayList<Service>> mServices = new ArrayMap<String, ArrayList<Service>>(1);
+    ArrayMap<String, ArrayList<Service>> mServices = new ArrayMap<>(1);
 
     public ProcStatsEntry(ProcessState proc, String packageName,
             ProcessStats.ProcessDataCollection tmpBgTotals,
@@ -249,6 +251,10 @@
                             + " not as good as last " + bestRunTime);
                 }
             }
+            // Final fallback, just pick the first subProc.
+            if (TextUtils.isEmpty(mBestTargetPackage)) {
+                mBestTargetPackage = subProcs.get(0).mPackage;
+            }
         } else if (subProcs.size() == 1) {
             mBestTargetPackage = subProcs.get(0).mPackage;
         }
diff --git a/src/com/android/settings/dashboard/SupportItemAdapter.java b/src/com/android/settings/dashboard/SupportItemAdapter.java
index 4ee28c6..9ef69883 100644
--- a/src/com/android/settings/dashboard/SupportItemAdapter.java
+++ b/src/com/android/settings/dashboard/SupportItemAdapter.java
@@ -20,6 +20,7 @@
 import android.annotation.LayoutRes;
 import android.annotation.StringRes;
 import android.app.Activity;
+import android.app.ActivityManager;
 import android.app.DialogFragment;
 import android.content.Context;
 import android.content.Intent;
@@ -372,6 +373,13 @@
         } else {
             holder.text2View.setVisibility(View.GONE);
         }
+
+        if (ActivityManager.isUserAMonkey()) {
+            holder.text1View.setVisibility(View.GONE);
+            holder.text2View.setVisibility(View.GONE);
+            spinner.setVisibility(View.GONE);
+            holder.itemView.findViewById(R.id.support_text).setVisibility(View.GONE);
+        }
     }
 
     private void bindSignInPromoTile(ViewHolder holder, EscalationData data) {
@@ -450,9 +458,15 @@
                         final SupportPhone phone = mSupportFeatureProvider
                                 .getSupportPhones(mSelectedCountry, true /* isTollFree */);
                         if (phone != null) {
-                            MetricsLogger.action(mActivity,
-                                    MetricsProto.MetricsEvent.ACTION_SUPPORT_DAIL_TOLLFREE);
-                            mActivity.startActivity(phone.getDialIntent());
+                            final Intent intent = phone.getDialIntent();
+                            final boolean canDial = !mActivity.getPackageManager()
+                                    .queryIntentActivities(intent, 0)
+                                    .isEmpty();
+                            if (canDial) {
+                                MetricsLogger.action(mActivity,
+                                        MetricsProto.MetricsEvent.ACTION_SUPPORT_DAIL_TOLLFREE);
+                                mActivity.startActivity(intent);
+                            }
                         }
                         break;
                     }
diff --git a/src/com/android/settings/dashboard/conditional/ConditionAdapterUtils.java b/src/com/android/settings/dashboard/conditional/ConditionAdapterUtils.java
index 51fd132..a16de50 100644
--- a/src/com/android/settings/dashboard/conditional/ConditionAdapterUtils.java
+++ b/src/com/android/settings/dashboard/conditional/ConditionAdapterUtils.java
@@ -68,12 +68,13 @@
         card.setOnClickListener(onClickListener);
         view.icon.setImageIcon(condition.getIcon());
         view.title.setText(condition.getTitle());
-        ImageView expand = (ImageView) view.itemView.findViewById(R.id.expand_indicator);
-        expand.setTag(condition);
+        final View collapsedGroup = view.itemView.findViewById(R.id.collapsed_group);
+        collapsedGroup.setTag(condition);
+        final ImageView expand = (ImageView) view.itemView.findViewById(R.id.expand_indicator);
         expand.setImageResource(isExpanded ? R.drawable.ic_expand_less : R.drawable.ic_expand_more);
         expand.setContentDescription(expand.getContext().getString(isExpanded
                 ? R.string.condition_expand_hide : R.string.condition_expand_show));
-        expand.setOnClickListener(onExpandListener);
+        collapsedGroup.setOnClickListener(onExpandListener);
 
         View detailGroup = view.itemView.findViewById(R.id.detail_group);
         CharSequence[] actions = condition.getActions();
diff --git a/src/com/android/settings/datausage/BillingCycleSettings.java b/src/com/android/settings/datausage/BillingCycleSettings.java
index 7e659c3..a23f811 100644
--- a/src/com/android/settings/datausage/BillingCycleSettings.java
+++ b/src/com/android/settings/datausage/BillingCycleSettings.java
@@ -197,10 +197,16 @@
             final long limitDisabled = isLimit ? LIMIT_DISABLED : WARNING_DISABLED;
 
             if (bytes > 1.5f * GB_IN_BYTES) {
-                bytesPicker.setText(formatText(bytes / (float) GB_IN_BYTES));
+                final String bytesText = formatText(bytes / (float) GB_IN_BYTES);
+                bytesPicker.setText(bytesText);
+                bytesPicker.setSelection(0, bytesText.length());
+
                 type.setSelection(1);
             } else {
-                bytesPicker.setText(formatText(bytes / (float) MB_IN_BYTES));
+                final String bytesText = formatText(bytes / (float) MB_IN_BYTES);
+                bytesPicker.setText(bytesText);
+                bytesPicker.setSelection(0, bytesText.length());
+
                 type.setSelection(0);
             }
         }
diff --git a/src/com/android/settings/support/SupportPhoneDialogFragment.java b/src/com/android/settings/support/SupportPhoneDialogFragment.java
index 77eb225..4dde547 100644
--- a/src/com/android/settings/support/SupportPhoneDialogFragment.java
+++ b/src/com/android/settings/support/SupportPhoneDialogFragment.java
@@ -15,9 +15,11 @@
  */
 package com.android.settings.support;
 
+import android.app.Activity;
 import android.app.AlertDialog;
 import android.app.Dialog;
 import android.app.DialogFragment;
+import android.content.Intent;
 import android.os.Bundle;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -68,9 +70,16 @@
     @Override
     public void onClick(View v) {
         final SupportPhone phone = getArguments().getParcelable(EXTRA_PHONE);
-        MetricsLogger.action(getActivity(),
-                MetricsProto.MetricsEvent.ACTION_SUPPORT_DIAL_TOLLED);
-        getActivity().startActivity(phone.getDialIntent());
+        final Activity activity = getActivity();
+        final Intent intent = phone.getDialIntent();
+        final boolean canDial = !activity.getPackageManager()
+                .queryIntentActivities(intent, 0)
+                .isEmpty();
+        if (canDial) {
+            MetricsLogger.action(getActivity(),
+                    MetricsProto.MetricsEvent.ACTION_SUPPORT_DIAL_TOLLED);
+            getActivity().startActivity(intent);
+        }
         dismiss();
     }
 }
diff --git a/tests/app/Android.mk b/tests/app/Android.mk
index bb31539..71bb587 100644
--- a/tests/app/Android.mk
+++ b/tests/app/Android.mk
@@ -7,6 +7,11 @@
 
 LOCAL_JAVA_LIBRARIES := android.test.runner bouncycastle
 
+LOCAL_STATIC_JAVA_LIBRARIES := \
+  android-support-test \
+  mockito-target \
+  espresso-core
+
 # Include all test java files.
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/app/AndroidManifest.xml b/tests/app/AndroidManifest.xml
index 2ef96cf..d765126 100644
--- a/tests/app/AndroidManifest.xml
+++ b/tests/app/AndroidManifest.xml
@@ -51,9 +51,9 @@
         </activity>
     </application>
 
-    <instrumentation android:name="android.test.InstrumentationTestRunner"
-        android:targetPackage="com.android.settings"
-        android:label="Settings App Tests">
+    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+      android:targetPackage="com.android.settings"
+      android:label="Settings Test Cases">
     </instrumentation>
 
     <instrumentation android:name="SettingsLaunchPerformance"
diff --git a/tests/app/src/com/android/settings/dashboard/TabSelectionOnLaunchTest.java b/tests/app/src/com/android/settings/dashboard/TabSelectionOnLaunchTest.java
new file mode 100644
index 0000000..24c1ead
--- /dev/null
+++ b/tests/app/src/com/android/settings/dashboard/TabSelectionOnLaunchTest.java
@@ -0,0 +1,108 @@
+/*
+ * 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.
+ */
+package com.android.settings.dashboard;
+
+import android.content.Intent;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.SmallTest;
+import android.support.test.rule.ActivityTestRule;
+import android.support.test.runner.AndroidJUnit4;
+import com.android.settings.Settings;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static android.support.test.espresso.Espresso.onView;
+import static android.support.test.espresso.assertion.ViewAssertions.matches;
+import static android.support.test.espresso.matcher.ViewMatchers.isSelected;
+import static android.support.test.espresso.matcher.ViewMatchers.withText;
+import static org.hamcrest.core.IsNot.not;
+
+@RunWith(AndroidJUnit4.class)
+@SmallTest
+public class TabSelectionOnLaunchTest {
+    @Rule
+    public ActivityTestRule<Settings> mActivityRule =
+            new ActivityTestRule<>(Settings.class, true, false);
+
+    private final int FLAG_RESTART = Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK;
+    private final String ARG_SELECT_SUPPORT_TAB = "SUPPORT";
+    private final String ARG_SELECT_FAKE_TAB = "NOT_SUPPORT";
+
+    @Test
+    /* cold start for settings app with correct flags and extra always selects support tab */
+    public void test_ColdStartWithCorrectArgsCorrectFlags_SupportSelected() {
+        launchSettingsWithFlags(ARG_SELECT_SUPPORT_TAB, FLAG_RESTART);
+        verifySupportSelected();
+    }
+
+    @Test
+    /* cold start with correct flags and wrong extra defaults to all tab */
+    public void test_ColdStartWithWrongExtra_DoesNotSelectSupport() {
+        launchSettingsWithFlags(ARG_SELECT_FAKE_TAB, FLAG_RESTART);
+        verifySupportNotSelected();
+    }
+
+    @Test
+    /* warm start from elsewhere in settings with wrong flags does not select support */
+    public void test_WarmStartSummarySelectedCorrectExtraWrongFlags_DoesNotSelectSupport() {
+        InstrumentationRegistry.getContext().
+                startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS));
+        launchSettingsNoFlags(ARG_SELECT_SUPPORT_TAB);
+        verifySupportNotSelected();
+    }
+
+    @Test
+    /* warm start from elsewhere in settings with with wrong flags & extra does not select support*/
+    public void test_WarmStartSummarySelectedWrongExtraWrongFlags_DoesNotSelectSupport() {
+        InstrumentationRegistry.getContext().
+                startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS));
+        launchSettingsNoFlags(ARG_SELECT_FAKE_TAB);
+        verifySupportNotSelected();
+    }
+
+    @Test
+    /* settings does not crash on null string */
+    public void test_DoesNotCrashOnNullExtra_DoesNotSelectSupport() {
+        launchSettingsWithFlags(null, FLAG_RESTART);
+        verifySupportNotSelected();
+    }
+
+    private void verifySupportNotSelected() {
+        onView(withText(mActivityRule.getActivity().getApplicationContext().
+                getString(com.android.settings.R.string.page_tab_title_support))).
+                check(matches(not(isSelected())));
+    }
+
+    private void verifySupportSelected() {
+        onView(withText(mActivityRule.getActivity().getApplicationContext().
+                getString(com.android.settings.R.string.page_tab_title_support))).
+                check(matches(isSelected()));
+    }
+
+    private void launchSettingsWithFlags(String extra, int flags) {
+        Intent intent = new Intent(android.provider.Settings.ACTION_SETTINGS);
+        intent.setFlags(flags);
+        intent.putExtra(DashboardContainerFragment.EXTRA_SELECT_SETTINGS_TAB, extra);
+        mActivityRule.launchActivity(intent);
+    }
+
+    private void launchSettingsNoFlags(String extra) {
+        Intent intent = new Intent(android.provider.Settings.ACTION_SETTINGS);
+        intent.putExtra(DashboardContainerFragment.EXTRA_SELECT_SETTINGS_TAB, extra);
+        mActivityRule.launchActivity(intent);
+    }
+}
\ No newline at end of file
diff --git a/tests/unit/Android.mk b/tests/unit/Android.mk
index 3ba4606..7010bd1 100644
--- a/tests/unit/Android.mk
+++ b/tests/unit/Android.mk
@@ -7,7 +7,10 @@
 
 LOCAL_JAVA_LIBRARIES := android.test.runner
 
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test mockito-target
+LOCAL_STATIC_JAVA_LIBRARIES := \
+  android-support-test \
+  mockito-target \
+  espresso-core
 
 # Include all test java files.
 LOCAL_SRC_FILES := $(call all-java-files-under, src)