Merge "Refines the limit of advanced in edit shortcut dialog." into rvc-dev
diff --git a/res/layout/notification_history_log_row.xml b/res/layout/notification_history_log_row.xml
index b1357e9..ab5e29d 100644
--- a/res/layout/notification_history_log_row.xml
+++ b/res/layout/notification_history_log_row.xml
@@ -26,7 +26,8 @@
 
     <LinearLayout
         android:layout_width="match_parent"
-        android:layout_height="@*android:dimen/status_bar_icon_size"
+        android:layout_height="wrap_content"
+        android:minHeight="@*android:dimen/status_bar_icon_size"
         android:gravity="center_vertical">
 
         <TextView
diff --git a/res/raw/gesture_device_controls.mp4 b/res/raw/gesture_device_controls.mp4
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/res/raw/gesture_device_controls.mp4
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 79d797c..e695c4d 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -402,8 +402,7 @@
     <dimen name="two_target_min_width">80dp</dimen>
 
     <!-- Maximum height for SliceView, override on slices/view/src/main/res/values/dimens.xml -->
-    <!-- A single Row Slice height is 60dp -->
-    <dimen name="abc_slice_large_height">1200dp</dimen>
+    <dimen name="abc_slice_large_height">1800dp</dimen>
 
     <!-- System navigation settings illustration height -->
     <dimen name="system_navigation_illustration_height">320dp</dimen>
diff --git a/res/xml/device_controls_settings.xml b/res/xml/device_controls_settings.xml
index 998b982..da6cdc0 100644
--- a/res/xml/device_controls_settings.xml
+++ b/res/xml/device_controls_settings.xml
@@ -21,7 +21,8 @@
     android:title="@string/device_controls_sentence">
 
     <com.android.settings.widget.VideoPreference
-        android:key="device_controls_video"/>
+        android:key="device_controls_video"
+        app:animation="@raw/gesture_device_controls"/>
 
     <SwitchPreference
         android:key="gesture_device_controls_switch"
diff --git a/res/xml/wifi_network_details_fragment2.xml b/res/xml/wifi_network_details_fragment2.xml
index 30a7f67..92f68cc 100644
--- a/res/xml/wifi_network_details_fragment2.xml
+++ b/res/xml/wifi_network_details_fragment2.xml
@@ -31,10 +31,18 @@
         android:selectable="false"
         settings:isPreferenceVisible="false"/>
 
+    <!-- The preference to display the second summary -->
+    <com.android.settings.widget.LinkifySummaryPreference
+        android:key="second_summary"
+        android:icon="@drawable/ic_info_outline_24dp"
+        android:selectable="false"
+        settings:allowDividerAbove="false"/>
+
     <!-- Buttons -->
     <com.android.settingslib.widget.ActionButtonsPreference
         android:key="buttons"
-        android:selectable="false" />
+        android:selectable="false"
+        settings:allowDividerAbove="true"/>
 
     <!-- General Details Preferences -->
     <Preference
diff --git a/src/com/android/settings/widget/EntityHeaderController.java b/src/com/android/settings/widget/EntityHeaderController.java
index 654d50b..91a20b3 100644
--- a/src/com/android/settings/widget/EntityHeaderController.java
+++ b/src/com/android/settings/widget/EntityHeaderController.java
@@ -374,7 +374,6 @@
         }
     }
 
