diff --git a/res/xml/wifi_network_details_fragment2.xml b/res/xml/wifi_network_details_fragment2.xml
index 30a7f67de00..92f68cc4665 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"/>
+
+
+
+ android:selectable="false"
+ settings:allowDividerAbove="true"/>
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 2228f7b140a..58299c848c2 100644
--- a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
+++ b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
@@ -446,10 +446,8 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle
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 394bab65be0..1a8ac1df8f5 100644
--- a/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2.java
+++ b/src/com/android/settings/wifi/details2/WifiNetworkDetailsFragment2.java
@@ -140,7 +140,7 @@ public class WifiNetworkDetailsFragment2 extends DashboardFragment implements
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 @@ public class WifiNetworkDetailsFragment2 extends DashboardFragment implements
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 00000000000..93bb2c4b16e
--- /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/tests/robotests/src/com/android/settings/widget/LinkifySummaryPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/LinkifySummaryPreferenceTest.java
new file mode 100644
index 00000000000..e5ae8402532
--- /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 00000000000..439fd7df87b
--- /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);
+ }
+}