use of android.bluetooth.BluetoothAdapter in project bitcoin-wallet by bitcoin-wallet.
the class AlertDialogsFragment method handleProperty.
private boolean handleProperty(final String key, final String value) {
if (key.equalsIgnoreCase("min.security_patch.bluetooth")) {
final String minSecurityPatchLevel = value;
log.info("according to \"{}\", minimum security patch level for bluetooth is {}", versionUrl, minSecurityPatchLevel);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Build.VERSION.SECURITY_PATCH.compareTo(minSecurityPatchLevel) < 0) {
final BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (bluetoothAdapter != null && BluetoothAdapter.getDefaultAdapter().isEnabled()) {
handler.post(new Runnable() {
@Override
public void run() {
if (isAdded())
createInsecureBluetoothAlertDialog(minSecurityPatchLevel).show();
}
});
return true;
}
}
} else {
log.info("Ignoring key: {}", key);
}
return false;
}
use of android.bluetooth.BluetoothAdapter in project android_packages_apps_Settings by LineageOS.
the class TetherSettings method updateBluetoothState.
private void updateBluetoothState() {
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
if (adapter == null) {
return;
}
int btState = adapter.getState();
if (btState == BluetoothAdapter.STATE_TURNING_OFF) {
mBluetoothTether.setEnabled(false);
} else if (btState == BluetoothAdapter.STATE_TURNING_ON) {
mBluetoothTether.setEnabled(false);
} else {
BluetoothPan bluetoothPan = mBluetoothPan.get();
if (btState == BluetoothAdapter.STATE_ON && bluetoothPan != null && bluetoothPan.isTetheringOn()) {
mBluetoothTether.setChecked(true);
mBluetoothTether.setEnabled(!mDataSaverEnabled);
} else {
mBluetoothTether.setEnabled(!mDataSaverEnabled);
mBluetoothTether.setChecked(false);
}
}
}
use of android.bluetooth.BluetoothAdapter in project android_packages_apps_Settings by LineageOS.
the class TetherSettings method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.tether_prefs);
mFooterPreferenceMixin.createFooterPreference().setTitle(R.string.tethering_footer_info);
mDataSaverBackend = new DataSaverBackend(getContext());
mDataSaverEnabled = mDataSaverBackend.isDataSaverEnabled();
mDataSaverFooter = findPreference(DATA_SAVER_FOOTER);
setIfOnlyAvailableForAdmins(true);
if (isUiRestricted()) {
mUnavailable = true;
getPreferenceScreen().removeAll();
return;
}
final Activity activity = getActivity();
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
if (adapter != null) {
adapter.getProfileProxy(activity.getApplicationContext(), mProfileServiceListener, BluetoothProfile.PAN);
}
mEnableWifiAp = (SwitchPreference) findPreference(ENABLE_WIFI_AP);
Preference wifiApSettings = findPreference(WIFI_AP_SSID_AND_SECURITY);
mUsbTether = (SwitchPreference) findPreference(USB_TETHER_SETTINGS);
mBluetoothTether = (SwitchPreference) findPreference(ENABLE_BLUETOOTH_TETHERING);
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);
}
mWifiTetherPreferenceController.displayPreference(getPreferenceScreen());
if (WifiTetherSettings.isTetherSettingPageEnabled()) {
removePreference(ENABLE_WIFI_AP);
removePreference(WIFI_AP_SSID_AND_SECURITY);
} else {
if (wifiAvailable && !Utils.isMonkeyRunning()) {
mWifiApEnabler = new WifiApEnabler(activity, mDataSaverBackend, mEnableWifiAp);
initWifiTethering();
} else {
getPreferenceScreen().removePreference(mEnableWifiAp);
getPreferenceScreen().removePreference(wifiApSettings);
}
}
if (!bluetoothAvailable) {
getPreferenceScreen().removePreference(mBluetoothTether);
} else {
BluetoothPan pan = mBluetoothPan.get();
if (pan != null && pan.isTetheringOn()) {
mBluetoothTether.setChecked(true);
} else {
mBluetoothTether.setChecked(false);
}
}
// Set initial state based on Data Saver mode.
onDataSaverChanged(mDataSaverBackend.isDataSaverEnabled());
}
use of android.bluetooth.BluetoothAdapter in project android_packages_apps_Settings by LineageOS.
the class TetherSettings method onDestroy.
@Override
public void onDestroy() {
mDataSaverBackend.remListener(this);
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
BluetoothProfile profile = mBluetoothPan.getAndSet(null);
if (profile != null && adapter != null) {
adapter.closeProfileProxy(BluetoothProfile.PAN, profile);
}
super.onDestroy();
}
use of android.bluetooth.BluetoothAdapter in project android_packages_apps_Settings by LineageOS.
the class TetherSettings method startTethering.
private void startTethering(int choice) {
if (choice == TETHERING_BLUETOOTH) {
// Turn on Bluetooth first.
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
if (adapter.getState() == BluetoothAdapter.STATE_OFF) {
mBluetoothEnableForTether = true;
adapter.enable();
mBluetoothTether.setSummary(R.string.bluetooth_turning_on);
mBluetoothTether.setEnabled(false);
return;
}
}
mCm.startTethering(choice, true, mStartTetheringCallback, mHandler);
}
Aggregations