use of com.android.settings.wifi.WifiApEnabler in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class TetherSettings method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
if (icicle != null) {
mTetherChoice = icicle.getInt(TETHER_CHOICE);
}
addPreferencesFromResource(R.xml.tether_prefs);
mDataSaverBackend = new DataSaverBackend(getContext());
mDataSaverEnabled = mDataSaverBackend.isDataSaverEnabled();
mDataSaverFooter = findPreference(DATA_SAVER_FOOTER);
setIfOnlyAvailableForAdmins(true);
if (isUiRestricted()) {
mUnavailable = true;
setPreferenceScreen(new PreferenceScreen(getPrefContext(), null));
return;
}
final Activity activity = getActivity();
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
if (adapter != null) {
adapter.getProfileProxy(activity.getApplicationContext(), mProfileServiceListener, BluetoothProfile.PAN);
}
mCreateNetwork = findPreference(WIFI_AP_SSID_AND_SECURITY);
boolean enableWifiApSettingsExt = getResources().getBoolean(R.bool.show_wifi_hotspot_settings);
boolean isWifiApEnabled = getResources().getBoolean(R.bool.hide_wifi_hotspot);
checkDefaultValue(getActivity());
if (enableWifiApSettingsExt) {
mEnableWifiAp = (HotspotPreference) findPreference(ENABLE_WIFI_AP_EXT);
getPreferenceScreen().removePreference(findPreference(ENABLE_WIFI_AP));
getPreferenceScreen().removePreference(mCreateNetwork);
Intent intent = new Intent();
intent.setAction("com.qti.ap.settings");
intent.setPackage("com.qualcomm.qti.extsettings");
mEnableWifiAp.setIntent(intent);
} else {
mEnableWifiAp = (SwitchPreference) findPreference(ENABLE_WIFI_AP);
getPreferenceScreen().removePreference(findPreference(ENABLE_WIFI_AP_EXT));
}
if (isWifiApEnabled) {
getPreferenceScreen().removePreference(mEnableWifiAp);
getPreferenceScreen().removePreference(mCreateNetwork);
}
if (getResources().getBoolean(R.bool.config_regional_hotspot_tether_help_enable)) {
mTetherHelp = (PreferenceScreen) findPreference(TETHERING_HELP);
} else {
getPreferenceScreen().removePreference(findPreference(TETHERING_HELP));
}
mUsbTether = (SwitchPreference) findPreference(USB_TETHER_SETTINGS);
mBluetoothTether = (SwitchPreference) findPreference(ENABLE_BLUETOOTH_TETHERING);
mHotspotInactivityTimeout = (ListPreference) findPreference(HOTSPOT_TIMEOUT);
mDataSaverBackend.addListener(this);
mCm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
mUsbRegexs = mCm.getTetherableUsbRegexs();
mWifiRegexs = mCm.getTetherableWifiRegexs();
mBluetoothRegexs = mCm.getTetherableBluetoothRegexs();
final boolean usbAvailable = mUsbRegexs.length != 0;
final boolean wifiAvailable = mWifiRegexs.length != 0;
final boolean bluetoothAvailable = mBluetoothRegexs.length != 0;
if (!usbAvailable || Utils.isMonkeyRunning()) {
getPreferenceScreen().removePreference(mUsbTether);
}
if (wifiAvailable && !Utils.isMonkeyRunning()) {
mWifiApEnabler = new WifiApEnabler(activity, mDataSaverBackend, mEnableWifiAp);
initWifiTethering();
} else {
getPreferenceScreen().removePreference(mEnableWifiAp);
getPreferenceScreen().removePreference(mCreateNetwork);
}
if (!bluetoothAvailable) {
getPreferenceScreen().removePreference(mBluetoothTether);
} else {
BluetoothPan pan = mBluetoothPan.get();
if (pan != null && pan.isTetheringOn()) {
mBluetoothTether.setChecked(true);
} else {
mBluetoothTether.setChecked(false);
}
}
mHotspotInactivityTimeout.setOnPreferenceChangeListener(this);
// Set initial state based on Data Saver mode.
onDataSaverChanged(mDataSaverBackend.isDataSaverEnabled());
}
Aggregations