use of android.bluetooth.BluetoothAdapter in project android_packages_apps_Settings by LineageOS.
the class Status method setBtStatus.
private void setBtStatus() {
BluetoothAdapter bluetooth = BluetoothAdapter.getDefaultAdapter();
Preference btAddressPref = findPreference(KEY_BT_ADDRESS);
if (bluetooth == null) {
// device not BT capable
getPreferenceScreen().removePreference(btAddressPref);
} else {
String address = bluetooth.isEnabled() ? bluetooth.getAddress() : null;
btAddressPref.setSummary(!TextUtils.isEmpty(address) ? address : getString(R.string.status_unavailable));
}
}
use of android.bluetooth.BluetoothAdapter in project android_packages_apps_Settings by LineageOS.
the class BluetoothNamePreference method persistString.
@Override
protected boolean persistString(String value) {
BluetoothAdapter adapter = mLocalManager.getBluetoothAdapter();
adapter.setName(value);
return true;
}
use of android.bluetooth.BluetoothAdapter in project android_packages_apps_Settings by LineageOS.
the class CachedBluetoothDeviceManager method readPairedDevices.
private synchronized boolean readPairedDevices() {
BluetoothAdapter adapter = mLocalManager.getBluetoothAdapter();
Set<BluetoothDevice> bondedDevices = adapter.getBondedDevices();
if (bondedDevices == null)
return false;
boolean deviceAdded = false;
for (BluetoothDevice device : bondedDevices) {
CachedBluetoothDevice cachedDevice = findDevice(device);
if (cachedDevice == null) {
cachedDevice = new CachedBluetoothDevice(mLocalManager.getContext(), device);
mCachedDevices.add(cachedDevice);
dispatchDeviceAdded(cachedDevice);
deviceAdded = true;
}
}
return deviceAdded;
}
use of android.bluetooth.BluetoothAdapter in project fdroidclient by f-droid.
the class BluetoothServer method run.
@Override
public void run() {
final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
try {
serverSocket = adapter.listenUsingInsecureRfcommWithServiceRecord("FDroid App Swap", BluetoothConstants.fdroidUuid());
} catch (IOException e) {
Log.e(TAG, "Error starting Bluetooth server socket, will stop the server now", e);
return;
}
while (true) {
if (isInterrupted()) {
Utils.debugLog(TAG, "Server stopped so will terminate loop looking for client connections.");
break;
}
if (!adapter.isEnabled()) {
Utils.debugLog(TAG, "User disabled Bluetooth from outside, stopping.");
break;
}
try {
BluetoothSocket clientSocket = serverSocket.accept();
if (clientSocket != null) {
if (isInterrupted()) {
Utils.debugLog(TAG, "Server stopped after socket accepted from client, but before initiating connection.");
break;
}
ClientConnection client = new ClientConnection(clientSocket, webRoot);
client.start();
clients.add(client);
}
} catch (IOException e) {
Log.e(TAG, "Error receiving client connection over Bluetooth server socket, will continue listening for other clients", e);
}
}
}
use of android.bluetooth.BluetoothAdapter in project xDrip by NightscoutFoundation.
the class JoH method isBluetoothEnabled.
public static boolean isBluetoothEnabled(final Context context) {
try {
final BluetoothManager bluetoothManager = (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
// local scope only
final BluetoothAdapter mBluetoothAdapter = bluetoothManager.getAdapter();
return mBluetoothAdapter.isEnabled();
} catch (Exception e) {
UserError.Log.d(TAG, "isBluetoothEnabled() exception: " + e);
}
return false;
}
Aggregations