Avoid launching details settings after WifiEntry is forgotten
- Don't launch details settings if WifiEntry isn't saved Bug: 359584817 Flag: EXEMPT bugfix Test: Manual testing atest -c NetworkProviderSettingsTest Change-Id: Iff1c37b64adef6d136d2aaa6a0a946c22af38193
This commit is contained in:
@@ -1068,6 +1068,10 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void launchNetworkDetailsFragment(LongPressWifiEntryPreference pref) {
|
void launchNetworkDetailsFragment(LongPressWifiEntryPreference pref) {
|
||||||
final WifiEntry wifiEntry = pref.getWifiEntry();
|
final WifiEntry wifiEntry = pref.getWifiEntry();
|
||||||
|
if (!wifiEntry.isSaved()) {
|
||||||
|
Log.w(TAG, "launchNetworkDetailsFragment: Don't launch because WifiEntry isn't saved!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
final Context context = requireContext();
|
final Context context = requireContext();
|
||||||
|
|
||||||
final Bundle bundle = new Bundle();
|
final Bundle bundle = new Bundle();
|
||||||
|
|||||||
@@ -872,6 +872,17 @@ public class NetworkProviderSettingsTest {
|
|||||||
verify(mWifiEntry, never()).getKey();
|
verify(mWifiEntry, never()).getKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void launchNetworkDetailsFragment_wifiEntryIsNotSaved_ignoreWifiEntry() {
|
||||||
|
when(mWifiEntry.isSaved()).thenReturn(false);
|
||||||
|
LongPressWifiEntryPreference preference =
|
||||||
|
mNetworkProviderSettings.createLongPressWifiEntryPreference(mWifiEntry);
|
||||||
|
|
||||||
|
mNetworkProviderSettings.launchNetworkDetailsFragment(preference);
|
||||||
|
|
||||||
|
verify(mWifiEntry, never()).getKey();
|
||||||
|
}
|
||||||
|
|
||||||
@Implements(PreferenceFragmentCompat.class)
|
@Implements(PreferenceFragmentCompat.class)
|
||||||
public static class ShadowPreferenceFragmentCompat {
|
public static class ShadowPreferenceFragmentCompat {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user