Search in sources :

Example 31 with CachedBluetoothDevice

use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project platform_packages_apps_Settings by BlissRoms.

the class BluetoothSettings method initDevicePreference.

/**
 * Add a listener, which enables the advanced settings icon.
 *
 * @param preference the newly added preference
 */
@Override
void initDevicePreference(BluetoothDevicePreference preference) {
    preference.setOrder(PAIRED_DEVICE_ORDER);
    CachedBluetoothDevice cachedDevice = preference.getCachedDevice();
    if (cachedDevice.getBondState() == BluetoothDevice.BOND_BONDED) {
        // Only paired device have an associated advanced settings screen
        preference.setOnGearClickListener(mDeviceProfilesListener);
    }
}
Also used : CachedBluetoothDevice(com.android.settingslib.bluetooth.CachedBluetoothDevice)

Example 32 with CachedBluetoothDevice

use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project platform_packages_apps_Settings by BlissRoms.

the class DeviceProfilesSettings method askDisconnect.

private void askDisconnect(Context context, final LocalBluetoothProfile profile) {
    // local reference for callback
    final CachedBluetoothDevice device = mCachedDevice;
    String name = device.getName();
    if (TextUtils.isEmpty(name)) {
        name = context.getString(R.string.bluetooth_device);
    }
    String profileName = context.getString(profile.getNameResource(device.getDevice()));
    String title = context.getString(R.string.bluetooth_disable_profile_title);
    String message = context.getString(R.string.bluetooth_disable_profile_message, profileName, name);
    DialogInterface.OnClickListener disconnectListener = new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            device.disconnect(profile);
            profile.setPreferred(device.getDevice(), false);
            if (profile instanceof MapProfile) {
                device.setMessagePermissionChoice(BluetoothDevice.ACCESS_REJECTED);
            }
            refreshProfilePreference(findProfile(profile.toString()), profile);
        }
    };
    mDisconnectDialog = Utils.showDisconnectDialog(context, mDisconnectDialog, disconnectListener, title, Html.fromHtml(message));
}
Also used : MapProfile(com.android.settingslib.bluetooth.MapProfile) CachedBluetoothDevice(com.android.settingslib.bluetooth.CachedBluetoothDevice) DialogInterface(android.content.DialogInterface) OnClickListener(android.view.View.OnClickListener)

Example 33 with CachedBluetoothDevice

use of com.android.settingslib.bluetooth.CachedBluetoothDevice in project platform_packages_apps_Settings by BlissRoms.

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(com.android.internal.annotations.VisibleForTesting)

Example 34 with CachedBluetoothDevice

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

the class DevicePickerFragmentTest method callingPackageIsNotEqualToLaunchPackage_broadcastNotSend.

@Test
public void callingPackageIsNotEqualToLaunchPackage_broadcastNotSend() {
    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.fake.settings";
    mFragment.mLaunchClass = "com.android.settings.bluetooth.BluetoothPermissionActivity";
    mFragment.mCallingAppPackageName = "com.android.settings";
    mFragment.onDeviceBondStateChanged(cachedDevice, BluetoothDevice.BOND_BONDED);
    verify(mContext, never()).sendBroadcast(intentCaptor.capture());
}
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 35 with CachedBluetoothDevice

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

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;
}
Also used : BluetoothDevice(android.bluetooth.BluetoothDevice) CachedBluetoothDevice(com.android.settingslib.bluetooth.CachedBluetoothDevice) Iterator(java.util.Iterator) VisibleForTesting(androidx.annotation.VisibleForTesting)

Aggregations

CachedBluetoothDevice (com.android.settingslib.bluetooth.CachedBluetoothDevice)85 BluetoothDevice (android.bluetooth.BluetoothDevice)29 LocalBluetoothManager (com.android.settingslib.bluetooth.LocalBluetoothManager)29 CachedBluetoothDeviceManager (com.android.settingslib.bluetooth.CachedBluetoothDeviceManager)14 VisibleForTesting (com.android.internal.annotations.VisibleForTesting)13 DialogInterface (android.content.DialogInterface)7 OnClickListener (android.view.View.OnClickListener)7 MapProfile (com.android.settingslib.bluetooth.MapProfile)7 Intent (android.content.Intent)3 VisibleForTesting (androidx.annotation.VisibleForTesting)3 Preference (androidx.preference.Preference)2 LocalBluetoothProfile (com.android.settingslib.bluetooth.LocalBluetoothProfile)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 IntentFilter (android.content.IntentFilter)1 Bundle (android.os.Bundle)1 ListBuilder (androidx.slice.builders.ListBuilder)1 SubSettingLauncher (com.android.settings.core.SubSettingLauncher)1 GearPreference (com.android.settings.widget.GearPreference)1 PbapServerProfile (com.android.settingslib.bluetooth.PbapServerProfile)1