Merge "[Settings] BT and WiFi reset menu might covers VPN"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5494acf..fbae241 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -130,10 +130,30 @@
<string name="bluetooth_pair_other_ear_dialog_right_ear_positive_button">Pair right ear</string>
<!-- Connected devices settings. Positive button of the dialog to help user to pair left ear of the hearing aid device. Dialog shows when only one of the hearing aid device set is connected. [CHAR LIMIT=20] -->
<string name="bluetooth_pair_other_ear_dialog_left_ear_positive_button">Pair left ear</string>
-
+ <!-- Connected devices settings. Title of the preference to show the entrance of the hearing device controls page. [CHAR LIMIT=35] -->
+ <string name="bluetooth_device_controls_title">Hearing device controls</string>
+ <!-- Connected devices settings. Summary of the preference to show the entrance of the hearing device controls page. [CHAR LIMIT=NONE] -->
+ <string name="bluetooth_device_controls_summary">Hearing device shortcut, hearing aid compatibility</string>
+ <!-- Connected devices settings. Title of the preference to show the entrance of the audio output page. It can change different types of audio are played on phone or other bluetooth devices. [CHAR LIMIT=35] -->
+ <string name="bluetooth_audio_routing_title">Audio output</string>
+ <!-- Connected devices settings. Summary of the preference to show the entrance of the audio output page. [CHAR LIMIT=NONE] -->
+ <string name="bluetooth_audio_routing_summary">Choose whether different types of audio are played on your hearing device or phone speaker</string>
<!-- Title for related tools section. This section will list related tools below. [CHAR LIMIT=15] -->
<string name="bluetooth_screen_related">Related</string>
+ <!-- Bluetooth audio output settings. Title of the option managing ringtone audio path. [CHAR LIMIT=30] -->
+ <string name="bluetooth_ringtone_title">Ringtone</string>
+ <!-- Bluetooth audio output settings. Title of the option managing call audio path. [CHAR LIMIT=30] -->
+ <string name="bluetooth_call_title">Call</string>
+ <!-- Bluetooth audio output settings. Title of the option managing media audio path. [CHAR LIMIT=30] -->
+ <string name="bluetooth_media_title">Media</string>
+ <!-- Bluetooth audio output settings. Title of the option managing system sounds audio path. [CHAR LIMIT=30] -->
+ <string name="bluetooth_system_sounds_title">System sounds</string>
+ <!-- Bluetooth audio output settings. Title of the option to play audio on hearing aids. [CHAR LIMIT=40] -->
+ <string name="bluetooth_audio_path_hearing_device_title">Play on hearing device</string>
+ <!-- Bluetooth audio output settings. Title of the option to play audio on phone speaker. [CHAR LIMIT=40] -->
+ <string name="bluetooth_audio_path_phone_speaker_title">Play on phone speaker</string>
+
<!--Bluetooth settings screen, summary text for Bluetooth device with no name -->
<string name="bluetooth_device">Unnamed Bluetooth device</string>
<!--Bluetooth settings screen, text that appears in heading bar when scanning for devices -->
@@ -4221,8 +4241,8 @@
<!-- Button text for the accessibility dialog continue to the next screen for hearing aid. [CHAR LIMIT=32] -->
<string name="accessibility_hearingaid_instruction_continue_button">Continue</string>
- <!-- Title for the accessibility preference for hearing aid. [CHAR LIMIT=35] -->
- <string name="accessibility_hearingaid_title">Hearing aids</string>
+ <!-- Title for the accessibility preference for hearing devices. [CHAR LIMIT=35] -->
+ <string name="accessibility_hearingaid_title">Hearing devices</string>
<!-- Summary for the accessibility preference for hearing aid when not connected. [CHAR LIMIT=50] -->
<string name="accessibility_hearingaid_not_connected_summary">No hearing aids connected</string>
<!-- Summary for the accessibility preference for hearing aid when adding new devices. [CHAR LIMIT=50] -->
@@ -4241,6 +4261,29 @@
<string name="accessibility_hearingaid_left_and_right_side_device_summary"><xliff:g id="device_name" example="GN Hearing Aids">%1$s</xliff:g>, left and right</string>
<!-- Summary for the accessibility preference for hearing aid when there are more than one set of devices are active. [CHAR LIMIT=50] -->
<string name="accessibility_hearingaid_more_device_summary"><xliff:g id="device_name" example="GN Hearing Aids">%1$s</xliff:g> +1 more</string>
+ <!-- Title for the hearing device pairing preference. [CHAR LIMIT=20] -->
+ <string name="accessibility_hearing_device_pairing_title">Pair new device</string>
+ <!-- Title for the preference category containing the connected hearing device group. [CHAR LIMIT=20]-->
+ <string name="accessibility_hearing_device_saved_title">Saved devices</string>
+ <!-- Title for the preference category containing the controls of the hearing device. [CHAR LIMIT=35] -->
+ <string name="accessibility_hearing_device_control">Hearing device controls</string>
+ <!-- Title for the accessibility preference for hearing devices. [CHAR LIMIT=35] -->
+ <string name="accessibility_hearing_device_shortcut_title">Hearing device shortcut</string>
+ <!-- Title for the Hearing Aid Compatibility preference in the accessibility page. [CHAR LIMIT=35] -->
+ <string name="accessibility_hac_mode_title">Hearing aid compatibility</string>
+ <!--Summary for the Hearing Aid Compatibility preference in the accessibility page. [CHAR LIMIT=NONE] -->
+ <string name="accessibility_hac_mode_summary">Improve audio for some hearing devices</string>
+ <!-- Description for text in accessibility hearing aids footer. [CHAR LIMIT=NONE] -->
+ <string name="accessibility_hearing_device_footer_summary">Make sure your hearing devices are turned on and in pairing mode</string>
+ <!-- Title for the pair hearing device page. [CHAR LIMIT=25] -->
+ <string name="accessibility_hearing_device_pairing_page_title">Pair hearing device</string>
+ <!-- Title for the preference category containing the list of the available hearing during and after bluetooth scanning devices. [CHAR LIMIT=30] -->
+ <string name="accessibility_found_hearing_devices">Available devices</string>
+ <!-- Title for the preference category containing the all bluetooth devices during and after bluetooth scanning devices. Used when people can not find their hearing device in hearing device pairing list. [CHAR LIMIT=45] -->
+ <string name="accessibility_found_all_devices">Don\u2019t see your hearing device?</string>
+ <!-- Title for listing all bluetooth devices preference in the accessibility page. [CHAR LIMIT=40] -->
+ <string name="accessibility_list_all_devices_title">View all Bluetooth devices</string>
+
<!-- Title for the accessibility audio adjustment page. [CHAR LIMIT=50] -->
<string name="accessibility_audio_adjustment_title">Audio adjustment</string>
<!-- Title for control audio description preference. [CHAR LIMIT=50] -->
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index b66e2af..ac2b26b 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -590,6 +590,7 @@
}
private void onAddGuestClicked() {
+ Context context = getContext();
final UserCreatingDialog guestCreatingDialog =
new UserCreatingDialog(getActivity(), /* isGuest= */ true);
guestCreatingDialog.show();
@@ -597,18 +598,18 @@
ThreadUtils.postOnBackgroundThread(() -> {
mMetricsFeatureProvider.action(getActivity(), SettingsEnums.ACTION_USER_GUEST_ADD);
Trace.beginSection("UserSettings.addGuest");
- final UserInfo guest = mUserManager.createGuest(getContext());
+ final UserInfo guest = mUserManager.createGuest(context);
Trace.endSection();
ThreadUtils.postOnMainThread(() -> {
guestCreatingDialog.dismiss();
if (guest == null) {
- Toast.makeText(getContext(),
+ Toast.makeText(context,
com.android.settingslib.R.string.add_guest_failed,
Toast.LENGTH_SHORT).show();
return;
}
- openUserDetails(guest, true);
+ openUserDetails(guest, true, context);
});
});
}
@@ -622,14 +623,10 @@
}
}
- private void onUserCreated(UserInfo userInfo) {
+ private void onUserCreated(UserInfo userInfo, Context context) {
hideUserCreatingDialog();
- // prevent crash when config changes during user creation
- if (getContext() == null) {
- return;
- }
mAddingUser = false;
- openUserDetails(userInfo, true);
+ openUserDetails(userInfo, true, context);
}
private void hideUserCreatingDialog() {
@@ -646,11 +643,21 @@
}
private void openUserDetails(UserInfo userInfo, boolean newUser) {
+ openUserDetails(userInfo, newUser, getContext());
+ }
+
+ private void openUserDetails(UserInfo userInfo, boolean newUser, Context context) {
+ // to prevent a crash when config changes during user creation,
+ // we simply ignore this redirection step
+ if (context == null) {
+ return;
+ }
+
Bundle extras = new Bundle();
extras.putInt(UserDetailsSettings.EXTRA_USER_ID, userInfo.id);
extras.putBoolean(AppRestrictionsFragment.EXTRA_NEW_USER, newUser);
- SubSettingLauncher launcher = new SubSettingLauncher(getContext())
+ SubSettingLauncher launcher = new SubSettingLauncher(context)
.setDestination(UserDetailsSettings.class.getName())
.setArguments(extras)
.setTitleText(userInfo.name)
@@ -1013,6 +1020,9 @@
@VisibleForTesting
void createUser(final int userType, String userName) {
+ Context context = getContext();
+ Resources resources = getResources();
+ final Drawable selectedUserIcon = mPendingUserIcon;
Future<?> unusedCreateUserFuture = ThreadUtils.postOnBackgroundThread(() -> {
UserInfo user;
@@ -1035,19 +1045,19 @@
}
Future<?> unusedSettingIconFuture = ThreadUtils.postOnBackgroundThread(() -> {
- Drawable newUserIcon = mPendingUserIcon;
+ Drawable newUserIcon = selectedUserIcon;
if (newUserIcon == null) {
- newUserIcon = UserIcons.getDefaultUserIcon(getResources(), user.id, false);
+ newUserIcon = UserIcons.getDefaultUserIcon(resources, user.id, false);
}
mUserManager.setUserIcon(
user.id, UserIcons.convertToBitmapAtUserIconSize(
- getResources(), newUserIcon));
+ resources, newUserIcon));
});
mPendingUserIcon = null;
mPendingUserName = null;
- onUserCreated(user);
+ onUserCreated(user, context);
});
});
}
diff --git a/src/com/android/settings/wifi/NetworkRequestDialogFragment.java b/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
index 5fe156c..5639047 100644
--- a/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
+++ b/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
@@ -16,7 +16,7 @@
package com.android.settings.wifi;
-import static com.android.settings.wifi.WifiUtils.getWifiEntrySecurity;
+import static com.android.wifitrackerlib.Utils.getSecurityTypesFromScanResult;
import static java.util.stream.Collectors.toList;
@@ -77,8 +77,12 @@
private static final int MAX_NUMBER_LIST_ITEM = 5;
private boolean mShowLimitedItem = true;
+ private static class MatchWifi {
+ String mSsid;
+ List<Integer> mSecurityTypes;
+ }
+ private List<MatchWifi> mMatchWifis = new ArrayList<>();
@VisibleForTesting List<WifiEntry> mFilteredWifiEntries = new ArrayList<>();
- @VisibleForTesting List<ScanResult> mMatchedScanResults = new ArrayList<>();
private WifiEntryAdapter mDialogAdapter;
private NetworkRequestUserSelectionCallback mUserSelectionCallback;
@@ -237,7 +241,7 @@
/** Called when the state of Wifi has changed. */
@Override
public void onWifiStateChanged() {
- if (mMatchedScanResults.size() == 0) {
+ if (mMatchWifis.size() == 0) {
return;
}
updateWifiEntries();
@@ -249,7 +253,7 @@
*/
@Override
public void onWifiEntriesChanged() {
- if (mMatchedScanResults.size() == 0) {
+ if (mMatchWifis.size() == 0) {
return;
}
updateWifiEntries();
@@ -275,16 +279,24 @@
wifiEntries.addAll(mWifiPickerTracker.getWifiEntries());
mFilteredWifiEntries.clear();
- mFilteredWifiEntries.addAll(wifiEntries.stream().filter(entry -> {
- for (ScanResult matchedScanResult : mMatchedScanResults) {
- if (TextUtils.equals(entry.getSsid(), matchedScanResult.SSID)
- && entry.getSecurity() == getWifiEntrySecurity(matchedScanResult)) {
+ mFilteredWifiEntries.addAll(wifiEntries.stream()
+ .filter(entry -> isMatchedWifiEntry(entry))
+ .limit(mShowLimitedItem ? MAX_NUMBER_LIST_ITEM : Long.MAX_VALUE)
+ .collect(toList()));
+ }
+
+ private boolean isMatchedWifiEntry(WifiEntry entry) {
+ for (MatchWifi wifi : mMatchWifis) {
+ if (!TextUtils.equals(entry.getSsid(), wifi.mSsid)) {
+ continue;
+ }
+ for (Integer security : wifi.mSecurityTypes) {
+ if (entry.getSecurityTypes().contains(security)) {
return true;
}
}
- return false;
- }).limit(mShowLimitedItem ? MAX_NUMBER_LIST_ITEM : Long.MAX_VALUE)
- .collect(toList()));
+ }
+ return false;
}
private class WifiEntryAdapter extends ArrayAdapter<WifiEntry> {
@@ -350,7 +362,14 @@
@Override
public void onMatch(List<ScanResult> scanResults) {
- mMatchedScanResults = scanResults;
+ mMatchWifis.clear();
+ for (ScanResult scanResult : scanResults) {
+ MatchWifi matchWifi = new MatchWifi();
+ matchWifi.mSsid = scanResult.SSID;
+ matchWifi.mSecurityTypes = getSecurityTypesFromScanResult(scanResult);
+ mMatchWifis.add(matchWifi);
+ }
+
updateWifiEntries();
updateUi();
}
diff --git a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
index 6261db9..386f66d 100644
--- a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
@@ -16,6 +16,9 @@
package com.android.settings.wifi;
+import static com.android.wifitrackerlib.WifiEntry.SECURITY_PSK;
+import static com.android.wifitrackerlib.WifiEntry.SECURITY_SAE;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
@@ -47,16 +50,20 @@
import org.junit.Before;
import org.junit.Ignore;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InOrder;
-import org.mockito.MockitoAnnotations;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
@RunWith(RobolectricTestRunner.class)
@@ -64,15 +71,34 @@
public class NetworkRequestDialogFragmentTest {
private static final String KEY_SSID = "key_ssid";
- private static final String KEY_SECURITY = "key_security";
+ private static final String TEST_CAPABILITIES_OPEN = "[ESS]";
+ private static final String TEST_CAPABILITIES_WPA2_PSK = "[WPA2-PSK-CCMP][ESS]";
+ private static final String TEST_CAPABILITIES_WPA3_SAE = "[RSN-PSK+SAE-CCMP][ESS]";
private static final String TEST_APP_NAME = "TestAppName";
+ @Rule
+ public final MockitoRule mMockitoRule = MockitoJUnit.rule();
+ @Mock
+ WifiPickerTracker mWifiPickerTracker;
+ @Mock
+ WifiEntry mWifiEntry;
+
private FragmentActivity mActivity;
private NetworkRequestDialogFragment networkRequestDialogFragment;
+ ScanResult mScanResult = new ScanResult();
+
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
+ when(mWifiEntry.getSsid()).thenReturn(KEY_SSID);
+ when(mWifiEntry.getSecurityTypes()).thenReturn(Arrays.asList(SECURITY_PSK, SECURITY_SAE));
+ when(mWifiEntry.getSecurity()).thenReturn(SECURITY_PSK);
+ when(mWifiPickerTracker.getConnectedWifiEntry()).thenReturn(null);
+ when(mWifiPickerTracker.getWifiEntries()).thenReturn(Arrays.asList(mWifiEntry));
+
+ mScanResult.SSID = KEY_SSID;
+ mScanResult.capabilities = TEST_CAPABILITIES_OPEN;
+
FakeFeatureFactory fakeFeatureFactory = FakeFeatureFactory.setupForTest();
when(fakeFeatureFactory.wifiTrackerLibProvider.createWifiPickerTracker(
any(), any(), any(), any(), any(), anyLong(), anyLong(), any()))
@@ -82,7 +108,7 @@
new Intent().putExtra(NetworkRequestDialogFragment.EXTRA_APP_NAME,
TEST_APP_NAME)).setup().get();
networkRequestDialogFragment = spy(NetworkRequestDialogFragment.newInstance());
- networkRequestDialogFragment.mWifiPickerTracker = mock(WifiPickerTracker.class);
+ networkRequestDialogFragment.mWifiPickerTracker = mWifiPickerTracker;
}
@Ignore
@@ -151,12 +177,10 @@
@Test
public void onWifiStateChanged_nonEmptyMatchedScanResults_shouldUpdateWifiEntries() {
final InOrder inOrder = inOrder(networkRequestDialogFragment);
+ mScanResult.capabilities = TEST_CAPABILITIES_OPEN;
+ networkRequestDialogFragment.onMatch(Arrays.asList(mScanResult));
- final List<ScanResult> scanResults = new ArrayList<>();
- networkRequestDialogFragment.mMatchedScanResults = scanResults;
- ScanResult scanResult = mock(ScanResult.class);
- networkRequestDialogFragment.mMatchedScanResults.add(scanResult);
- networkRequestDialogFragment.onMatch(scanResults);
+ networkRequestDialogFragment.onWifiStateChanged();
inOrder.verify(networkRequestDialogFragment).updateWifiEntries();
inOrder.verify(networkRequestDialogFragment).updateUi();
@@ -165,12 +189,10 @@
@Test
public void onWifiEntriesChanged_nonEmptyMatchedScanResults_shouldUpdateWifiEntries() {
final InOrder inOrder = inOrder(networkRequestDialogFragment);
+ mScanResult.capabilities = TEST_CAPABILITIES_OPEN;
+ networkRequestDialogFragment.onMatch(Arrays.asList(mScanResult));
- final List<ScanResult> scanResults = new ArrayList<>();
- networkRequestDialogFragment.mMatchedScanResults = scanResults;
- ScanResult scanResult = mock(ScanResult.class);
- networkRequestDialogFragment.mMatchedScanResults.add(scanResult);
- networkRequestDialogFragment.onMatch(scanResults);
+ networkRequestDialogFragment.onWifiEntriesChanged();
inOrder.verify(networkRequestDialogFragment).updateWifiEntries();
inOrder.verify(networkRequestDialogFragment).updateUi();
@@ -288,4 +310,34 @@
// Check
verify(selectionCallback, times(1)).reject();
}
+
+ @Test
+ public void updateWifiEntries_noMatchSecurityWifi_filteredWifiIsEmpty() {
+ mScanResult.capabilities = TEST_CAPABILITIES_OPEN;
+ networkRequestDialogFragment.onMatch(Arrays.asList(mScanResult));
+
+ networkRequestDialogFragment.updateWifiEntries();
+
+ assertThat(networkRequestDialogFragment.mFilteredWifiEntries.size()).isEqualTo(0);
+ }
+
+ @Test
+ public void updateWifiEntries_matchWpa2Wifi_filteredWifiNotEmpty() {
+ mScanResult.capabilities = TEST_CAPABILITIES_WPA2_PSK;
+ networkRequestDialogFragment.onMatch(Arrays.asList(mScanResult));
+
+ networkRequestDialogFragment.updateWifiEntries();
+
+ assertThat(networkRequestDialogFragment.mFilteredWifiEntries.size()).isNotEqualTo(0);
+ }
+
+ @Test
+ public void updateWifiEntries_matchWpa3Wifi_filteredWifiNotEmpty() {
+ mScanResult.capabilities = TEST_CAPABILITIES_WPA3_SAE;
+ networkRequestDialogFragment.onMatch(Arrays.asList(mScanResult));
+
+ networkRequestDialogFragment.updateWifiEntries();
+
+ assertThat(networkRequestDialogFragment.mFilteredWifiEntries.size()).isNotEqualTo(0);
+ }
}