-
     private void setText(@IdRes int id, CharSequence text) {
         TextView textView = mHeader.findViewById(id);
         if (textView != null) {
diff --git a/src/com/android/settings/widget/LinkifySummaryPreference.java b/src/com/android/settings/widget/LinkifySummaryPreference.java
new file mode 100644
index 0000000..2683873
--- /dev/null
+++ b/src/com/android/settings/widget/LinkifySummaryPreference.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2020 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.text.SpannableString;
+import android.text.TextUtils;
+import android.text.method.LinkMovementMethod;
+import android.text.style.ClickableSpan;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.TextView;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceViewHolder;
+
+/** A preference which supports linkify text in the summary **/
+public class LinkifySummaryPreference extends Preference {
+
+    public LinkifySummaryPreference(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    public LinkifySummaryPreference(Context context) {
+        super(context);
+    }
+
+    @Override
+    public void onBindViewHolder(PreferenceViewHolder holder) {
+        super.onBindViewHolder(holder);
+
+        final TextView summaryView = (TextView) holder.findViewById(android.R.id.summary);
+        if (summaryView == null || summaryView.getVisibility() != View.VISIBLE) {
+            return;
+        }
+
+        final CharSequence summary = getSummary();
+        if (!TextUtils.isEmpty(summary)) {
+            final SpannableString spannableSummary = new SpannableString(summary);
+            if (spannableSummary.getSpans(0, spannableSummary.length(), ClickableSpan.class)
+                    .length > 0) {
+                summaryView.setMovementMethod(LinkMovementMethod.getInstance());
+            }
+        }
+    }
+}
diff --git a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
index 2228f7b..58299c8 100644
--- a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
+++ b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
@@ -446,10 +446,8 @@
         if (usingDataUsageHeader(mContext)) {
             mSummaryHeaderController.updateState(mDataUsageSummaryPref);
         } else {
-            String summary = mWifiEntry.getSummary();
-
             mEntityHeaderController
-                    .setSummary(summary)
+                    .setSummary(mWifiEntry.getSummary())
                     .setSecondSummary(getExpiryTimeSummary())
                     .setRecyclerView(mFragment.getListView(), mLifecycle)
                     .done(mFragment.getActivity(), true /* rebind */);
diff --git a/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2.java b/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2.java
index 394bab6..1a8ac1d 100644
--- a/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2.java
+++ b/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2.java
@@ -140,7 +140,7 @@
                                 getContext().getSystemService(Context.DEVICE_POLICY_SERVICE);
                         final UserManager um = (UserManager)
                                 getContext().getSystemService(Context.USER_SERVICE);
-                        int profileOwnerUserId = Utils.getManagedProfileId(
+                        final int profileOwnerUserId = Utils.getManagedProfileId(
                                 um, UserHandle.myUserId());
                         admin = new EnforcedAdmin(dpm.getProfileOwnerAsUser(profileOwnerUserId),
                                 null, UserHandle.of(profileOwnerUserId));
@@ -162,6 +162,11 @@
         setupNetworksDetailTracker();
         final WifiEntry wifiEntry = mNetworkDetailsTracker.getWifiEntry();
 
+        final WifiSecondSummaryController2 wifiSecondSummaryController2 =
+                new WifiSecondSummaryController2(context);
+        wifiSecondSummaryController2.setWifiEntry(wifiEntry);
+        mControllers.add(wifiSecondSummaryController2);
+
         mWifiDetailPreferenceController2 = WifiDetailPreferenceController2.newInstance(
                 wifiEntry,
                 cm,
diff --git a/src/com/android/settings/wifi/details2/WifiSecondSummaryController2.java b/src/com/android/settings/wifi/details2/WifiSecondSummaryController2.java
new file mode 100644
index 0000000..93bb2c4
--- /dev/null
+++ b/src/com/android/settings/wifi/details2/WifiSecondSummaryController2.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2020 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.wifi.details2;
+
+import android.content.Context;
+import android.text.TextUtils;
+
+import com.android.settings.core.BasePreferenceController;
+import com.android.wifitrackerlib.WifiEntry;
+
+/**
+ * {@link BasePreferenceController} that display the second summary. If users click the preference,
+ * @link ClickableSpan#onClick} of the first {@link ClickableSpan} in the summary will be called.
+ */
+public class WifiSecondSummaryController2 extends BasePreferenceController {
+
+    private static final String KEY_WIFI_SECOND_SUMMARY = "second_summary";
+    private CharSequence mSecondSummary;
+
+    public WifiSecondSummaryController2(Context context) {
+        super(context, KEY_WIFI_SECOND_SUMMARY);
+    }
+
+    public void setWifiEntry(WifiEntry wifiEntry) {
+        mSecondSummary = wifiEntry.getSecondSummary();
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return TextUtils.isEmpty(mSecondSummary) ? CONDITIONALLY_UNAVAILABLE : AVAILABLE;
+    }
+
+    @Override
+    public CharSequence getSummary() {
+        return mSecondSummary;
+    }
+}
diff --git a/src/com/android/settings/wifi/p2p/WifiP2pSettings.java b/src/com/android/settings/wifi/p2p/WifiP2pSettings.java
index 8544a53..7f82359 100644
--- a/src/com/android/settings/wifi/p2p/WifiP2pSettings.java
+++ b/src/com/android/settings/wifi/p2p/WifiP2pSettings.java
@@ -50,6 +50,7 @@
 import android.widget.EditText;
 import android.widget.Toast;
 
+import androidx.annotation.VisibleForTesting;
 import androidx.appcompat.app.AlertDialog;
 import androidx.preference.Preference;
 import androidx.preference.PreferenceScreen;
@@ -79,9 +80,9 @@
     private OnClickListener mDisconnectListener;
     private OnClickListener mCancelConnectListener;
     private OnClickListener mDeleteGroupListener;
-    private WifiP2pPeer mSelectedWifiPeer;
+    @VisibleForTesting WifiP2pPeer mSelectedWifiPeer;
     private WifiP2pPersistentGroup mSelectedGroup;
-    private String mSelectedGroupName;
+    @VisibleForTesting String mSelectedGroupName;
     private EditText mDeviceNameText;
 
     private boolean mWifiP2pEnabled;
@@ -100,13 +101,13 @@
     private static final int DIALOG_DELETE_GROUP = 4;
 
     private static final String SAVE_DIALOG_PEER = "PEER_STATE";
-    private static final String SAVE_DEVICE_NAME = "DEV_NAME";
-    private static final String SAVE_SELECTED_GROUP = "GROUP_NAME";
+    @VisibleForTesting static final String SAVE_DEVICE_NAME = "DEV_NAME";
+    @VisibleForTesting static final String SAVE_SELECTED_GROUP = "GROUP_NAME";
 
     private WifiP2pDevice mThisDevice;
     private WifiP2pDeviceList mPeers = new WifiP2pDeviceList();
 
-    private String mSavedDeviceName;
+    @VisibleForTesting String mSavedDeviceName;
 
     private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
         @Override
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/NfcAndPaymentFragmentTest.java b/tests/robotests/src/com/android/settings/connecteddevice/NfcAndPaymentFragmentTest.java
index 6a15108..46c9cbb 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/NfcAndPaymentFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/NfcAndPaymentFragmentTest.java
@@ -26,7 +26,6 @@
 import android.provider.SearchIndexableResource;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -63,8 +62,7 @@
     }
 
     @Test
-    @Ignore
-    public void searchIndexProvider_shouldIndexAllItems() {
+    public void searchIndexProvider_shouldIndexValidItems() {
         when(mContext.getApplicationContext()).thenReturn(mContext);
         when(NfcAdapter.getDefaultAdapter(mContext)).thenReturn(mNfcAdapter);
         when(mNfcAdapter.isSecureNfcSupported()).thenReturn(true);
@@ -73,6 +71,6 @@
                 .getNonIndexableKeys(mContext);
 
         assertThat(niks).isNotNull();
-        assertThat(niks).isEmpty();
+        assertThat(niks).containsExactly("nfc_detection_point");
     }
 }
diff --git a/tests/robotests/src/com/android/settings/widget/LinkifySummaryPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/LinkifySummaryPreferenceTest.java
new file mode 100644
index 0000000..e5ae840
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/widget/LinkifySummaryPreferenceTest.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2020 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 org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.text.SpannableStringBuilder;
+import android.text.Spanned;
+import android.text.method.LinkMovementMethod;
+import android.text.style.URLSpan;
+import android.view.View;
+import android.widget.TextView;
+
+import androidx.preference.PreferenceViewHolder;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class LinkifySummaryPreferenceTest {
+    @Spy
+    private PreferenceViewHolder mViewHolder;
+    @Mock
+    private TextView mSummaryTextView;
+    private LinkifySummaryPreference mPreference;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+
+        final Context context = RuntimeEnvironment.application;
+        mPreference = new LinkifySummaryPreference(context, null /* attrs */);
+
+        final View view = spy(View.inflate(context, mPreference.getLayoutResource(),
+                null /* root */));
+        mViewHolder = spy(PreferenceViewHolder.createInstanceForTests(view));
+        doReturn(mSummaryTextView).when(mViewHolder).findViewById(android.R.id.summary);
+    }
+
+    @Test
+    public void onBindViewHolder_summaryTextViewGone_shouldNotSetMovementMethod() {
+        when(mSummaryTextView.getVisibility()).thenReturn(View.GONE);
+
+        mPreference.onBindViewHolder(mViewHolder);
+
+        verify(mSummaryTextView, never()).setMovementMethod(LinkMovementMethod.getInstance());
+    }
+
+    @Test
+    public void onBindViewHolder_noLinkSummary_shouldNotSetMovementMethod() {
+        when(mSummaryTextView.getVisibility()).thenReturn(View.VISIBLE);
+        final CharSequence seondSummary = "secondSummary";
+        mPreference.setSummary(seondSummary);
+
+        mPreference.onBindViewHolder(mViewHolder);
+
+        verify(mSummaryTextView, never()).setMovementMethod(LinkMovementMethod.getInstance());
+    }
+
+    @Test
+    public void onBindViewHolder_linkedSummary_shouldSetMovementMethod() {
+        when(mSummaryTextView.getVisibility()).thenReturn(View.VISIBLE);
+        final CharSequence seondSummary = "secondSummary";
+        final SpannableStringBuilder summaryBuilder = new SpannableStringBuilder();
+        summaryBuilder.append(seondSummary, new URLSpan("" /* url */),
+                Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+        mPreference.setSummary(summaryBuilder);
+
+        mPreference.onBindViewHolder(mViewHolder);
+
+        verify(mSummaryTextView).setMovementMethod(any(LinkMovementMethod.class));
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/details2/WifiSecondSummaryController2Test.java b/tests/robotests/src/com/android/settings/wifi/details2/WifiSecondSummaryController2Test.java
new file mode 100644
index 0000000..439fd7d
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/wifi/details2/WifiSecondSummaryController2Test.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2020 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.wifi.details2;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.when;
+
+import com.android.wifitrackerlib.WifiEntry;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class WifiSecondSummaryController2Test {
+
+    private WifiSecondSummaryController2 mController;
+    @Mock
+    private WifiEntry mWifiEntry;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mController = new WifiSecondSummaryController2(RuntimeEnvironment.application);
+    }
+
+    @Test
+    public void getAvailabilityStatus_showWhenSummaryAvailable() {
+        // Visible when summary is not empty.
+        when(mWifiEntry.getSecondSummary()).thenReturn("test");
+        mController.setWifiEntry(mWifiEntry);
+
+        assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+
+        // Invisible when summary is empty.
+        when(mWifiEntry.getSecondSummary()).thenReturn("");
+        mController.setWifiEntry(mWifiEntry);
+
+        assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/p2p/WifiP2pSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/p2p/WifiP2pSettingsTest.java
new file mode 100644
index 0000000..ba6a075
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/wifi/p2p/WifiP2pSettingsTest.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2020 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.wifi.p2p;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.os.Bundle;
+
+import androidx.fragment.app.FragmentActivity;
+
+import com.android.settings.testutils.XmlTestUtils;
+import com.android.settingslib.core.AbstractPreferenceController;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.Robolectric;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+public class WifiP2pSettingsTest {
+
+    private Context mContext;
+    private FragmentActivity mActivity;
+    private WifiP2pSettings mFragment;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mContext = RuntimeEnvironment.application;
+        mActivity = Robolectric.setupActivity(FragmentActivity.class);
+        mFragment = spy(new WifiP2pSettings());
+    }
+
+    @Test
+    public void preferenceScreenKey_shouldContainsAllControllerKeys() {
+        final List<String> preferenceScreenKeys = XmlTestUtils.getKeysFromPreferenceXml(mContext,
+                mFragment.getPreferenceScreenResId());
+        final List<String> preferenceKeys = new ArrayList<>();
+
+        for (AbstractPreferenceController controller : mFragment.createPreferenceControllers(
+                mContext)) {
+            preferenceKeys.add(controller.getPreferenceKey());
+        }
+
+        assertThat(preferenceScreenKeys).containsAllIn(preferenceKeys);
+    }
+
+    @Test
+    public void onActivityCreate_withNullBundle_canNotGetValue() {
+        when(mFragment.getActivity()).thenReturn(mActivity);
+
+        mFragment.onActivityCreated(null);
+
+        assertThat(mFragment.mSelectedWifiPeer).isNull();
+    }
+
+    @Test
+    public void onActivityCreate_withDeviceName_shouldGetDeviceName() {
+        when(mFragment.getActivity()).thenReturn(mActivity);
+        final String fakeDeviceName = "fakename";
+        final Bundle bundle = new Bundle();
+        bundle.putString(WifiP2pSettings.SAVE_DEVICE_NAME, fakeDeviceName);
+
+        mFragment.onActivityCreated(bundle);
+
+        assertThat(mFragment.mSavedDeviceName).isEqualTo(fakeDeviceName);
+    }
+
+    @Test
+    public void onActivityCreate_withGroupName_shouldGetGroupName() {
+        when(mFragment.getActivity()).thenReturn(mActivity);
+        final String fakeGroupName = "fakegroup";
+        final Bundle bundle = new Bundle();
+        bundle.putString(WifiP2pSettings.SAVE_SELECTED_GROUP, fakeGroupName);
+
+        mFragment.onActivityCreated(bundle);
+
+        assertThat(mFragment.mSelectedGroupName).isEqualTo(fakeGroupName);
+        assertThat(mFragment.mSavedDeviceName).isNull();
+    }
+}