use of android.net.wifi.SoftApConfiguration in project android_packages_apps_Settings by omnirom.
the class WifiTetherAutoOffPreferenceController method onPreferenceChange.
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean settingsOn = (Boolean) newValue;
SoftApConfiguration softApConfiguration = mWifiManager.getSoftApConfiguration();
SoftApConfiguration newSoftApConfiguration = new SoftApConfiguration.Builder(softApConfiguration).setAutoShutdownEnabled(settingsOn).build();
return mWifiManager.setSoftApConfiguration(newSoftApConfiguration);
}
use of android.net.wifi.SoftApConfiguration in project android_packages_apps_Settings by omnirom.
the class WifiTetherPasswordPreferenceController method updateDisplay.
@Override
public void updateDisplay() {
final SoftApConfiguration config = mWifiManager.getSoftApConfiguration();
if (config.getSecurityType() != SoftApConfiguration.SECURITY_TYPE_OPEN && TextUtils.isEmpty(config.getPassphrase())) {
mPassword = generateRandomPassword();
} else {
mPassword = config.getPassphrase();
}
mSecurityType = config.getSecurityType();
((ValidatedEditTextPreference) mPreference).setValidator(this);
((ValidatedEditTextPreference) mPreference).setIsPassword(true);
((ValidatedEditTextPreference) mPreference).setIsSummaryPassword(true);
updatePasswordDisplay((EditTextPreference) mPreference);
}
use of android.net.wifi.SoftApConfiguration in project android_packages_apps_Settings by omnirom.
the class WifiTetherSSIDPreferenceController method updateDisplay.
@Override
public void updateDisplay() {
final SoftApConfiguration config = mWifiManager.getSoftApConfiguration();
if (config != null) {
mSSID = config.getSsid();
} else {
mSSID = DEFAULT_SSID;
}
((ValidatedEditTextPreference) mPreference).setValidator(this);
if (mWifiManager.isWifiApEnabled() && config != null) {
final Intent intent = WifiDppUtils.getHotspotConfiguratorIntentOrNull(mContext, mWifiManager, config);
if (intent == null) {
Log.e(TAG, "Invalid security to share hotspot");
((WifiTetherSsidPreference) mPreference).setButtonVisible(false);
} else {
((WifiTetherSsidPreference) mPreference).setButtonOnClickListener(view -> shareHotspotNetwork(intent));
((WifiTetherSsidPreference) mPreference).setButtonVisible(true);
}
} else {
((WifiTetherSsidPreference) mPreference).setButtonVisible(false);
}
updateSsidDisplay((EditTextPreference) mPreference);
}
use of android.net.wifi.SoftApConfiguration in project android_packages_apps_Settings by omnirom.
the class WifiTetherSettings method onTetherConfigUpdated.
@Override
public void onTetherConfigUpdated(AbstractPreferenceController context) {
final SoftApConfiguration config = buildNewConfig();
mPasswordPreferenceController.setSecurityType(config.getSecurityType());
/**
* if soft AP is stopped, bring up
* else restart with new config
* TODO: update config on a running access point when framework support is added
*/
if (mWifiManager.getWifiApState() == WifiManager.WIFI_AP_STATE_ENABLED) {
Log.d("TetheringSettings", "Wifi AP config changed while enabled, stop and restart");
mRestartWifiApAfterConfigChange = true;
mSwitchBarController.stopTether();
}
mWifiManager.setSoftApConfiguration(config);
if (context instanceof WifiTetherSecurityPreferenceController) {
reConfigInitialExpandedChildCount();
}
}
use of android.net.wifi.SoftApConfiguration in project android_packages_apps_Settings by omnirom.
the class WifiTetherPreferenceController method handleWifiApStateChanged.
@VisibleForTesting
void handleWifiApStateChanged(int state, int reason) {
switch(state) {
case WifiManager.WIFI_AP_STATE_ENABLING:
mPreference.setSummary(R.string.wifi_tether_starting);
break;
case WifiManager.WIFI_AP_STATE_ENABLED:
final SoftApConfiguration softApConfig = mWifiManager.getSoftApConfiguration();
updateConfigSummary(softApConfig);
break;
case WifiManager.WIFI_AP_STATE_DISABLING:
mPreference.setSummary(R.string.wifi_tether_stopping);
break;
case WifiManager.WIFI_AP_STATE_DISABLED:
mPreference.setSummary(R.string.wifi_hotspot_off_subtext);
break;
default:
if (reason == WifiManager.SAP_START_FAILURE_NO_CHANNEL) {
mPreference.setSummary(R.string.wifi_sap_no_channel_error);
} else {
mPreference.setSummary(R.string.wifi_error);
}
}
}
Aggregations