Don't add wifi entries twice, when returning from another activity.
Bug: 3209730 Change-Id: I7408a56fc10359e508be5a1d27492da2227335ce
This commit is contained in:
@@ -168,43 +168,47 @@ public class WifiSettings extends SettingsPreferenceFragment
|
|||||||
// state, start it off in the right state
|
// state, start it off in the right state
|
||||||
mEnableNextOnConnection = intent.getBooleanExtra(EXTRA_ENABLE_NEXT_ON_CONNECT, false);
|
mEnableNextOnConnection = intent.getBooleanExtra(EXTRA_ENABLE_NEXT_ON_CONNECT, false);
|
||||||
|
|
||||||
if (mEnableNextOnConnection) {
|
// Avoid re-adding on returning from an overlapping activity/fragment.
|
||||||
if (mEnableNextOnConnection && hasNextButton()) {
|
if (getPreferenceScreen() == null || getPreferenceScreen().getPreferenceCount() < 2) {
|
||||||
final ConnectivityManager connectivity = (ConnectivityManager)
|
if (mEnableNextOnConnection) {
|
||||||
getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
|
if (mEnableNextOnConnection && hasNextButton()) {
|
||||||
if (connectivity != null) {
|
final ConnectivityManager connectivity = (ConnectivityManager)
|
||||||
NetworkInfo info = connectivity.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
|
getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
changeNextButtonState(info.isConnected());
|
if (connectivity != null) {
|
||||||
|
NetworkInfo info = connectivity.getNetworkInfo(
|
||||||
|
ConnectivityManager.TYPE_WIFI);
|
||||||
|
changeNextButtonState(info.isConnected());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (mInXlSetupWizard) {
|
if (mInXlSetupWizard) {
|
||||||
addPreferencesFromResource(R.xml.wifi_access_points_for_wifi_setup_xl);
|
addPreferencesFromResource(R.xml.wifi_access_points_for_wifi_setup_xl);
|
||||||
} else if (intent.getBooleanExtra("only_access_points", false)) {
|
} else if (intent.getBooleanExtra("only_access_points", false)) {
|
||||||
addPreferencesFromResource(R.xml.wifi_access_points);
|
addPreferencesFromResource(R.xml.wifi_access_points);
|
||||||
} else {
|
} else {
|
||||||
addPreferencesFromResource(R.xml.wifi_settings);
|
addPreferencesFromResource(R.xml.wifi_settings);
|
||||||
mWifiEnabler = new WifiEnabler(activity,
|
mWifiEnabler = new WifiEnabler(activity,
|
||||||
(CheckBoxPreference) findPreference("enable_wifi"));
|
(CheckBoxPreference) findPreference("enable_wifi"));
|
||||||
mNotifyOpenNetworks =
|
mNotifyOpenNetworks =
|
||||||
(CheckBoxPreference) findPreference("notify_open_networks");
|
(CheckBoxPreference) findPreference("notify_open_networks");
|
||||||
mNotifyOpenNetworks.setChecked(Secure.getInt(getContentResolver(),
|
mNotifyOpenNetworks.setChecked(Secure.getInt(getContentResolver(),
|
||||||
Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 0) == 1);
|
Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 0) == 1);
|
||||||
|
}
|
||||||
|
// This may be either ProgressCategory or AccessPointCategoryForXL.
|
||||||
|
final ProgressCategoryBase preference =
|
||||||
|
(ProgressCategoryBase) findPreference("access_points");
|
||||||
|
mAccessPoints = preference;
|
||||||
|
mAccessPoints.setOrderingAsAdded(false);
|
||||||
|
mAddNetwork = findPreference("add_network");
|
||||||
|
|
||||||
|
registerForContextMenu(getListView());
|
||||||
|
setHasOptionsMenu(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// After confirming PreferenceScreen is available, we call super.
|
// After confirming PreferenceScreen is available, we call super.
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
|
||||||
// This may be either ProgressCategory or AccessPointCategoryForXL.
|
|
||||||
final ProgressCategoryBase preference =
|
|
||||||
(ProgressCategoryBase) findPreference("access_points");
|
|
||||||
mAccessPoints = preference;
|
|
||||||
mAccessPoints.setOrderingAsAdded(false);
|
|
||||||
mAddNetwork = findPreference("add_network");
|
|
||||||
|
|
||||||
registerForContextMenu(getListView());
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user