Search in sources :

Example 91 with CachedBluetoothDevice

use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class RemoteDeviceNameDialogFragment method getDevice.

@VisibleForTesting
CachedBluetoothDevice getDevice(Context context) {
    String deviceAddress = getArguments().getString(KEY_CACHED_DEVICE_ADDRESS);
    LocalBluetoothManager manager = Utils.getLocalBtManager(context);
    BluetoothDevice device = manager.getBluetoothAdapter().getRemoteDevice(deviceAddress);
    return manager.getCachedDeviceManager().findDevice(device);
}
Also used : BluetoothDevice(android.bluetooth.BluetoothDevice) CachedBluetoothDevice(com.android.settingslib.bluetooth.CachedBluetoothDevice) LocalBluetoothManager(com.android.settingslib.bluetooth.LocalBluetoothManager) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 92 with CachedBluetoothDevice

use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SavedBluetoothDeviceUpdater method onPreferenceClick.

@Override
public boolean onPreferenceClick(Preference preference) {
    final CachedBluetoothDevice device = ((BluetoothDevicePreference) preference).getBluetoothDevice();
    device.connect(true);
    return true;
}
Also used : CachedBluetoothDevice(com.android.settingslib.bluetooth.CachedBluetoothDevice)

Example 93 with CachedBluetoothDevice

use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ForgetDeviceDialogFragment method getDevice.

@VisibleForTesting
CachedBluetoothDevice getDevice(Context context) {
    String deviceAddress = getArguments().getString(KEY_DEVICE_ADDRESS);
    LocalBluetoothManager manager = Utils.getLocalBtManager(context);
    BluetoothDevice device = manager.getBluetoothAdapter().getRemoteDevice(deviceAddress);
    return manager.getCachedDeviceManager().findDevice(device);
}
Also used : BluetoothDevice(android.bluetooth.BluetoothDevice) CachedBluetoothDevice(com.android.settingslib.bluetooth.CachedBluetoothDevice) LocalBluetoothManager(com.android.settingslib.bluetooth.LocalBluetoothManager) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 94 with CachedBluetoothDevice

use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DevicePickerFragmentTest method callingPackageIsEqualToLaunchPackage_sendBroadcastToLaunchPackage.

@Test
public void callingPackageIsEqualToLaunchPackage_sendBroadcastToLaunchPackage() {
    final CachedBluetoothDevice cachedDevice = mock(CachedBluetoothDevice.class);
    final BluetoothDevice bluetoothDevice = mock(BluetoothDevice.class);
    final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
    when(cachedDevice.getDevice()).thenReturn(bluetoothDevice);
    mFragment.mSelectedDevice = bluetoothDevice;
    mFragment.mLaunchPackage = "com.android.settings";
    mFragment.mLaunchClass = "com.android.settings.bluetooth.BluetoothPermissionActivity";
    mFragment.mCallingAppPackageName = "com.android.settings";
    mFragment.onDeviceBondStateChanged(cachedDevice, BluetoothDevice.BOND_BONDED);
    verify(mContext).sendBroadcast(intentCaptor.capture(), eq("android.permission.BLUETOOTH_ADMIN"));
    assertThat(intentCaptor.getValue().getComponent().getPackageName()).isEqualTo(mFragment.mLaunchPackage);
}
Also used : CachedBluetoothDevice(com.android.settingslib.bluetooth.CachedBluetoothDevice) BluetoothDevice(android.bluetooth.BluetoothDevice) CachedBluetoothDevice(com.android.settingslib.bluetooth.CachedBluetoothDevice) Intent(android.content.Intent) Test(org.junit.Test)

Example 95 with CachedBluetoothDevice

use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BluetoothDevicesSlice method getBluetoothRowBuilder.

private List<ListBuilder.RowBuilder> getBluetoothRowBuilder() {
    // According to Bluetooth devices to create row builders.
    final List<ListBuilder.RowBuilder> bluetoothRows = new ArrayList<>();
    List<CachedBluetoothDevice> bluetoothDevices = getConnectedBluetoothDevices();
    for (CachedBluetoothDevice bluetoothDevice : bluetoothDevices) {
        final ListBuilder.RowBuilder rowBuilder = new ListBuilder.RowBuilder().setTitleItem(getBluetoothDeviceIcon(bluetoothDevice), ListBuilder.ICON_IMAGE).setTitle(bluetoothDevice.getName()).setSubtitle(bluetoothDevice.getConnectionSummary());
        if (bluetoothDevice.isConnectedA2dpDevice()) {
            // For available media devices, the primary action is to activate audio stream and
            // add setting icon to the end to link detail page.
            rowBuilder.setPrimaryAction(buildMediaBluetoothAction(bluetoothDevice));
            rowBuilder.addEndItem(buildBluetoothDetailDeepLinkAction(bluetoothDevice));
        } else {
            // For other devices, the primary action is to link detail page.
            rowBuilder.setPrimaryAction(buildBluetoothDetailDeepLinkAction(bluetoothDevice));
        }
        bluetoothRows.add(rowBuilder);
    }
    return bluetoothRows;
}
Also used : CachedBluetoothDevice(com.android.settingslib.bluetooth.CachedBluetoothDevice) ArrayList(java.util.ArrayList) ListBuilder(androidx.slice.builders.ListBuilder)

Aggregations

CachedBluetoothDevice (com.android.settingslib.bluetooth.CachedBluetoothDevice)104 BluetoothDevice (android.bluetooth.BluetoothDevice)38 LocalBluetoothManager (com.android.settingslib.bluetooth.LocalBluetoothManager)30 CachedBluetoothDeviceManager (com.android.settingslib.bluetooth.CachedBluetoothDeviceManager)15 VisibleForTesting (com.android.internal.annotations.VisibleForTesting)12 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)8 DialogInterface (android.content.DialogInterface)7 OnClickListener (android.view.View.OnClickListener)7 MapProfile (com.android.settingslib.bluetooth.MapProfile)7 VisibleForTesting (androidx.annotation.VisibleForTesting)6 Intent (android.content.Intent)5 Preference (androidx.preference.Preference)4 Bundle (android.os.Bundle)2 ListBuilder (androidx.slice.builders.ListBuilder)2 SubSettingLauncher (com.android.settings.core.SubSettingLauncher)2 GearPreference (com.android.settings.widget.GearPreference)2 LocalBluetoothProfile (com.android.settingslib.bluetooth.LocalBluetoothProfile)2 Iterator (java.util.Iterator)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2