use of com.android.settingslib.wifi.AccessPoint in project android_packages_apps_Settings by DirtyUnicorns.
the class SavedAccessPointsWifiSettings method initPreferences.
private void initPreferences() {
PreferenceScreen preferenceScreen = getPreferenceScreen();
final Context context = getPrefContext();
final List<AccessPoint> accessPoints = WifiSavedConfigUtils.getAllConfigs(context, mWifiManager);
Collections.sort(accessPoints, SAVED_NETWORK_COMPARATOR);
cacheRemoveAllPrefs(preferenceScreen);
final int accessPointsSize = accessPoints.size();
for (int i = 0; i < accessPointsSize; ++i) {
AccessPoint ap = accessPoints.get(i);
String key = AccessPointPreference.generatePreferenceKey(ap);
LongPressAccessPointPreference preference = (LongPressAccessPointPreference) getCachedPreference(key);
if (preference == null) {
preference = new LongPressAccessPointPreference(ap, context, mUserBadgeCache, true, this);
preference.setKey(key);
preference.setIcon(null);
preferenceScreen.addPreference(preference);
}
preference.setOrder(i);
}
removeCachedPrefs(preferenceScreen);
if (mAddNetworkPreference == null) {
mAddNetworkPreference = new Preference(getPrefContext());
mAddNetworkPreference.setIcon(R.drawable.ic_menu_add_inset);
mAddNetworkPreference.setTitle(R.string.wifi_add_network);
}
mAddNetworkPreference.setOrder(accessPointsSize);
preferenceScreen.addPreference(mAddNetworkPreference);
if (getPreferenceScreen().getPreferenceCount() < 1) {
Log.w(TAG, "Saved networks activity loaded, but there are no saved networks!");
}
}
use of com.android.settingslib.wifi.AccessPoint in project android_packages_apps_Settings by DirtyUnicorns.
the class WifiSettings method isDisabledByWrongPassword.
/**
* Helper method to return whether an AccessPoint is disabled due to a wrong password
*/
private static boolean isDisabledByWrongPassword(AccessPoint accessPoint) {
WifiConfiguration config = accessPoint.getConfig();
if (config == null) {
return false;
}
WifiConfiguration.NetworkSelectionStatus networkStatus = config.getNetworkSelectionStatus();
if (networkStatus == null || networkStatus.isNetworkEnabled()) {
return false;
}
int reason = networkStatus.getNetworkSelectionDisableReason();
return WifiConfiguration.NetworkSelectionStatus.DISABLED_BY_WRONG_PASSWORD == reason;
}
use of com.android.settingslib.wifi.AccessPoint in project android_packages_apps_Settings by DirtyUnicorns.
the class WifiSettings method configureConnectedAccessPointPreferenceCategory.
/**
* Configure the ConnectedAccessPointPreferenceCategory and return true if the Category was
* shown.
*/
private boolean configureConnectedAccessPointPreferenceCategory(List<AccessPoint> accessPoints) {
if (accessPoints.size() == 0) {
removeConnectedAccessPointPreference();
return false;
}
AccessPoint connectedAp = accessPoints.get(0);
if (!connectedAp.isActive()) {
removeConnectedAccessPointPreference();
return false;
}
// Is the preference category empty?
if (mConnectedAccessPointPreferenceCategory.getPreferenceCount() == 0) {
addConnectedAccessPointPreference(connectedAp);
return true;
}
// Is the previous currently connected SSID different from the new one?
AccessPointPreference preference = (AccessPointPreference) (mConnectedAccessPointPreferenceCategory.getPreference(0));
// in the UI.
if (preference.getAccessPoint() != connectedAp) {
removeConnectedAccessPointPreference();
addConnectedAccessPointPreference(connectedAp);
return true;
}
// Else same AP is connected, simply refresh the connected access point preference
// (first and only access point in this category).
((LongPressAccessPointPreference) mConnectedAccessPointPreferenceCategory.getPreference(0)).refresh();
return true;
}
use of com.android.settingslib.wifi.AccessPoint in project android_packages_apps_Settings by DirtyUnicorns.
the class WifiSettings method onCreateDialog.
@Override
public Dialog onCreateDialog(int dialogId) {
switch(dialogId) {
case WIFI_DIALOG_ID:
if (mDlgAccessPoint == null && mAccessPointSavedState == null) {
// add new network
mDialog = WifiDialog.createFullscreen(getActivity(), this, mDlgAccessPoint, mDialogMode);
} else {
// modify network
if (mDlgAccessPoint == null) {
// restore AP from save state
mDlgAccessPoint = new AccessPoint(getActivity(), mAccessPointSavedState);
// Reset the saved access point data
mAccessPointSavedState = null;
}
mDialog = WifiDialog.createModal(getActivity(), this, mDlgAccessPoint, mDialogMode);
}
mSelectedAccessPoint = mDlgAccessPoint;
return mDialog;
case WPS_PBC_DIALOG_ID:
return new WpsDialog(getActivity(), WpsInfo.PBC);
case WPS_PIN_DIALOG_ID:
return new WpsDialog(getActivity(), WpsInfo.DISPLAY);
case WRITE_NFC_DIALOG_ID:
if (mSelectedAccessPoint != null) {
mWifiToNfcDialog = new WriteWifiConfigToNfcDialog(getActivity(), mSelectedAccessPoint.getSecurity(), new WifiManagerWrapper(mWifiManager));
} else if (mWifiNfcDialogSavedState != null) {
mWifiToNfcDialog = new WriteWifiConfigToNfcDialog(getActivity(), mWifiNfcDialogSavedState, new WifiManagerWrapper(mWifiManager));
}
return mWifiToNfcDialog;
}
return super.onCreateDialog(dialogId);
}
use of com.android.settingslib.wifi.AccessPoint in project android_packages_apps_Settings by DirtyUnicorns.
the class WifiDialogActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
final Intent intent = getIntent();
if (WizardManagerHelper.isSetupWizardIntent(intent)) {
setTheme(SetupWizardUtils.getTransparentTheme(intent));
}
super.onCreate(savedInstanceState);
final Bundle accessPointState = intent.getBundleExtra(KEY_ACCESS_POINT_STATE);
AccessPoint accessPoint = null;
if (accessPointState != null) {
accessPoint = new AccessPoint(this, accessPointState);
}
WifiDialog dialog = WifiDialog.createModal(this, this, accessPoint, WifiConfigUiBase.MODE_CONNECT);
dialog.show();
dialog.setOnDismissListener(this);
}
Aggregations