mSelectedAccessPoint = (AccessPoint) preference;
menu.setHeaderTitle(mSelectedAccessPoint.ssid);
if (mSelectedAccessPoint.getLevel() != -1) {
- int connectStringRes = 0;
if (mSelectedAccessPoint.getState() == null) {
- connectStringRes = R.string.wifi_menu_connect;
- } else if (mSelectedAccessPoint.networkId == INVALID_NETWORK_ID &&
- mSelectedAccessPoint.getNetworkInfo().getState()
- != State.DISCONNECTED) {
- // State is non-null (and not disconnected) but this network has no
- // configuration, which means it is ephemeral. Allow the user to save the
- // configuration permanently (but still issue this as a CONNECT command).
- connectStringRes = R.string.wifi_menu_remember;
+ menu.add(Menu.NONE, MENU_ID_CONNECT, 0, R.string.wifi_menu_connect);
}
+ }
- if (connectStringRes != 0) {
- menu.add(Menu.NONE, MENU_ID_CONNECT, 0, connectStringRes);
- }
+ if (ActivityManager.getCurrentUser() == UserHandle.USER_OWNER &&
+ (mSelectedAccessPoint.networkId != INVALID_NETWORK_ID ||
+ (mSelectedAccessPoint.getNetworkInfo() != null &&
+ mSelectedAccessPoint.getNetworkInfo().getState() != State.DISCONNECTED))) {
+ // Allow forgetting a network if the current user is the owner and either the
+ // network is saved or ephemerally connected. (In the latter case, "forget"
+ // blacklists the network so it won't be used again, ephemerally).
+ menu.add(Menu.NONE, MENU_ID_FORGET, 0, R.string.wifi_menu_forget);
}
if (mSelectedAccessPoint.networkId != INVALID_NETWORK_ID) {
- if (ActivityManager.getCurrentUser() == UserHandle.USER_OWNER) {
- menu.add(Menu.NONE, MENU_ID_FORGET, 0, R.string.wifi_menu_forget);
- }
menu.add(Menu.NONE, MENU_ID_MODIFY, 0, R.string.wifi_menu_modify);
- if (mSelectedAccessPoint.security != AccessPoint.SECURITY_NONE) {
+ NfcAdapter nfcAdapter = NfcAdapter.getNfcAdapter(getActivity());
+ if (nfcAdapter != null && nfcAdapter.isEnabled() &&
+ mSelectedAccessPoint.security != AccessPoint.SECURITY_NONE) {
// Only allow writing of NFC tags for password-protected networks.
menu.add(Menu.NONE, MENU_ID_WRITE_NFC, 0, R.string.wifi_menu_write_to_nfc);
}