Merge changes from topic "jr_device" into sc-dev
* changes:
Update NLS listing page
Add device list to NLS pages
Add icons to NLS mgmt page
diff --git a/src/com/android/settings/display/ScreenTimeoutSettings.java b/src/com/android/settings/display/ScreenTimeoutSettings.java
index b518646..b187c87 100644
--- a/src/com/android/settings/display/ScreenTimeoutSettings.java
+++ b/src/com/android/settings/display/ScreenTimeoutSettings.java
@@ -26,8 +26,13 @@
import android.os.Bundle;
import android.os.UserHandle;
import android.provider.Settings;
+import android.text.SpannableString;
+import android.text.Spanned;
+import android.text.style.ClickableSpan;
import android.util.Log;
+import android.view.View;
+import androidx.annotation.NonNull;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
@@ -97,15 +102,6 @@
mPrivacyPreference.setTitle(R.string.adaptive_sleep_privacy);
mPrivacyPreference.setSelectable(false);
mPrivacyPreference.setLayoutResource(R.layout.preference_footer);
-
- mDisableOptionsPreference = new FooterPreference(context);
- mDisableOptionsPreference.setLayoutResource(R.layout.preference_footer);
- mDisableOptionsPreference.setTitle(R.string.admin_disabled_other_options);
- mDisableOptionsPreference.setIcon(R.drawable.ic_info_outline_24dp);
-
- // The 'disabled by admin' preference should always be at the end of the setting page.
- mDisableOptionsPreference.setOrder(DEFAULT_ORDER_OF_LOWEST_PREFERENCE);
- mPrivacyPreference.setOrder(DEFAULT_ORDER_OF_LOWEST_PREFERENCE - 1);
}
@Override
@@ -138,14 +134,6 @@
final PreferenceScreen screen = getPreferenceScreen();
screen.removeAll();
- if (mAdmin != null) {
- mDisableOptionsPreference.setOnPreferenceClickListener(p -> {
- RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(), mAdmin);
- return true;
- });
- screen.addPreference(mDisableOptionsPreference);
- }
-
final List<? extends CandidateInfo> candidateList = getCandidates();
if (candidateList == null) {
return;
@@ -165,14 +153,43 @@
}
if (mAdmin != null) {
- mDisableOptionsPreference.setOnPreferenceClickListener(p -> {
- RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(), mAdmin);
- return true;
- });
+ setupDisabledFooterPreference();
screen.addPreference(mDisableOptionsPreference);
}
}
+ @VisibleForTesting
+ void setupDisabledFooterPreference() {
+ final String textDisabledByAdmin = getResources().getString(
+ R.string.admin_disabled_other_options);
+ final String textMoreDetails = getResources().getString(R.string.admin_more_details);
+
+ final SpannableString spannableString = new SpannableString(
+ textDisabledByAdmin + System.lineSeparator() + textMoreDetails);
+ final ClickableSpan clickableSpan = new ClickableSpan() {
+ @Override
+ public void onClick(@NonNull View widget) {
+ RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(), mAdmin);
+ }
+ };
+
+ if (textDisabledByAdmin != null && textMoreDetails != null) {
+ spannableString.setSpan(clickableSpan, textDisabledByAdmin.length() + 1,
+ textDisabledByAdmin.length() + textMoreDetails.length() + 1,
+ Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ }
+
+ mDisableOptionsPreference = new FooterPreference(getContext());
+ mDisableOptionsPreference.setLayoutResource(R.layout.preference_footer);
+ mDisableOptionsPreference.setTitle(spannableString);
+ mDisableOptionsPreference.setSelectable(false);
+ mDisableOptionsPreference.setIcon(R.drawable.ic_info_outline_24dp);
+
+ // The 'disabled by admin' preference should always be at the end of the setting page.
+ mDisableOptionsPreference.setOrder(DEFAULT_ORDER_OF_LOWEST_PREFERENCE);
+ mPrivacyPreference.setOrder(DEFAULT_ORDER_OF_LOWEST_PREFERENCE - 1);
+ }
+
@Override
protected String getDefaultKey() {
return getCurrentSystemScreenTimeout(getContext());
diff --git a/src/com/android/settings/network/ProviderModelSlice.java b/src/com/android/settings/network/ProviderModelSlice.java
index c020f06..a1fdb1c 100644
--- a/src/com/android/settings/network/ProviderModelSlice.java
+++ b/src/com/android/settings/network/ProviderModelSlice.java
@@ -83,8 +83,9 @@
// Second section: Add a carrier item.
// Third section: Add the Wi-Fi items which are not connected.
// Fourth section: If device has connection problem, this row show the message for user.
+ boolean hasEthernet = isEthernetConnected();
final ListBuilder listBuilder = mHelper.createListBuilder(getUri());
- if (mHelper.isAirplaneModeEnabled() && !mWifiManager.isWifiEnabled()) {
+ if (mHelper.isAirplaneModeEnabled() && !mWifiManager.isWifiEnabled() && !hasEthernet) {
log("Airplane mode is enabled.");
return listBuilder.build();
}
@@ -104,12 +105,12 @@
log("hasCarrier: " + hasCarrier);
// First section: Add a Ethernet or Wi-Fi item which state is connected.
- if (isEthernetConnected()) {
+ final WifiSliceItem connectedWifiItem = mHelper.getConnectedWifiItem(wifiList);
+ if (hasEthernet) {
log("get Ethernet item which is connected");
listBuilder.addRow(createEthernetRow());
maxListSize--;
} else {
- final WifiSliceItem connectedWifiItem = mHelper.getConnectedWifiItem(wifiList);
if (connectedWifiItem != null) {
log("get Wi-Fi item which is connected");
listBuilder.addRow(getWifiSliceItemRow(connectedWifiItem));
@@ -126,7 +127,14 @@
maxListSize--;
}
- // Third section: Add the Wi-Fi items which are not connected.
+ // Third section: Add the connected Wi-Fi item to Wi-Fi list if the Ethernet is connected.
+ if (connectedWifiItem != null && hasEthernet) {
+ log("get Wi-Fi item which is connected");
+ listBuilder.addRow(getWifiSliceItemRow(connectedWifiItem));
+ maxListSize--;
+ }
+
+ // Fourth section: Add the Wi-Fi items which are not connected.
if (wifiList != null && wifiList.size() > 0) {
log("get Wi-Fi items which are not connected. Wi-Fi items : " + wifiList.size());
@@ -140,7 +148,7 @@
}
}
- // Fourth section: If device has connection problem, this row show the message for user.
+ // Fifth section: If device has connection problem, this row show the message for user.
// 1) show non_carrier_network_unavailable:
// - while no wifi item
// 2) show all_network_unavailable:
@@ -154,7 +162,7 @@
resId = R.string.all_network_unavailable;
}
- if (!hasCarrier) {
+ if (!hasCarrier && !hasEthernet) {
// If there is no item in ProviderModelItem, slice needs a header.
listBuilder.setHeader(mHelper.createHeader(
NetworkProviderSettings.ACTION_NETWORK_PROVIDER_SETTINGS));
diff --git a/tests/robotests/src/com/android/settings/display/ScreenTimeoutSettingsTest.java b/tests/robotests/src/com/android/settings/display/ScreenTimeoutSettingsTest.java
index efc45e0..f0bf95c 100644
--- a/tests/robotests/src/com/android/settings/display/ScreenTimeoutSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/display/ScreenTimeoutSettingsTest.java
@@ -23,6 +23,7 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.atLeast;
+import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
@@ -138,6 +139,7 @@
public void updateCandidates_enforcedAdmin_showDisabledByAdminPreference() {
mSettings.mAdmin = new RestrictedLockUtils.EnforcedAdmin();
mSettings.mDisableOptionsPreference = mDisableOptionsPreference;
+ doNothing().when(mSettings).setupDisabledFooterPreference();
mSettings.updateCandidates();
diff --git a/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java b/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java
index 476d854..705f60e 100644
--- a/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java
+++ b/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java
@@ -264,7 +264,7 @@
@Test
@UiThreadTest
- public void getSlice_connectedEthernet_getOneEthernetAndOneCarrierAndTwoWiFi() {
+ public void getSlice_haveEthernetAndCarrierAndTwoDisconnectedWifi_getFourRow() {
mWifiList.clear();
mockWifiItemCondition(mMockWifiSliceItem1, "wifi1", "wifi1",
WifiEntry.CONNECTED_STATE_DISCONNECTED, "wifi1_key", true);
@@ -273,9 +273,29 @@
WifiEntry.CONNECTED_STATE_DISCONNECTED, "wifi2_key", true);
mWifiList.add(mMockWifiSliceItem2);
mMockNetworkProviderWorker.updateSelfResults(mWifiList);
- when(mProviderModelSliceHelper.isAirplaneModeEnabled()).thenReturn(false);
- when(mProviderModelSliceHelper.hasCarrier()).thenReturn(true);
- when(mProviderModelSliceHelper.isDataSimActive()).thenReturn(true);
+ mockHelperCondition(false, true, true, null);
+ when(mMockNetworkProviderWorker.isEthernetConnected()).thenReturn(true);
+
+ final Slice slice = mMockProviderModelSlice.getSlice();
+
+ assertThat(slice).isNotNull();
+ assertThat(mMockProviderModelSlice.hasCreateEthernetRow()).isTrue();
+ verify(mListBuilder, times(1)).addRow(mMockCarrierRowBuild);
+ verify(mListBuilder, times(4)).addRow(any(ListBuilder.RowBuilder.class));
+ }
+
+ @Test
+ @UiThreadTest
+ public void getSlice_haveEthernetAndCarrierAndConnectedWifiAndDisconnectedWifi_getFourRow() {
+ mWifiList.clear();
+ mockWifiItemCondition(mMockWifiSliceItem1, "wifi1", "wifi1",
+ WifiEntry.CONNECTED_STATE_CONNECTED, "wifi1_key", true);
+ mWifiList.add(mMockWifiSliceItem1);
+ mockWifiItemCondition(mMockWifiSliceItem2, "wifi2", "wifi2",
+ WifiEntry.CONNECTED_STATE_DISCONNECTED, "wifi2_key", true);
+ mWifiList.add(mMockWifiSliceItem2);
+ mMockNetworkProviderWorker.updateSelfResults(mWifiList);
+ mockHelperCondition(false, true, true, mWifiList.get(0));
when(mMockNetworkProviderWorker.isEthernetConnected()).thenReturn(true);
final Slice slice = mMockProviderModelSlice.getSlice();