Restrict WiFi network connection
- Use StandardWifiEntry#canConnect() to determine if the network should
be disabled or not.
- Use StandardWifiEntry#getSummary() to retrieve the restriction message.
- Disabled WiFi network if it cannot connect.
- If WiFi network is connected or saved network, leave it enabled to
disconnect or configure.
- See the result screenshot in b/203168943#comment11
Bug: 203168938
Bug: 203168943
Test: manual test
make RunSettingsRoboTests ROBOTEST_FILTER=LongPressWifiEntryPreferenceTest
make RunSettingsRoboTests ROBOTEST_FILTER=NetworkProviderSettingsTest
Merged-In: I04aafaa5b383598a0f87eea15d06b38bbc662b9e
Change-Id: I04aafaa5b383598a0f87eea15d06b38bbc662b9e
(cherry picked from commit f86bdc9c69
)
This commit is contained in:
@@ -628,15 +628,7 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
|
||||
}
|
||||
|
||||
if (preference instanceof LongPressWifiEntryPreference) {
|
||||
final WifiEntry selectedEntry =
|
||||
((LongPressWifiEntryPreference) preference).getWifiEntry();
|
||||
|
||||
if (selectedEntry.shouldEditBeforeConnect()) {
|
||||
launchConfigNewNetworkFragment(selectedEntry);
|
||||
return true;
|
||||
}
|
||||
|
||||
connect(selectedEntry, true /* editIfNoConfig */, true /* fullScreenEdit */);
|
||||
onSelectedWifiPreferenceClick((LongPressWifiEntryPreference) preference);
|
||||
} else if (preference == mAddWifiNetworkPreference) {
|
||||
onAddNetworkPressed();
|
||||
} else {
|
||||
@@ -645,6 +637,25 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
|
||||
return true;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void onSelectedWifiPreferenceClick(LongPressWifiEntryPreference preference) {
|
||||
final WifiEntry selectedEntry = preference.getWifiEntry();
|
||||
|
||||
if (selectedEntry.shouldEditBeforeConnect()) {
|
||||
launchConfigNewNetworkFragment(selectedEntry);
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectedEntry.canConnect()) {
|
||||
connect(selectedEntry, true /* editIfNoConfig */, true /* fullScreenEdit */);
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectedEntry.isSaved()) {
|
||||
launchNetworkDetailsFragment(preference);
|
||||
}
|
||||
}
|
||||
|
||||
private void launchWifiDppConfiguratorActivity(WifiEntry wifiEntry) {
|
||||
final Intent intent = WifiDppUtils.getConfiguratorQrCodeGeneratorIntentOrNull(getContext(),
|
||||
mWifiManager, wifiEntry);
|
||||
@@ -984,7 +995,8 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
|
||||
return new FirstWifiEntryPreference(getPrefContext(), wifiEntry, this);
|
||||
}
|
||||
|
||||
private void launchNetworkDetailsFragment(LongPressWifiEntryPreference pref) {
|
||||
@VisibleForTesting
|
||||
void launchNetworkDetailsFragment(LongPressWifiEntryPreference pref) {
|
||||
final WifiEntry wifiEntry = pref.getWifiEntry();
|
||||
final Context context = getContext();
|
||||
final CharSequence title =
|
||||
@@ -1253,7 +1265,8 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
|
||||
}
|
||||
}
|
||||
|
||||
private void launchConfigNewNetworkFragment(WifiEntry wifiEntry) {
|
||||
@VisibleForTesting
|
||||
void launchConfigNewNetworkFragment(WifiEntry wifiEntry) {
|
||||
final Bundle bundle = new Bundle();
|
||||
bundle.putString(WifiNetworkDetailsFragment.KEY_CHOSEN_WIFIENTRY_KEY,
|
||||
wifiEntry.getKey());
|
||||
|
Reference in New Issue
Block a user