Fix "Add Network" button on SavedAccessPoints page.

Fix merge conflict.

The old onSubmit was a no-op. It now correctly pipes onSubmit to
WifiManager#save() with the new WifiConfiguration. On successful save,
it displays the new network in the list, and on failure, it displays a
toast indicating that the save action failed. Adds a test for the
WifiDialog behaviors on this page.

Bug: 66177765
Test: make RunSettingsRoboTests, manual - tested with Wifi enabled and
disabled, and with networks that were visible and not.
Change-Id: I27446aa49bc9efaf1ea1d6c6158928b62ce01ba2
This commit is contained in:
Eric Schwarzenbach
2017-09-20 16:34:23 -07:00
parent 0e680b3cfd
commit c03bd8f86f
3 changed files with 59 additions and 11 deletions

View File

@@ -17,6 +17,7 @@
package com.android.settings.wifi;
import android.annotation.Nullable;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.icu.text.Collator;
@@ -28,6 +29,7 @@ import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.util.Log;
import android.widget.Toast;
import com.android.internal.logging.nano.MetricsProto;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
@@ -88,6 +90,22 @@ public class SavedAccessPointsWifiSettings extends SettingsPreferenceFragment
}
};
private final WifiManager.ActionListener mSaveListener = new WifiManager.ActionListener() {
@Override
public void onSuccess() {
postUpdatePreference();
}
@Override
public void onFailure(int reason) {
Activity activity = getActivity();
if (activity != null) {
Toast.makeText(activity,
R.string.wifi_failed_save_message,
Toast.LENGTH_SHORT).show();
}
}
};
private WifiDialog mDialog;
private WifiManagerWrapper mWifiManager;
private AccessPoint mDlgAccessPoint;
@@ -267,7 +285,7 @@ public class SavedAccessPointsWifiSettings extends SettingsPreferenceFragment
@Override
public void onSubmit(WifiDialog dialog) {
// Ignored
mWifiManager.save(dialog.getController().getConfig(), mSaveListener);
}
@Override