Merge "Update dependent logic in modes vis page" into main
diff --git a/res/values/strings.xml b/res/values/strings.xml
index fb6a3c1..d752338 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2291,6 +2291,10 @@
<string name="wifi_dpp_failure_enrollee_rejected_configuration">Contact the device manufacturer</string>
<!-- Hint for Wi-Fi connection fail [CHAR LIMIT=NONE] -->
<string name="wifi_dpp_check_connection_try_again">Check connection and try again</string>
+ <!-- Hint for Wi-Fi connection fail [CHAR LIMIT=NONE] -->
+ <string name="wifi_dpp_check_connection_no_matched_ssid">This Wi\u2011Fi network isn\u2019t available right now</string>
+ <!-- Hint for Wi-Fi connection fail [CHAR LIMIT=NONE] -->
+ <string name="wifi_dpp_check_connection_no_matched_security">There\u2019s a problem with this QR code. Try connecting another way.</string>
<!-- Title for the fragment choose network [CHAR LIMIT=50] -->
<string name="wifi_dpp_choose_network">Choose network</string>
<!-- Hint for the user to center another device's QR code in the below camera window [CHAR LIMIT=NONE] -->
diff --git a/src/com/android/settings/datausage/AppDataUsagePreference.java b/src/com/android/settings/datausage/AppDataUsagePreference.java
index d8c7392..277c9b3 100644
--- a/src/com/android/settings/datausage/AppDataUsagePreference.java
+++ b/src/com/android/settings/datausage/AppDataUsagePreference.java
@@ -38,6 +38,7 @@
public AppDataUsagePreference(Context context, AppItem item, int percent,
UidDetailProvider provider) {
super(context);
+ setLayoutResource(R.layout.preference_process_stats);
setKey("app_data_usage_" + item.key);
mItem = item;
mPercent = percent;
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index a0137df..3188240 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -1834,6 +1834,24 @@
MultiUserSwitchBarController.class.getName();
rawData.add(allowMultipleUsersResult);
+
+ SearchIndexableRaw addUserData = new SearchIndexableRaw(context);
+ addUserData.key = KEY_ADD_USER;
+
+ // Dynamically set the title of addUser preference
+ final UserCapabilities userCaps = UserCapabilities.create(context);
+ if (!userCaps.mCanAddRestrictedProfile) {
+ addUserData.title = context.getString(
+ com.android.settingslib.R.string.user_add_user);
+ } else {
+ addUserData.title = context.getString(
+ R.string.user_add_user_or_profile_menu);
+ }
+ addUserData.screenTitle = context.getString(R.string.user_settings_title);
+ addUserData.iconResId = R.drawable.ic_add_40dp;
+
+ rawData.add(addUserData);
+
return rawData;
}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java b/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java
index 34948dc..97e41b4 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java
@@ -16,6 +16,7 @@
package com.android.settings.wifi.dpp;
+import static android.content.res.Resources.ID_NULL;
import static android.net.wifi.WifiInfo.sanitizeSsid;
import android.app.Activity;
@@ -101,6 +102,8 @@
// Interval between initiating WifiPickerTracker scans.
private static final long SCAN_INTERVAL_MILLIS = 10_000;
+ private static final @StringRes int REACHABLE_WIFI_NETWORK = ID_NULL;
+
private QrCamera mCamera;
private TextureView mTextureView;
private QrDecorateView mDecorateView;
@@ -201,8 +204,9 @@
wifiManager.enableNetwork(id, /* attemptConnect */ false);
// WifiTracker only contains a hidden SSID Wi-Fi network if it's saved.
// We can't check if a hidden SSID Wi-Fi network is reachable in advance.
- if (qrCodeWifiConfiguration.hiddenSSID
- || isReachableWifiNetwork(qrCodeWifiConfiguration)) {
+ @StringRes int wifiReachabilityStringId =
+ getWifiReachabilityStringId(qrCodeWifiConfiguration);
+ if (wifiReachabilityStringId == REACHABLE_WIFI_NETWORK) {
hasHiddenOrReachableWifiNetwork = true;
mEnrolleeWifiConfiguration = qrCodeWifiConfiguration;
wifiManager.connect(id,
@@ -210,8 +214,7 @@
}
if (!hasHiddenOrReachableWifiNetwork) {
- showErrorMessageAndRestartCamera(
- R.string.wifi_dpp_check_connection_try_again);
+ showErrorMessageAndRestartCamera(wifiReachabilityStringId);
return;
}
@@ -242,7 +245,10 @@
WifiDppUtils.triggerVibrationForQrCodeRecognition(getContext());
}
- private boolean isReachableWifiNetwork(WifiConfiguration wifiConfiguration) {
+ private @StringRes int getWifiReachabilityStringId(WifiConfiguration wifiConfiguration) {
+ if (wifiConfiguration.hiddenSSID) {
+ return REACHABLE_WIFI_NETWORK;
+ }
final List<WifiEntry> wifiEntries = mWifiPickerTracker.getWifiEntries();
final WifiEntry connectedWifiEntry = mWifiPickerTracker.getConnectedWifiEntry();
if (connectedWifiEntry != null) {
@@ -250,24 +256,29 @@
wifiEntries.add(connectedWifiEntry);
}
+ boolean canFindNetwork = false;
for (WifiEntry wifiEntry : wifiEntries) {
if (!TextUtils.equals(wifiEntry.getSsid(), sanitizeSsid(wifiConfiguration.SSID))) {
continue;
}
+ canFindNetwork = true;
final int security =
WifiDppUtils.getSecurityTypeFromWifiConfiguration(wifiConfiguration);
if (security == wifiEntry.getSecurity()) {
- return true;
+ return REACHABLE_WIFI_NETWORK;
}
// Default security type of PSK/SAE transition mode WifiEntry is SECURITY_PSK and
// there is no way to know if a WifiEntry is of transition mode. Give it a chance.
if (security == WifiEntry.SECURITY_SAE
&& wifiEntry.getSecurity() == WifiEntry.SECURITY_PSK) {
- return true;
+ return REACHABLE_WIFI_NETWORK;
}
}
- return false;
+ if (canFindNetwork) {
+ return R.string.wifi_dpp_check_connection_no_matched_security;
+ }
+ return R.string.wifi_dpp_check_connection_no_matched_ssid;
}
@VisibleForTesting
diff --git a/tests/robotests/src/com/android/settings/datausage/AppDataUsagePreferenceTest.java b/tests/robotests/src/com/android/settings/datausage/AppDataUsagePreferenceTest.java
index 7e6d314..f621cbf 100644
--- a/tests/robotests/src/com/android/settings/datausage/AppDataUsagePreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/AppDataUsagePreferenceTest.java
@@ -91,7 +91,7 @@
mPreference = new AppDataUsagePreference(RuntimeEnvironment.application, mAppItem,
50 /* percent */, mUidDetailProvider);
final View view = LayoutInflater.from(RuntimeEnvironment.application).inflate(
- com.android.settingslib.widget.preference.app.R.layout.preference_app, null);
+ com.android.settings.R.layout.preference_process_stats, null);
final PreferenceViewHolder preferenceViewHolder =
PreferenceViewHolder.createInstanceForTests(view);
final ProgressBar progressBar = (ProgressBar) preferenceViewHolder.findViewById(
diff --git a/tests/robotests/src/com/android/settings/users/UserSettingsTest.java b/tests/robotests/src/com/android/settings/users/UserSettingsTest.java
index 85db0bd..754c429 100644
--- a/tests/robotests/src/com/android/settings/users/UserSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/users/UserSettingsTest.java
@@ -37,6 +37,7 @@
import static org.mockito.Mockito.when;
import static org.robolectric.Shadows.shadowOf;
+import android.app.admin.DevicePolicyManager;
import android.app.settings.SettingsEnums;
import android.content.ComponentName;
import android.content.Context;
@@ -112,6 +113,7 @@
private static final String KEY_USER_GUEST = "user_guest";
private static final String KEY_ALLOW_MULTIPLE_USERS = "allow_multiple_users";
private static final String KEY_USER_SETTINGS_SCREEN = "user_settings_screen";
+ private static final String KEY_ADD_USER = "user_add";
private static final int ACTIVE_USER_ID = 0;
private static final int INACTIVE_ADMIN_USER_ID = 1;
private static final int INACTIVE_SECONDARY_USER_ID = 14;
@@ -130,6 +132,8 @@
@Mock
private PreferenceManager mMockPreferenceManager;
@Mock
+ private DevicePolicyManager mDevicePolicyManager;
+ @Mock
private UserPreference mMePreference;
@Mock
private RestrictedPreference mAddUserPreference;
@@ -222,7 +226,7 @@
@Test
public void testGetRawDataToIndex_returnAllIndexablePreferences() {
- String[] expectedKeys = {KEY_ALLOW_MULTIPLE_USERS, KEY_USER_SETTINGS_SCREEN};
+ String[] expectedKeys = {KEY_ALLOW_MULTIPLE_USERS, KEY_USER_SETTINGS_SCREEN, KEY_ADD_USER};
List<String> keysResultList = new ArrayList<>();
ShadowUserManager.getShadow().setSupportsMultipleUsers(true);
List<SearchIndexableRaw> rawData =
@@ -236,6 +240,54 @@
}
@Test
+ public void testGetRawDataToIndex_addRestrictedProfileAllowed_addUserTitleIsCorrect() {
+ ShadowUserManager.getShadow().setSupportsMultipleUsers(true);
+ SettingsShadowResources.overrideResource(
+ com.android.settings.R.bool.config_offer_restricted_profiles,
+ Boolean.TRUE);
+ when(mUserManager.hasBaseUserRestriction(UserManager.DISALLOW_ADD_USER, mContext.getUser()))
+ .thenReturn(false);
+ ShadowUserManager.getShadow().setUserTypeEnabled(UserManager.USER_TYPE_FULL_RESTRICTED,
+ true);
+ when(mContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
+ .thenReturn(mDevicePolicyManager);
+ when(mDevicePolicyManager.isDeviceManaged()).thenReturn(false);
+
+ List<SearchIndexableRaw> rawData =
+ UserSettings.SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(mContext, true);
+
+ String title = null;
+ for (SearchIndexableRaw rawDataItem : rawData) {
+ if (rawDataItem.key.equals(KEY_ADD_USER)) {
+ title = rawDataItem.title;
+ }
+ }
+
+ assertThat(title).isEqualTo(mContext.getString(
+ com.android.settings.R.string.user_add_user_or_profile_menu));
+ }
+
+ @Test
+ public void testGetRawDataToIndex_addRestrictedProfileDisallowed_addUserTitleIsCorrect() {
+ ShadowUserManager.getShadow().setSupportsMultipleUsers(true);
+ SettingsShadowResources.overrideResource(
+ com.android.settings.R.bool.config_offer_restricted_profiles,
+ Boolean.FALSE);
+ List<SearchIndexableRaw> rawData =
+ UserSettings.SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(mContext, true);
+
+ String title = null;
+ for (SearchIndexableRaw rawDataItem : rawData) {
+ if (rawDataItem.key.equals(KEY_ADD_USER)) {
+ title = rawDataItem.title;
+ }
+ }
+
+ assertThat(title).isEqualTo(mContext.getString(
+ com.android.settingslib.R.string.user_add_user));
+ }
+
+ @Test
public void testAssignDefaultPhoto_hasDefaultUserIconSize() {
doReturn(mUserManager).when(mContext).getSystemService(Context.USER_SERVICE);
int size = 100;
diff --git a/tests/unit/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java b/tests/unit/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java
index 5f887de..1c51d1d 100644
--- a/tests/unit/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java
@@ -60,6 +60,7 @@
import com.android.settings.network.ims.MockWfcQueryImsState;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -396,6 +397,7 @@
}
@Test
+ @Ignore
public void getCurrentCarrierNameForDisplay_withoutSubId_returnNotNull() {
assertThat(MobileNetworkUtils.getCurrentCarrierNameForDisplay(
mContext)).isNotNull();