use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BluetoothDevicesSlice method getConnectedBluetoothDevices.
@VisibleForTesting
List<CachedBluetoothDevice> getConnectedBluetoothDevices() {
final List<CachedBluetoothDevice> bluetoothDeviceList = new ArrayList<>();
// If Bluetooth is disable, skip to get the Bluetooth devices.
if (!BluetoothAdapter.getDefaultAdapter().isEnabled()) {
Log.i(TAG, "Cannot get Bluetooth devices, Bluetooth is disabled.");
return bluetoothDeviceList;
}
// Get the Bluetooth devices from LocalBluetoothManager.
final LocalBluetoothManager bluetoothManager = com.android.settings.bluetooth.Utils.getLocalBtManager(mContext);
if (bluetoothManager == null) {
Log.i(TAG, "Cannot get Bluetooth devices, Bluetooth is unsupported.");
return bluetoothDeviceList;
}
final Collection<CachedBluetoothDevice> cachedDevices = bluetoothManager.getCachedDeviceManager().getCachedDevicesCopy();
// Get all connected devices and sort them.
return cachedDevices.stream().filter(device -> device.getDevice().isConnected()).sorted(COMPARATOR).collect(Collectors.toList());
}
use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BluetoothDeviceUpdater method addPreference.
/**
* Add the {@link Preference} that represents the {@code cachedDevice}
*/
protected void addPreference(CachedBluetoothDevice cachedDevice) {
final BluetoothDevice device = cachedDevice.getDevice();
if (!mPreferenceMap.containsKey(device)) {
BluetoothDevicePreference btPreference = new BluetoothDevicePreference(mPrefContext, cachedDevice, true);
btPreference.setOnGearClickListener(mDeviceProfilesListener);
if (this instanceof Preference.OnPreferenceClickListener) {
btPreference.setOnPreferenceClickListener((Preference.OnPreferenceClickListener) this);
}
mPreferenceMap.put(device, btPreference);
mDevicePreferenceCallback.onDeviceAdded(btPreference);
}
}
use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BluetoothDeviceUpdater method launchDeviceDetails.
/**
* Get {@link CachedBluetoothDevice} from {@link Preference} and it is used to init
* {@link SubSettingLauncher} to launch {@link BluetoothDeviceDetailsFragment}
*/
protected void launchDeviceDetails(Preference preference) {
final CachedBluetoothDevice device = ((BluetoothDevicePreference) preference).getBluetoothDevice();
if (device == null) {
return;
}
final Bundle args = new Bundle();
args.putString(BluetoothDeviceDetailsFragment.KEY_DEVICE_ADDRESS, device.getDevice().getAddress());
new SubSettingLauncher(mFragment.getContext()).setDestination(BluetoothDeviceDetailsFragment.class.getName()).setArguments(args).setTitleRes(R.string.device_details_title).setSourceMetricsCategory(mFragment.getMetricsCategory()).launch();
}
use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ConnectedBluetoothDeviceUpdater method addPreference.
@Override
protected void addPreference(CachedBluetoothDevice cachedDevice) {
super.addPreference(cachedDevice);
final BluetoothDevice device = cachedDevice.getDevice();
if (mPreferenceMap.containsKey(device)) {
final BluetoothDevicePreference btPreference = (BluetoothDevicePreference) mPreferenceMap.get(device);
btPreference.setOnGearClickListener(null);
btPreference.hideSecondTarget(true);
btPreference.setOnPreferenceClickListener((Preference p) -> {
launchDeviceDetails(p);
return true;
});
}
}
use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DevicePickerFragment method onDeviceBondStateChanged.
public void onDeviceBondStateChanged(CachedBluetoothDevice cachedDevice, int bondState) {
BluetoothDevice device = cachedDevice.getDevice();
if (!device.equals(mSelectedDevice)) {
return;
}
if (bondState == BluetoothDevice.BOND_BONDED) {
sendDevicePickedIntent(device);
finish();
} else if (bondState == BluetoothDevice.BOND_NONE) {
enableScanning();
}
}
Aggregations