Search in sources :

Example 1 with HotspotPreference

use of com.android.settings.HotspotPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WifiApEnabler method handleWifiApStateChanged.

private void handleWifiApStateChanged(int state, int reason) {
    boolean enableWifiApSettingsExt = mContext.getResources().getBoolean(R.bool.show_wifi_hotspot_settings);
    if (enableWifiApSettingsExt) {
        HotspotPreference hSwitch = (HotspotPreference) mSwitch;
        switch(state) {
            case WifiManager.WIFI_AP_STATE_ENABLING:
                hSwitch.setSummary(R.string.wifi_tether_starting);
                hSwitch.setEnabled(false);
                break;
            case WifiManager.WIFI_AP_STATE_ENABLED:
                /**
                     * Summary on enable is handled by tether
                     * broadcast notice
                     */
                postTurnOn(mContext, TETHERING_WIFI);
                hSwitch.setChecked(true);
                /* Doesnt need the airplane check */
                hSwitch.setEnabled(!mDataSaverBackend.isDataSaverEnabled());
                break;
            case WifiManager.WIFI_AP_STATE_DISABLING:
                hSwitch.setSummary(R.string.wifi_tether_stopping);
                hSwitch.setChecked(false);
                hSwitch.setEnabled(false);
                break;
            case WifiManager.WIFI_AP_STATE_DISABLED:
                hSwitch.setChecked(false);
                hSwitch.setSummary(mOriginalSummary);
                enableWifiSwitch();
                break;
            default:
                hSwitch.setChecked(false);
                if (reason == WifiManager.SAP_START_FAILURE_NO_CHANNEL) {
                    hSwitch.setSummary(R.string.wifi_sap_no_channel_error);
                } else {
                    hSwitch.setSummary(R.string.wifi_error);
                }
                enableWifiSwitch();
        }
    } else {
        SwitchPreference sSwitch = (SwitchPreference) mSwitch;
        switch(state) {
            case WifiManager.WIFI_AP_STATE_ENABLING:
                sSwitch.setSummary(R.string.wifi_tether_starting);
                sSwitch.setEnabled(false);
                break;
            case WifiManager.WIFI_AP_STATE_ENABLED:
                /**
                     * Summary on enable is handled by tether
                     * broadcast notice
                     */
                sSwitch.setChecked(true);
                /* Doesnt need the airplane check */
                sSwitch.setEnabled(!mDataSaverBackend.isDataSaverEnabled());
                mWifiSavedState = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.WIFI_SAVED_STATE, 0);
                break;
            case WifiManager.WIFI_AP_STATE_DISABLING:
                sSwitch.setSummary(R.string.wifi_tether_stopping);
                sSwitch.setChecked(false);
                sSwitch.setEnabled(false);
                break;
            case WifiManager.WIFI_AP_STATE_DISABLED:
                sSwitch.setChecked(false);
                sSwitch.setSummary(mOriginalSummary);
                /* If saved WiFi state is enabled, WiFi will restore to enabled state
                    on softAP disable. in this case call enableWifiSwitch on WIFI_STATE_ENABLED
                    event */
                if (mWifiSavedState == 0)
                    enableWifiSwitch();
                break;
            default:
                sSwitch.setChecked(false);
                if (reason == WifiManager.SAP_START_FAILURE_NO_CHANNEL) {
                    sSwitch.setSummary(R.string.wifi_sap_no_channel_error);
                } else {
                    sSwitch.setSummary(R.string.wifi_error);
                }
                enableWifiSwitch();
        }
    }
}
Also used : SwitchPreference(android.support.v14.preference.SwitchPreference) HotspotPreference(com.android.settings.HotspotPreference)

Aggregations

SwitchPreference (android.support.v14.preference.SwitchPreference)1 HotspotPreference (com.android.settings.HotspotPreference)1