diff --git a/res/drawable/ic_lock_pin.xml b/res/drawable/ic_lock_pin.xml
index e1821f6ec8b..587f49cab5b 100644
--- a/res/drawable/ic_lock_pin.xml
+++ b/res/drawable/ic_lock_pin.xml
@@ -21,5 +21,5 @@
android:viewportHeight="24">
+ android:fillColor="?android:attr/colorAccent"/>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index c19c8dc6711..8bc44bef868 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1088,77 +1088,77 @@
You\u2019ve chosen to use your fingerprint as one way to unlock your phone. If you skip now, you\u2019ll need to set this up later. Setup takes only a minute or so.
- A PIN protects your tablet if it\u2019s lost or stolen
+ A PIN protects the tablet if it\u2019s lost or stolen
- A pattern protects your tablet if it\u2019s lost or stolen
+ A pattern protects the tablet if it\u2019s lost or stolen
- A password protects your tablet if it\u2019s lost or stolen
+ A password protects the tablet if it\u2019s lost or stolen
- A PIN protects your device if it\u2019s lost or stolen
+ A PIN protects the device if it\u2019s lost or stolen
- A pattern protects your device if it\u2019s lost or stolen
+ A pattern protects the device if it\u2019s lost or stolen
- A password protects your device if it\u2019s lost or stolen
+ A password protects the device if it\u2019s lost or stolen
- A PIN protects your phone if it\u2019s lost or stolen
+ A PIN protects the phone if it\u2019s lost or stolen
- A pattern protects your phone if it\u2019s lost or stolen
+ A pattern protects the phone if it\u2019s lost or stolen
- A password protects your phone if it\u2019s lost or stolen
+ A password protects the phone if it\u2019s lost or stolen
- A PIN is required to set up Fingerprint Unlock.\n\nA PIN protects your tablet if it\u2019s lost or stolen.
+ A PIN is required to set up Fingerprint Unlock.\n\nA PIN protects the tablet if it\u2019s lost or stolen.
- A pattern is required to set up Fingerprint Unlock.\n\nA pattern protects your tablet if it\u2019s lost or stolen.
+ A pattern is required to set up Fingerprint Unlock.\n\nA pattern protects the tablet if it\u2019s lost or stolen.
- A password is required to set up Fingerprint Unlock.\n\nA password protects your tablet if it\u2019s lost or stolen.
+ A password is required to set up Fingerprint Unlock.\n\nA password protects the tablet if it\u2019s lost or stolen.
- A PIN is required to set up Fingerprint Unlock.\n\nA PIN protects your device if it\u2019s lost or stolen.
+ A PIN is required to set up Fingerprint Unlock.\n\nA PIN protects the device if it\u2019s lost or stolen.
- A pattern is required to set up Fingerprint Unlock.\n\nA pattern protects your device if it\u2019s lost or stolen.
+ A pattern is required to set up Fingerprint Unlock.\n\nA pattern protects the device if it\u2019s lost or stolen.
- A password is required to set up Fingerprint Unlock.\n\nA password protects your device if it\u2019s lost or stolen.
+ A password is required to set up Fingerprint Unlock.\n\nA password protects the device if it\u2019s lost or stolen.
- A PIN is required to set up Fingerprint Unlock.\n\nA PIN protects your phone if it\u2019s lost or stolen.
+ A PIN is required to set up Fingerprint Unlock.\n\nA PIN protects the phone if it\u2019s lost or stolen.
- A pattern is required to set up Fingerprint Unlock.\n\nA pattern protects your phone if it\u2019s lost or stolen.
+ A pattern is required to set up Fingerprint Unlock.\n\nA pattern protects the phone if it\u2019s lost or stolen.
- A password is required to set up Fingerprint Unlock.\n\nA password protects your phone if it\u2019s lost or stolen.
+ A password is required to set up Fingerprint Unlock.\n\nA password protects the phone if it\u2019s lost or stolen.
- A PIN is required to set up Face Unlock.\n\nA PIN protects your tablet if it\u2019s lost or stolen.
+ A PIN is required to set up Face Unlock.\n\nA PIN protects the tablet if it\u2019s lost or stolen.
- A pattern is required to set up Face Unlock.\n\nA pattern protects your tablet if it\u2019s lost or stolen.
+ A pattern is required to set up Face Unlock.\n\nA pattern protects the tablet if it\u2019s lost or stolen.
- A password is required to set up Face Unlock.\n\nA password protects your tablet if it\u2019s lost or stolen.
+ A password is required to set up Face Unlock.\n\nA password protects the tablet if it\u2019s lost or stolen.
- A PIN is required to set up Face Unlock.\n\nA PIN protects your device if it\u2019s lost or stolen.
+ A PIN is required to set up Face Unlock.\n\nA PIN protects the device if it\u2019s lost or stolen.
- A pattern is required to set up Face Unlock.\n\nA pattern protects your device if it\u2019s lost or stolen.
+ A pattern is required to set up Face Unlock.\n\nA pattern protects the device if it\u2019s lost or stolen.
- A password is required to set up Face Unlock.\n\nA password protects your device if it\u2019s lost or stolen.
+ A password is required to set up Face Unlock.\n\nA password protects the device if it\u2019s lost or stolen.
- A PIN is required to set up Face Unlock.\n\nA PIN protects your phone if it\u2019s lost or stolen.
+ A PIN is required to set up Face Unlock.\n\nA PIN protects the phone if it\u2019s lost or stolen.
- A pattern is required to set up Face Unlock.\n\nA pattern protects your phone if it\u2019s lost or stolen.
+ A pattern is required to set up Face Unlock.\n\nA pattern protects the phone if it\u2019s lost or stolen.
- A password is required to set up Face Unlock.\n\nA password protects your phone if it\u2019s lost or stolen.
+ A password is required to set up Face Unlock.\n\nA password protects the phone if it\u2019s lost or stolen.
- A PIN is required to set up Face Unlock and Fingerprint Unlock.\n\nA PIN protects your tablet if it\u2019s lost or stolen.
+ A PIN is required to set up Face Unlock and Fingerprint Unlock.\n\nA PIN protects the tablet if it\u2019s lost or stolen.
- A pattern is required to set up Face Unlock and Fingerprint Unlock.\n\nA pattern protects your tablet if it\u2019s lost or stolen.
+ A pattern is required to set up Face Unlock and Fingerprint Unlock.\n\nA pattern protects the tablet if it\u2019s lost or stolen.
- A password is required to set up Face Unlock and Fingerprint Unlock.\n\nA password protects your tablet if it\u2019s lost or stolen.
+ A password is required to set up Face Unlock and Fingerprint Unlock.\n\nA password protects the tablet if it\u2019s lost or stolen.
- A PIN is required to set up Face Unlock and Fingerprint Unlock.\n\nA PIN protects your device if it\u2019s lost or stolen.
+ A PIN is required to set up Face Unlock and Fingerprint Unlock.\n\nA PIN protects the device if it\u2019s lost or stolen.
- A pattern is required to set up Face Unlock and Fingerprint Unlock.\n\nA pattern protects your device if it\u2019s lost or stolen.
+ A pattern is required to set up Face Unlock and Fingerprint Unlock.\n\nA pattern protects the device if it\u2019s lost or stolen.
- A password is required to set up Face Unlock and Fingerprint Unlock.\n\nA password protects your device if it\u2019s lost or stolen.
+ A password is required to set up Face Unlock and Fingerprint Unlock.\n\nA password protects the device if it\u2019s lost or stolen.
- A PIN is required to set up Face Unlock and Fingerprint Unlock.\n\nA PIN protects your phone if it\u2019s lost or stolen.
+ A PIN is required to set up Face Unlock and Fingerprint Unlock.\n\nA PIN protects the phone if it\u2019s lost or stolen.
- A pattern is required to set up Face Unlock and Fingerprint Unlock.\n\nA pattern protects your phone if it\u2019s lost or stolen.
+ A pattern is required to set up Face Unlock and Fingerprint Unlock.\n\nA pattern protects the phone if it\u2019s lost or stolen.
- A password is required to set up Face Unlock and Fingerprint Unlock.\n\nA password protects your phone if it\u2019s lost or stolen.
+ A password is required to set up Face Unlock and Fingerprint Unlock.\n\nA password protects the phone if it\u2019s lost or stolen.
Skip PIN setup?
@@ -5403,8 +5403,8 @@
Using the accessibility button. The gesture isn\u2019t available with 3-button navigation.
Quickly access accessibility features
-
- Quickly access accessibility features from any screen. \n\nTo get started, go to accessibility settings and select a feature. Tap on the shortcut and select the accessibility button or gesture.
+
+ Quickly access accessibility features from any screen.\n\nTo get started, go to accessibility settings and select a feature. Tap on the shortcut and select the accessibility button.\n\nTo use the accessibility button in the navigation bar instead, switch to 2-button navigation or 3-button navigation.
Quickly access accessibility features from any screen. \n\nTo get started, go to accessibility settings and select a feature. Tap on the shortcut and select the accessibility button.
@@ -8204,7 +8204,7 @@
wifi, wi-fi, call, calling
screen, touchscreen
dim screen, touchscreen, battery, bright
- dim screen, night, tint, night shift, brightness, screen color, colour, color, light sensitivity, photophobia, make darker, darken, dark mode, migraine
+ dim screen, night, tint, night shift, brightness, screen color, colour, color
background, personalize, customize display
text size
@@ -8252,7 +8252,7 @@
serial number, hardware version
android security patch level, baseband version, kernel version
- theme, light, dark, mode
+ theme, light, dark, mode, light sensitivity, photophobia, make darker, darken, dark mode, migraine
dark theme
@@ -12353,6 +12353,15 @@
Device name
+
+ Basic info
+
+ Legal & regulatory
+
+ Device details
+
+ Device identifiers
+
Wi-Fi control
diff --git a/res/xml/accessibility_button_settings.xml b/res/xml/accessibility_button_settings.xml
index 02b1c7d4693..78d13ab1a8d 100644
--- a/res/xml/accessibility_button_settings.xml
+++ b/res/xml/accessibility_button_settings.xml
@@ -61,7 +61,6 @@
-
-
+
-
-
+
+
-
-
+
+
-
-
+
+
+
-
-
-
-
+
-
-
-
-
+
+
-
-
+
+
+
+
-
-
+
+
+
+
+
-
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
-
-
+
-
-
+
+
-
-
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/com/android/settings/accessibility/AccessibilityButtonFooterPreferenceController.java b/src/com/android/settings/accessibility/AccessibilityButtonFooterPreferenceController.java
index 744a29211cf..8b4a364a393 100644
--- a/src/com/android/settings/accessibility/AccessibilityButtonFooterPreferenceController.java
+++ b/src/com/android/settings/accessibility/AccessibilityButtonFooterPreferenceController.java
@@ -34,4 +34,11 @@ public class AccessibilityButtonFooterPreferenceController extends
protected String getLabelName() {
return mContext.getString(R.string.accessibility_button_title);
}
+
+ @Override
+ public CharSequence getSummary() {
+ return AccessibilityUtil.isGestureNavigateEnabled(mContext)
+ ? mContext.getString(R.string.accessibility_button_gesture_description)
+ : mContext.getString(R.string.accessibility_button_description);
+ }
}
diff --git a/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java b/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
index 1e251794458..95f74fa18ce 100644
--- a/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
+++ b/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
@@ -38,7 +38,6 @@ import android.telephony.CellBroadcastIntents;
import android.telephony.CellBroadcastService;
import android.telephony.CellSignalStrength;
import android.telephony.ICellBroadcastService;
-import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.SubscriptionInfo;
@@ -245,6 +244,8 @@ public class SimStatusDialogController implements LifecycleObserver {
private void updateSubscriptionStatus() {
updateNetworkProvider();
+ // getServiceState() may return null when the subscription is inactive
+ // or when there was an error communicating with the phone process.
final ServiceState serviceState = mTelephonyManager.getServiceState();
final SignalStrength signalStrength = mTelephonyManager.getSignalStrength();
@@ -577,7 +578,10 @@ public class SimStatusDialogController implements LifecycleObserver {
}
private void updateRoamingStatus(ServiceState serviceState) {
- if (serviceState.getRoaming()) {
+ // If the serviceState is null, we assume that roaming is disabled.
+ if (serviceState == null) {
+ mDialog.setText(ROAMING_INFO_VALUE_ID, mRes.getString(R.string.radioInfo_unknown));
+ } else if (serviceState.getRoaming()) {
mDialog.setText(ROAMING_INFO_VALUE_ID, mRes.getString(R.string.radioInfo_roaming_in));
} else {
mDialog.setText(ROAMING_INFO_VALUE_ID, mRes.getString(R.string.radioInfo_roaming_not));
diff --git a/src/com/android/settings/network/AirplaneModePreferenceController.java b/src/com/android/settings/network/AirplaneModePreferenceController.java
index 122b9752ca8..68390379328 100644
--- a/src/com/android/settings/network/AirplaneModePreferenceController.java
+++ b/src/com/android/settings/network/AirplaneModePreferenceController.java
@@ -35,11 +35,12 @@ import com.android.settings.AirplaneModeEnabler;
import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnDestroy;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;
public class AirplaneModePreferenceController extends TogglePreferenceController
- implements LifecycleObserver, OnStart, OnStop,
+ implements LifecycleObserver, OnStart, OnStop, OnDestroy,
AirplaneModeEnabler.OnAirplaneModeChangedListener {
public static final int REQUEST_CODE_EXIT_ECM = 1;
@@ -133,6 +134,12 @@ public class AirplaneModePreferenceController extends TogglePreferenceController
}
}
+ @Override
+ public void onDestroy() {
+ mAirplaneModeEnabler.close();
+ }
+
+
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CODE_EXIT_ECM) {
final boolean isChoiceYes = data.getBooleanExtra(EXIT_ECM_RESULT, false);
diff --git a/src/com/android/settings/network/InternetUpdater.java b/src/com/android/settings/network/InternetUpdater.java
index cb8d32ca161..3d97e95483f 100644
--- a/src/com/android/settings/network/InternetUpdater.java
+++ b/src/com/android/settings/network/InternetUpdater.java
@@ -33,6 +33,7 @@ import android.net.ConnectivityManager;
import android.net.ConnectivityManager.NetworkCallback;
import android.net.Network;
import android.net.NetworkCapabilities;
+import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.util.Log;
@@ -249,6 +250,9 @@ public class InternetUpdater implements AirplaneModeEnabler.OnAirplaneModeChange
@InternetType int internetType = INTERNET_NETWORKS_AVAILABLE;
if (mInternetAvailable) {
internetType = sTransportMap.get(mTransport);
+ if (internetType == INTERNET_WIFI && isCarrierWifiActive()) {
+ internetType = INTERNET_CELLULAR;
+ }
} else if (mAirplaneModeEnabler.isAirplaneModeOn()
&& mWifiManager.getWifiState() != WifiManager.WIFI_STATE_ENABLED) {
internetType = INTERNET_OFF;
@@ -260,6 +264,15 @@ public class InternetUpdater implements AirplaneModeEnabler.OnAirplaneModeChange
}
}
+ protected boolean isCarrierWifiActive() {
+ final WifiInfo wifiInfo = mWifiManager.getConnectionInfo();
+ if (wifiInfo == null || !wifiInfo.isCarrierMerged()) {
+ return false;
+ }
+ Log.i(TAG, "Detect a merged carrier Wi-Fi connected.");
+ return true;
+ }
+
/**
* Get the internet type.
*/
diff --git a/src/com/android/settings/network/NetworkProviderSettings.java b/src/com/android/settings/network/NetworkProviderSettings.java
index 25cf4ce7dab..88e732a0702 100644
--- a/src/com/android/settings/network/NetworkProviderSettings.java
+++ b/src/com/android/settings/network/NetworkProviderSettings.java
@@ -116,6 +116,7 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
static final int MENU_ID_FORGET = Menu.FIRST + 3;
static final int MENU_ID_MODIFY = Menu.FIRST + 4;
static final int MENU_FIX_CONNECTIVITY = Menu.FIRST + 5;
+ static final int MENU_ID_SHARE = Menu.FIRST + 6;
@VisibleForTesting
static final int ADD_NETWORK_REQUEST = 2;
@@ -200,7 +201,7 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
* ensure that behavior is consistent if {@link #isUiRestricted()} changes. It could be changed
* by the Test DPC tool in AFW mode.
*/
- private boolean mIsRestricted;
+ protected boolean mIsRestricted;
@VisibleForTesting
AirplaneModeEnabler mAirplaneModeEnabler;
@@ -218,7 +219,8 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
PreferenceCategory mConnectedWifiEntryPreferenceCategory;
@VisibleForTesting
PreferenceCategory mFirstWifiEntryPreferenceCategory;
- private PreferenceCategory mWifiEntryPreferenceCategory;
+ @VisibleForTesting
+ PreferenceCategory mWifiEntryPreferenceCategory;
@VisibleForTesting
AddWifiNetworkPreference mAddWifiNetworkPreference;
private WifiSwitchPreferenceController mWifiSwitchPreferenceController;
@@ -458,6 +460,12 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
super.onStop();
}
+ @Override
+ public void onDestroy() {
+ mAirplaneModeEnabler.close();
+ super.onDestroy();
+ }
+
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
@@ -535,7 +543,8 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
}
if (mSelectedWifiEntry.canDisconnect()) {
- menu.add(Menu.NONE, MENU_ID_DISCONNECT, 0 /* order */,
+ menu.add(Menu.NONE, MENU_ID_SHARE, 0 /* order */, R.string.share);
+ menu.add(Menu.NONE, MENU_ID_DISCONNECT, 1 /* order */,
R.string.wifi_disconnect_button_text);
}
@@ -574,6 +583,10 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
case MENU_ID_FORGET:
forget(mSelectedWifiEntry);
return true;
+ case MENU_ID_SHARE:
+ WifiDppUtils.showLockScreen(getContext(),
+ () -> launchWifiDppConfiguratorActivity(mSelectedWifiEntry));
+ return true;
case MENU_ID_MODIFY:
showDialog(mSelectedWifiEntry, WifiConfigUiBase2.MODE_MODIFY);
return true;
@@ -608,6 +621,23 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
return true;
}
+ private void launchWifiDppConfiguratorActivity(WifiEntry wifiEntry) {
+ final Intent intent = WifiDppUtils.getConfiguratorQrCodeGeneratorIntentOrNull(getContext(),
+ mWifiManager, wifiEntry);
+
+ if (intent == null) {
+ Log.e(TAG, "Launch Wi-Fi DPP QR code generator with a wrong Wi-Fi network!");
+ } else {
+ mMetricsFeatureProvider.action(SettingsEnums.PAGE_UNKNOWN,
+ SettingsEnums.ACTION_SETTINGS_SHARE_WIFI_QR_CODE,
+ SettingsEnums.SETTINGS_WIFI_DPP_CONFIGURATOR,
+ /* key */ null,
+ /* value */ Integer.MIN_VALUE);
+
+ startActivity(intent);
+ }
+ }
+
private void showDialog(WifiEntry wifiEntry, int dialogMode) {
if (WifiUtils.isNetworkLockedDown(getActivity(), wifiEntry.getWifiConfiguration())
&& wifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_CONNECTED) {
@@ -771,7 +801,11 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
}
}
- private void updateWifiEntryPreferences() {
+ protected void updateWifiEntryPreferences() {
+ // bypass the update if the activity and the view are not ready, or it's restricted UI.
+ if (getActivity() == null || getView() == null || mIsRestricted) {
+ return;
+ }
// in case state has changed
if (mWifiPickerTracker.getWifiState() != WifiManager.WIFI_STATE_ENABLED) {
return;
diff --git a/src/com/android/settings/network/ProviderModelSlice.java b/src/com/android/settings/network/ProviderModelSlice.java
index aafe715c4a5..df705cd95c1 100644
--- a/src/com/android/settings/network/ProviderModelSlice.java
+++ b/src/com/android/settings/network/ProviderModelSlice.java
@@ -16,10 +16,10 @@
package com.android.settings.network;
-
import static android.app.slice.Slice.EXTRA_TOGGLE_STATE;
import static com.android.settings.slices.CustomSliceRegistry.PROVIDER_MODEL_SLICE_URI;
+import static com.android.settings.slices.CustomSliceRegistry.WIFI_SLICE_URI;
import android.annotation.ColorInt;
import android.app.AlertDialog;
@@ -96,78 +96,77 @@ public class ProviderModelSlice extends WifiSlice {
@Override
public Slice getSlice() {
// The provider model slice step:
- // First section: Add a Wi-Fi item which state is connected.
- // 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.
- @InternetUpdater.InternetType int internetType = getInternetType();
+ // First section: Add the Ethernet item.
+ // Second section: Add the carrier item.
+ // Third section: Add the Wi-Fi toggle item.
+ // Fourth section: Add the connected Wi-Fi item.
+ // Fifth section: Add the Wi-Fi items which are not connected.
+ // Sixth section: Add the See All item.
final ListBuilder listBuilder = mHelper.createListBuilder(getUri());
- if (mHelper.isAirplaneModeEnabled() && !mWifiManager.isWifiEnabled()
- && internetType != InternetUpdater.INTERNET_ETHERNET) {
- log("Airplane mode is enabled.");
- return listBuilder.build();
- }
-
int maxListSize = 0;
- List wifiList = null;
final NetworkProviderWorker worker = getWorker();
if (worker != null) {
- // get Wi-Fi list.
- wifiList = worker.getResults();
maxListSize = worker.getApRowCount();
} else {
log("network provider worker is null.");
}
- final boolean hasCarrier = mHelper.hasCarrier();
- log("hasCarrier: " + hasCarrier);
-
- // First section: Add a Ethernet or Wi-Fi item which state is connected.
- boolean isConnectedWifiAddedTop = false;
- final WifiSliceItem connectedWifiItem = mHelper.getConnectedWifiItem(wifiList);
- if (internetType == InternetUpdater.INTERNET_ETHERNET) {
+ // First section: Add the Ethernet item.
+ if (getInternetType() == InternetUpdater.INTERNET_ETHERNET) {
log("get Ethernet item which is connected");
listBuilder.addRow(createEthernetRow());
maxListSize--;
- } else {
- if (connectedWifiItem != null && internetType == InternetUpdater.INTERNET_WIFI) {
- log("get Wi-Fi item which is connected to internet");
- listBuilder.addRow(getWifiSliceItemRow(connectedWifiItem));
- isConnectedWifiAddedTop = true;
+ }
+
+ // Second section: Add the carrier item.
+ if (!mHelper.isAirplaneModeEnabled()) {
+ final boolean hasCarrier = mHelper.hasCarrier();
+ log("hasCarrier: " + hasCarrier);
+ if (hasCarrier) {
+ mHelper.updateTelephony();
+ listBuilder.addRow(
+ mHelper.createCarrierRow(
+ worker != null ? worker.getNetworkTypeDescription() : ""));
maxListSize--;
}
}
- // Second section: Add a carrier item.
- if (hasCarrier) {
- mHelper.updateTelephony();
- listBuilder.addRow(
- mHelper.createCarrierRow(
- worker != null ? worker.getNetworkTypeDescription() : ""));
- maxListSize--;
+ // Third section: Add the Wi-Fi toggle item.
+ final boolean isWifiEnabled = mWifiManager.isWifiEnabled();
+ listBuilder.addRow(createWifiToggleRow(mContext, isWifiEnabled));
+ maxListSize--;
+ if (!isWifiEnabled) {
+ log("Wi-Fi is disabled");
+ return listBuilder.build();
+ }
+ List wifiList = (worker != null) ? worker.getResults() : null;
+ if (wifiList == null || wifiList.size() <= 0) {
+ log("Wi-Fi list is empty");
+ return listBuilder.build();
}
- // Third section: Add the connected Wi-Fi item to Wi-Fi list if the Ethernet is connected.
- if (connectedWifiItem != null && !isConnectedWifiAddedTop) {
+ // Fourth section: Add the connected Wi-Fi item.
+ final WifiSliceItem connectedWifiItem = mHelper.getConnectedWifiItem(wifiList);
+ if (connectedWifiItem != null) {
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());
-
- final List disconnectedWifiList = wifiList.stream()
- .filter(wifiSliceItem -> wifiSliceItem.getConnectedState()
- != WifiEntry.CONNECTED_STATE_CONNECTED)
- .limit(maxListSize - 1)
- .collect(Collectors.toList());
- for (WifiSliceItem item : disconnectedWifiList) {
- listBuilder.addRow(getWifiSliceItemRow(item));
- }
- listBuilder.addRow(getSeeAllRow());
+ // Fifth section: Add the Wi-Fi items which are not connected.
+ log("get Wi-Fi items which are not connected. Wi-Fi items : " + wifiList.size());
+ final List disconnectedWifiList = wifiList.stream()
+ .filter(item -> item.getConnectedState() != WifiEntry.CONNECTED_STATE_CONNECTED)
+ .limit(maxListSize - 1)
+ .collect(Collectors.toList());
+ for (WifiSliceItem item : disconnectedWifiList) {
+ listBuilder.addRow(getWifiSliceItemRow(item));
}
+
+ // Sixth section: Add the See All item.
+ log("add See-All");
+ listBuilder.addRow(getSeeAllRow());
+
return listBuilder.build();
}
@@ -324,6 +323,26 @@ public class ProviderModelSlice extends WifiSlice {
.setSubtitle(mContext.getText(R.string.to_switch_networks_disconnect_ethernet));
}
+ /**
+ * @return a {@link ListBuilder.RowBuilder} of the Wi-Fi toggle.
+ */
+ protected ListBuilder.RowBuilder createWifiToggleRow(Context context, boolean isWifiEnabled) {
+ final Intent intent = new Intent(WIFI_SLICE_URI.toString())
+ .setData(WIFI_SLICE_URI)
+ .setClass(context, SliceBroadcastReceiver.class)
+ .putExtra(EXTRA_TOGGLE_STATE, !isWifiEnabled)
+ // The FLAG_RECEIVER_FOREGROUND flag is necessary to avoid the intent delay of
+ // the first sending after the device restarts
+ .addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
+ final PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent,
+ PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
+ final SliceAction toggleSliceAction = SliceAction.createToggle(pendingIntent,
+ null /* actionTitle */, isWifiEnabled);
+ return new ListBuilder.RowBuilder()
+ .setTitle(context.getString(R.string.wifi_settings))
+ .setPrimaryAction(toggleSliceAction);
+ }
+
protected ListBuilder.RowBuilder getSeeAllRow() {
final CharSequence title = mContext.getText(R.string.previous_connected_see_all);
final IconCompat icon = getSeeAllIcon();
diff --git a/src/com/android/settings/network/telephony/NetworkProviderWorker.java b/src/com/android/settings/network/telephony/NetworkProviderWorker.java
index 675d60fb94c..a6b438a93e2 100644
--- a/src/com/android/settings/network/telephony/NetworkProviderWorker.java
+++ b/src/com/android/settings/network/telephony/NetworkProviderWorker.java
@@ -54,7 +54,7 @@ public class NetworkProviderWorker extends WifiScanWorker implements
DataConnectivityListener.Client, InternetUpdater.InternetChangeListener,
SubscriptionsChangeListener.SubscriptionsChangeListenerClient {
private static final String TAG = "NetworkProviderWorker";
- private static final int PROVIDER_MODEL_DEFAULT_EXPANDED_ROW_COUNT = 5;
+ private static final int PROVIDER_MODEL_DEFAULT_EXPANDED_ROW_COUNT = 6;
private DataContentObserver mMobileDataObserver;
private SignalStrengthListener mSignalStrengthListener;
private SubscriptionsChangeListener mSubscriptionsListener;
diff --git a/src/com/android/settings/panel/InternetConnectivityPanel.java b/src/com/android/settings/panel/InternetConnectivityPanel.java
index 53c0f20ad19..ae6f2e0f59e 100644
--- a/src/com/android/settings/panel/InternetConnectivityPanel.java
+++ b/src/com/android/settings/panel/InternetConnectivityPanel.java
@@ -39,7 +39,6 @@ import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
-import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;
@@ -236,29 +235,17 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
@Override
public Intent getSeeMoreIntent() {
+ // Disable the see more button for provider model design.
+ if (mIsProviderModelEnabled) {
+ return null;
+ }
+
// Don't remove the see more intent for non-provider model design. This intent will be
// used when isCustomizedButtonUsed() returns false.
return new Intent(Settings.ACTION_WIRELESS_SETTINGS)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
- @Override
- public boolean isCustomizedButtonUsed() {
- return mIsProviderModelEnabled;
- }
-
- @Override
- public CharSequence getCustomizedButtonTitle() {
- return mContext.getText(
- mInternetUpdater.isWifiEnabled() ? R.string.turn_off_wifi : R.string.turn_on_wifi);
- }
-
- @Override
- public void onClickCustomizedButton(FragmentActivity panelActivity) {
- // Don't finish the panel activity
- mWifiManager.setWifiEnabled(!mInternetUpdater.isWifiEnabled());
- }
-
@Override
public boolean isProgressBarVisible() {
return mIsProgressBarVisible;
@@ -320,7 +307,6 @@ public class InternetConnectivityPanel implements PanelContent, LifecycleObserve
}
updateSubtitleText();
mCallback.onHeaderChanged();
- mCallback.onCustomizedButtonStateChanged();
}
@VisibleForTesting
diff --git a/src/com/android/settings/password/SetupChooseLockGeneric.java b/src/com/android/settings/password/SetupChooseLockGeneric.java
index 15a90e3fdbf..3261b81083b 100644
--- a/src/com/android/settings/password/SetupChooseLockGeneric.java
+++ b/src/com/android/settings/password/SetupChooseLockGeneric.java
@@ -23,7 +23,6 @@ import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_R
import android.content.Context;
import android.content.Intent;
-import android.content.res.Resources;
import android.os.Bundle;
import android.os.IBinder;
import android.os.UserHandle;
@@ -43,6 +42,7 @@ import com.android.settings.SetupWizardUtils;
import com.android.settings.utils.SettingsDividerItemDecoration;
import com.google.android.setupdesign.GlifPreferenceLayout;
+import com.google.android.setupdesign.util.ThemeHelper;
/**
* Setup Wizard's version of ChooseLockGeneric screen. It inherits the logic and basic structure
@@ -66,14 +66,10 @@ public class SetupChooseLockGeneric extends ChooseLockGeneric {
return SetupChooseLockGenericFragment.class;
}
- @Override
- protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
- final int new_resid = SetupWizardUtils.getTheme(this, getIntent());
- super.onApplyThemeResource(theme, new_resid, first);
- }
-
@Override
protected void onCreate(Bundle savedInstance) {
+ setTheme(SetupWizardUtils.getTheme(this, getIntent()));
+ ThemeHelper.trySetDynamicColor(this);
super.onCreate(savedInstance);
if(getIntent().hasExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY)) {
@@ -92,6 +88,12 @@ public class SetupChooseLockGeneric extends ChooseLockGeneric {
findViewById(R.id.content_parent).setFitsSystemWindows(false);
}
+ @Override
+ protected boolean isToolbarEnabled() {
+ // Hide the action bar from this page.
+ return false;
+ }
+
public static class SetupChooseLockGenericFragment extends ChooseLockGenericFragment {
public static final String EXTRA_PASSWORD_QUALITY = ":settings:password_quality";
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityButtonFooterPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityButtonFooterPreferenceControllerTest.java
new file mode 100644
index 00000000000..33c57625860
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityButtonFooterPreferenceControllerTest.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2021 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.accessibility;
+
+import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
+import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.res.Resources;
+
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.R;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+import org.robolectric.RobolectricTestRunner;
+
+/** Tests for {@link AccessibilityButtonFooterPreferenceController}. */
+@RunWith(RobolectricTestRunner.class)
+public class AccessibilityButtonFooterPreferenceControllerTest {
+
+ @Rule
+ public final MockitoRule mockito = MockitoJUnit.rule();
+
+ @Spy
+ private final Context mContext = ApplicationProvider.getApplicationContext();
+ @Spy
+ private final Resources mResources = mContext.getResources();
+ private AccessibilityButtonFooterPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ mController = new AccessibilityButtonFooterPreferenceController(mContext,
+ "test_key");
+ when(mContext.getResources()).thenReturn(mResources);
+ }
+
+ @Test
+ public void getSummary_navigationGestureEnabled_shouldReturnButtonAndGestureSummary() {
+ when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
+ .thenReturn(NAV_BAR_MODE_GESTURAL);
+
+ assertThat(mController.getSummary()).isEqualTo(
+ mContext.getText(R.string.accessibility_button_gesture_description));
+ }
+
+ @Test
+ public void getSummary_navigationGestureDisabled_shouldReturnButtonSummary() {
+ when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
+ .thenReturn(NAV_BAR_MODE_2BUTTON);
+
+ assertThat(mController.getSummary()).isEqualTo(
+ mContext.getText(R.string.accessibility_button_description));
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/accessibility/AnimatedImagePreferenceTest.java b/tests/robotests/src/com/android/settings/accessibility/AnimatedImagePreferenceTest.java
index 4bce0bb264b..c7e5b13be83 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AnimatedImagePreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AnimatedImagePreferenceTest.java
@@ -32,8 +32,7 @@ import android.graphics.drawable.AnimatedImageDrawable;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.AnimationDrawable;
import android.net.Uri;
-import android.view.LayoutInflater;
-import android.view.View;
+import android.view.ViewGroup;
import android.widget.ImageView;
import androidx.preference.PreferenceViewHolder;
@@ -45,6 +44,7 @@ import com.airbnb.lottie.LottieAnimationView;
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;
@@ -57,10 +57,12 @@ import java.io.InputStream;
public class AnimatedImagePreferenceTest {
private final Context mContext = RuntimeEnvironment.application;
private Uri mImageUri;
- private View mRootView;
private PreferenceViewHolder mViewHolder;
private AnimatedImagePreference mAnimatedImagePreference;
+ @Mock
+ private ViewGroup mRootView;
+
@Spy
private ImageView mImageView;
@@ -68,9 +70,8 @@ public class AnimatedImagePreferenceTest {
public void init() {
MockitoAnnotations.initMocks(this);
- final LayoutInflater inflater = LayoutInflater.from(mContext);
- mRootView = spy(inflater.inflate(R.layout.preference_animated_image, /* root= */ null));
mViewHolder = spy(PreferenceViewHolder.createInstanceForTests(mRootView));
+ doReturn(new LottieAnimationView(mContext)).when(mRootView).findViewById(R.id.lottie_view);
mImageView = spy(new ImageView(mContext));
mAnimatedImagePreference = new AnimatedImagePreference(mContext);
diff --git a/tests/robotests/src/com/android/settings/network/NetworkProviderSettingsTest.java b/tests/robotests/src/com/android/settings/network/NetworkProviderSettingsTest.java
index 7affe68ab99..99514497eb4 100644
--- a/tests/robotests/src/com/android/settings/network/NetworkProviderSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/network/NetworkProviderSettingsTest.java
@@ -535,4 +535,32 @@ public class NetworkProviderSettingsTest {
assertThat(p instanceof NetworkProviderSettings.FirstWifiEntryPreference).isTrue();
}
+
+ @Test
+ public void updateWifiEntryPreferences_activityIsNull_ShouldNotCrash() {
+ when(mNetworkProviderSettings.getActivity()).thenReturn(null);
+
+ // should not crash
+ mNetworkProviderSettings.updateWifiEntryPreferences();
+ }
+
+ @Test
+ public void updateWifiEntryPreferences_viewIsNull_ShouldNotCrash() {
+ final FragmentActivity activity = mock(FragmentActivity.class);
+ when(mNetworkProviderSettings.getActivity()).thenReturn(activity);
+ when(mNetworkProviderSettings.getView()).thenReturn(null);
+
+ // should not crash
+ mNetworkProviderSettings.updateWifiEntryPreferences();
+ }
+
+ @Test
+ public void updateWifiEntryPreferences_isRestricted_bypassUpdate() {
+ mNetworkProviderSettings.mIsRestricted = true;
+ mNetworkProviderSettings.mWifiEntryPreferenceCategory = mock(PreferenceCategory.class);
+
+ mNetworkProviderSettings.updateWifiEntryPreferences();
+
+ verify(mNetworkProviderSettings.mWifiEntryPreferenceCategory, never()).setVisible(true);
+ }
}
diff --git a/tests/unit/src/com/android/settings/network/InternetUpdaterTest.java b/tests/unit/src/com/android/settings/network/InternetUpdaterTest.java
index 5ab2ce06aa3..c54c3eec36a 100644
--- a/tests/unit/src/com/android/settings/network/InternetUpdaterTest.java
+++ b/tests/unit/src/com/android/settings/network/InternetUpdaterTest.java
@@ -39,6 +39,7 @@ import android.content.Context;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkCapabilities;
+import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import androidx.lifecycle.Lifecycle;
@@ -194,4 +195,17 @@ public class InternetUpdaterTest {
assertThat(mInternetUpdater.getInternetType()).isEqualTo(INTERNET_ETHERNET);
}
+
+ @Test
+ public void updateInternetType_carrierWifiConnected_getInternetCellular() {
+ final WifiInfo wifiInfo = mock(WifiInfo.class);
+ doReturn(wifiInfo).when(mWifiManager).getConnectionInfo();
+ doReturn(true).when(wifiInfo).isCarrierMerged();
+ mInternetUpdater.mInternetAvailable = true;
+ mInternetUpdater.mTransport = TRANSPORT_WIFI;
+
+ mInternetUpdater.updateInternetType();
+
+ assertThat(mInternetUpdater.getInternetType()).isEqualTo(INTERNET_CELLULAR);
+ }
}
diff --git a/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java b/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java
index 722e305197d..66247d3623e 100644
--- a/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java
+++ b/tests/unit/src/com/android/settings/network/ProviderModelSliceTest.java
@@ -46,6 +46,8 @@ import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import androidx.slice.Slice;
+import androidx.slice.SliceItem;
+import androidx.slice.SliceMetadata;
import androidx.slice.SliceProvider;
import androidx.slice.builders.ListBuilder;
import androidx.slice.builders.SliceAction;
@@ -104,8 +106,6 @@ public class ProviderModelSliceTest {
ListBuilder.RowBuilder mMockCarrierRowBuild;
@Mock
WifiPickerTracker mWifiPickerTracker;
- @Mock
- WifiSliceItem mWifiSliceItem;
AlertDialog mMockAlertDialog;
private FakeFeatureFactory mFeatureFactory;
@@ -127,7 +127,7 @@ public class ProviderModelSliceTest {
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mTelephonyManager);
when(mContext.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
-
+ when(mWifiManager.isWifiEnabled()).thenReturn(true);
// Set-up specs for SliceMetadata.
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
@@ -192,7 +192,24 @@ public class ProviderModelSliceTest {
@Test
@UiThreadTest
- public void getSlice_haveTwoWifiAndOneCarrier_getCarrierAndTwoWiFiAndSeeAll() {
+ public void getSlice_airplaneModeIsOn_oneWifiToggle() {
+ mWifiList.clear();
+ mMockNetworkProviderWorker.updateSelfResults(null);
+ mockHelperCondition(true, false, false, null);
+
+ final Slice slice = mMockProviderModelSlice.getSlice();
+
+ assertThat(slice).isNotNull();
+ verify(mListBuilder, times(1)).addRow(any(ListBuilder.RowBuilder.class));
+ final SliceItem sliceTitle =
+ SliceMetadata.from(mContext, slice).getListContent().getHeader().getTitleItem();
+ assertThat(sliceTitle.getText()).isEqualTo(
+ ResourcesUtils.getResourcesString(mContext, "wifi_settings"));
+ }
+
+ @Test
+ @UiThreadTest
+ public void getSlice_haveTwoWifiAndOneCarrier_getFiveRow() {
mWifiList.clear();
mockWifiItemCondition(mMockWifiSliceItem1, "wifi1", "wifi1",
WifiEntry.CONNECTED_STATE_CONNECTED, "wifi1_key", true);
@@ -207,13 +224,13 @@ public class ProviderModelSliceTest {
assertThat(slice).isNotNull();
verify(mListBuilder, times(1)).addRow(mMockCarrierRowBuild);
- verify(mListBuilder, times(4)).addRow(any(ListBuilder.RowBuilder.class));
+ verify(mListBuilder, times(5)).addRow(any(ListBuilder.RowBuilder.class));
assertThat(mMockProviderModelSlice.hasSeeAllRow()).isTrue();
}
@Test
@UiThreadTest
- public void getSlice_haveOneConnectedWifiAndTwoDisconnectedWifiAndNoCarrier_getFourRow() {
+ public void getSlice_haveOneConnectedWifiAndTwoDisconnectedWifiAndNoCarrier_getFiveRow() {
mWifiList.clear();
mockWifiItemCondition(mMockWifiSliceItem1, "wifi1", "wifi1",
WifiEntry.CONNECTED_STATE_CONNECTED, "wifi1_key", true);
@@ -230,13 +247,13 @@ public class ProviderModelSliceTest {
final Slice slice = mMockProviderModelSlice.getSlice();
assertThat(slice).isNotNull();
- verify(mListBuilder, times(4)).addRow(any(ListBuilder.RowBuilder.class));
+ verify(mListBuilder, times(5)).addRow(any(ListBuilder.RowBuilder.class));
assertThat(mMockProviderModelSlice.hasSeeAllRow()).isTrue();
}
@Test
@UiThreadTest
- public void getSlice_haveTwoDisconnectedWifiAndNoCarrier_getThreeRow() {
+ public void getSlice_haveTwoDisconnectedWifiAndNoCarrier_getFourRow() {
mWifiList.clear();
mockWifiItemCondition(mMockWifiSliceItem1, "wifi1", "wifi1",
WifiEntry.CONNECTED_STATE_DISCONNECTED, "wifi1_key", true);
@@ -250,13 +267,13 @@ public class ProviderModelSliceTest {
final Slice slice = mMockProviderModelSlice.getSlice();
assertThat(slice).isNotNull();
- verify(mListBuilder, times(3)).addRow(any(ListBuilder.RowBuilder.class));
+ verify(mListBuilder, times(4)).addRow(any(ListBuilder.RowBuilder.class));
assertThat(mMockProviderModelSlice.hasSeeAllRow()).isTrue();
}
@Test
@UiThreadTest
- public void getSlice_haveEthernetAndCarrierAndTwoDisconnectedWifi_getFiveRow() {
+ public void getSlice_haveEthernetAndCarrierAndTwoDisconnectedWifi_getSixRow() {
mWifiList.clear();
mockWifiItemCondition(mMockWifiSliceItem1, "wifi1", "wifi1",
WifiEntry.CONNECTED_STATE_DISCONNECTED, "wifi1_key", true);
@@ -274,13 +291,13 @@ public class ProviderModelSliceTest {
assertThat(slice).isNotNull();
assertThat(mMockProviderModelSlice.hasCreateEthernetRow()).isTrue();
verify(mListBuilder, times(1)).addRow(mMockCarrierRowBuild);
- verify(mListBuilder, times(5)).addRow(any(ListBuilder.RowBuilder.class));
+ verify(mListBuilder, times(6)).addRow(any(ListBuilder.RowBuilder.class));
assertThat(mMockProviderModelSlice.hasSeeAllRow()).isTrue();
}
@Test
@UiThreadTest
- public void getSlice_haveEthernetAndCarrierAndConnectedWifiAndDisconnectedWifi_getFiveRow() {
+ public void getSlice_haveEthernetAndCarrierAndConnectedWifiAndDisconnectedWifi_getSixRow() {
mWifiList.clear();
mockWifiItemCondition(mMockWifiSliceItem1, "wifi1", "wifi1",
WifiEntry.CONNECTED_STATE_CONNECTED, "wifi1_key", true);
@@ -298,7 +315,7 @@ public class ProviderModelSliceTest {
assertThat(slice).isNotNull();
assertThat(mMockProviderModelSlice.hasCreateEthernetRow()).isTrue();
verify(mListBuilder, times(1)).addRow(mMockCarrierRowBuild);
- verify(mListBuilder, times(5)).addRow(any(ListBuilder.RowBuilder.class));
+ verify(mListBuilder, times(6)).addRow(any(ListBuilder.RowBuilder.class));
assertThat(mMockProviderModelSlice.hasSeeAllRow()).isTrue();
}
@@ -396,6 +413,11 @@ public class ProviderModelSliceTest {
return super.getSeeAllRow();
}
+ @Override
+ public ListBuilder.RowBuilder getWifiSliceItemRow(WifiSliceItem wifiSliceItem) {
+ return super.getWifiSliceItemRow(wifiSliceItem);
+ }
+
public boolean hasCreateEthernetRow() {
return mHasCreateEthernetRow;
}
diff --git a/tests/unit/src/com/android/settings/panel/InternetConnectivityPanelTest.java b/tests/unit/src/com/android/settings/panel/InternetConnectivityPanelTest.java
index c13d368d2f7..30a272950f5 100644
--- a/tests/unit/src/com/android/settings/panel/InternetConnectivityPanelTest.java
+++ b/tests/unit/src/com/android/settings/panel/InternetConnectivityPanelTest.java
@@ -21,7 +21,6 @@ import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -32,7 +31,6 @@ import android.net.wifi.ScanResult;
import android.net.wifi.WifiManager;
import android.os.Handler;
-import androidx.fragment.app.FragmentActivity;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -89,8 +87,6 @@ public class InternetConnectivityPanelTest {
private WifiManager mWifiManager;
@Mock
private ProviderModelSliceHelper mProviderModelSliceHelper;
- @Mock
- private FragmentActivity mPanelActivity;
private Context mContext;
private FakeHandlerInjector mFakeHandlerInjector;
@@ -222,20 +218,6 @@ public class InternetConnectivityPanelTest {
assertThat(mPanel.getSubTitle()).isEqualTo(SUBTITLE_TEXT_TAP_A_NETWORK_TO_CONNECT);
}
- @Test
- public void getCustomizedButtonTitle_wifiOff_turnOnWifi() {
- doReturn(false).when(mInternetUpdater).isWifiEnabled();
-
- assertThat(mPanel.getCustomizedButtonTitle()).isEqualTo(BUTTON_TURN_ON_WIFI);
- }
-
- @Test
- public void getCustomizedButtonTitle_wifiOn_turnOffWifi() {
- doReturn(true).when(mInternetUpdater).isWifiEnabled();
-
- assertThat(mPanel.getCustomizedButtonTitle()).isEqualTo(BUTTON_TURN_OFF_WIFI);
- }
-
@Test
public void getSlices_providerModelDisabled_containsNecessarySlices() {
mPanel.mIsProviderModelEnabled = false;
@@ -255,33 +237,17 @@ public class InternetConnectivityPanelTest {
}
@Test
- public void getSeeMoreIntent_shouldNotNull() {
+ public void getSeeMoreIntent_providerModelDisabled_shouldNotNull() {
+ mPanel.mIsProviderModelEnabled = false;
+
assertThat(mPanel.getSeeMoreIntent()).isNotNull();
}
@Test
- public void onClickCustomizedButton_wifiOn_setWifiOff() {
- doReturn(true).when(mInternetUpdater).isWifiEnabled();
+ public void getSeeMoreIntent_providerModelEnabled_shouldBeNull() {
+ mPanel.mIsProviderModelEnabled = true;
- mPanel.onClickCustomizedButton(mPanelActivity);
-
- verify(mWifiManager).setWifiEnabled(false);
- }
-
- @Test
- public void onClickCustomizedButton_wifiOff_setWifiOn() {
- doReturn(false).when(mInternetUpdater).isWifiEnabled();
-
- mPanel.onClickCustomizedButton(mPanelActivity);
-
- verify(mWifiManager).setWifiEnabled(true);
- }
-
- @Test
- public void onClickCustomizedButton_shouldNotFinishActivity() {
- mPanel.onClickCustomizedButton(mPanelActivity);
-
- verify(mPanelActivity, never()).finish();
+ assertThat(mPanel.getSeeMoreIntent()).isNull();
}
@Test
@@ -293,26 +259,6 @@ public class InternetConnectivityPanelTest {
verify(mPanelContentCallback).onHeaderChanged();
}
- @Test
- public void onWifiEnabledChanged_wifiOff_onCustomizedButtonStateChanged() {
- doReturn(false).when(mInternetUpdater).isWifiEnabled();
- clearInvocations(mPanelContentCallback);
-
- mPanel.onWifiEnabledChanged(false);
-
- verify(mPanelContentCallback).onCustomizedButtonStateChanged();
- }
-
- @Test
- public void onWifiEnabledChanged_wifiOn_onCustomizedButtonStateChanged() {
- doReturn(true).when(mInternetUpdater).isWifiEnabled();
- clearInvocations(mPanelContentCallback);
-
- mPanel.onWifiEnabledChanged(true);
-
- verify(mPanelContentCallback).onCustomizedButtonStateChanged();
- }
-
@Test
public void updateProgressBar_wifiDisabled_hideProgress() {
mPanel.mIsProgressBarVisible = true;