use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project android_packages_apps_Settings by omnirom.
the class AccessibilityHearingAidPreferenceController method getConnectedHearingAidDevice.
@VisibleForTesting
CachedBluetoothDevice getConnectedHearingAidDevice() {
if (!mHearingAidProfileSupported) {
return null;
}
if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) {
return null;
}
final List<BluetoothDevice> deviceList = mLocalBluetoothManager.getProfileManager().getHearingAidProfile().getConnectedDevices();
final Iterator it = deviceList.iterator();
while (it.hasNext()) {
BluetoothDevice obj = (BluetoothDevice) it.next();
if (!mLocalBluetoothManager.getCachedDeviceManager().isSubDevice(obj)) {
return mLocalBluetoothManager.getCachedDeviceManager().findDevice(obj);
}
}
return null;
}
use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project platform_frameworks_base by android.
the class KeyboardUI method processKeyboardState.
// Should only be called on the handler thread
private void processKeyboardState() {
mHandler.removeMessages(MSG_PROCESS_KEYBOARD_STATE);
if (!mEnabled) {
mState = STATE_NOT_ENABLED;
return;
}
if (!mBootCompleted) {
mState = STATE_WAITING_FOR_BOOT_COMPLETED;
return;
}
if (mInTabletMode != InputManager.SWITCH_STATE_OFF) {
if (mState == STATE_WAITING_FOR_DEVICE_DISCOVERY) {
stopScanning();
} else if (mState == STATE_WAITING_FOR_BLUETOOTH) {
mUIHandler.sendEmptyMessage(MSG_DISMISS_BLUETOOTH_DIALOG);
}
mState = STATE_WAITING_FOR_TABLET_MODE_EXIT;
return;
}
final int btState = mLocalBluetoothAdapter.getState();
if ((btState == BluetoothAdapter.STATE_TURNING_ON || btState == BluetoothAdapter.STATE_ON) && mState == STATE_WAITING_FOR_BLUETOOTH) {
// If we're waiting for bluetooth but it has come on in the meantime, or is coming
// on, just dismiss the dialog. This frequently happens during device startup.
mUIHandler.sendEmptyMessage(MSG_DISMISS_BLUETOOTH_DIALOG);
}
if (btState == BluetoothAdapter.STATE_TURNING_ON) {
mState = STATE_WAITING_FOR_BLUETOOTH;
// Wait for bluetooth to fully come on.
return;
}
if (btState != BluetoothAdapter.STATE_ON) {
mState = STATE_WAITING_FOR_BLUETOOTH;
showBluetoothDialog();
return;
}
CachedBluetoothDevice device = getPairedKeyboard();
if (mState == STATE_WAITING_FOR_TABLET_MODE_EXIT || mState == STATE_WAITING_FOR_BLUETOOTH) {
if (device != null) {
// If we're just coming out of tablet mode or BT just turned on,
// then we want to go ahead and automatically connect to the
// keyboard. We want to avoid this in other cases because we might
// be spuriously called after the user has manually disconnected
// the keyboard, meaning we shouldn't try to automtically connect
// it again.
mState = STATE_PAIRED;
device.connect(false);
return;
}
mCachedDeviceManager.clearNonBondedDevices();
}
device = getDiscoveredKeyboard();
if (device != null) {
mState = STATE_PAIRING;
device.startPairing();
} else {
mState = STATE_WAITING_FOR_DEVICE_DISCOVERY;
startScanning();
}
}
use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project android_frameworks_base by DirtyUnicorns.
the class BluetoothControllerImpl method updateConnected.
private void updateConnected() {
// Make sure our connection state is up to date.
int state = mLocalBluetoothManager.getBluetoothAdapter().getConnectionState();
if (state != mConnectionState) {
mConnectionState = state;
mHandler.sendEmptyMessage(H.MSG_STATE_CHANGED);
}
if (mLastDevice != null && mLastDevice.isConnected()) {
// Our current device is still valid.
return;
}
mLastDevice = null;
for (CachedBluetoothDevice device : getDevices()) {
if (device.isConnected()) {
mLastDevice = device;
}
}
if (mLastDevice == null && mConnectionState == BluetoothAdapter.STATE_CONNECTED) {
// If somehow we think we are connected, but have no connected devices, we aren't
// connected.
mConnectionState = BluetoothAdapter.STATE_DISCONNECTED;
mHandler.sendEmptyMessage(H.MSG_STATE_CHANGED);
}
}
use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project android_frameworks_base by DirtyUnicorns.
the class BluetoothControllerImpl method dump.
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
pw.println("BluetoothController state:");
pw.print(" mLocalBluetoothManager=");
pw.println(mLocalBluetoothManager);
if (mLocalBluetoothManager == null) {
return;
}
pw.print(" mEnabled=");
pw.println(mEnabled);
pw.print(" mConnectionState=");
pw.println(stateToString(mConnectionState));
pw.print(" mLastDevice=");
pw.println(mLastDevice);
pw.print(" mCallbacks.size=");
pw.println(mHandler.mCallbacks.size());
pw.println(" Bluetooth Devices:");
for (CachedBluetoothDevice device : mLocalBluetoothManager.getCachedDeviceManager().getCachedDevicesCopy()) {
pw.println(" " + getDeviceString(device));
}
}
use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project android_frameworks_base by AOSPA.
the class BluetoothControllerImpl method dump.
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
pw.println("BluetoothController state:");
pw.print(" mLocalBluetoothManager=");
pw.println(mLocalBluetoothManager);
if (mLocalBluetoothManager == null) {
return;
}
pw.print(" mEnabled=");
pw.println(mEnabled);
pw.print(" mConnectionState=");
pw.println(stateToString(mConnectionState));
pw.print(" mLastDevice=");
pw.println(mLastDevice);
pw.print(" mCallbacks.size=");
pw.println(mHandler.mCallbacks.size());
pw.println(" Bluetooth Devices:");
for (CachedBluetoothDevice device : mLocalBluetoothManager.getCachedDeviceManager().getCachedDevicesCopy()) {
pw.println(" " + getDeviceString(device));
}
}
Aggregations