boolean isCandidateDevice(BluetoothDevice device) { int deviceClass=device.getBluetoothClass().getDeviceClass(); return(((deviceClass & BluetoothClass.Device.Major.COMPUTER)== BluetoothClass.Device.Major.COMPUTER) || ((deviceClass & BluetoothClass.Device.Major.PHONE)== BluetoothClass.Device.Major.PHONE) || ((deviceClass & BluetoothClass.Device.Major.AUDIO_VIDEO)== BluetoothClass.Device.Major.AUDIO_VIDEO)); } }
BluetoothClass bluetoothClass = mConnectedHeadset.getBluetoothClass(); if (bluetoothClass != null)
/** * Gets the bluetooth device class name. * * @return the bluetooth device class name */ public String getBluetoothDeviceClassName() { return BluetoothClassResolver.resolveDeviceClass(mDevice.getBluetoothClass().getDeviceClass()); }
/** * Gets the bluetooth device major class name. * * @return the bluetooth device major class name */ public String getBluetoothDeviceMajorClassName() { return BluetoothClassResolver.resolveMajorDeviceClass(mDevice.getBluetoothClass().getMajorDeviceClass()); }
public Set<BluetoothService> getBluetoothDeviceKnownSupportedServices() { if (mServiceSet == null) { synchronized (this) { if (mServiceSet == null) { final Set<BluetoothService> serviceSet = new HashSet<>(); for (final BluetoothService service : BluetoothService.values()) { if (mDevice.getBluetoothClass().hasService(service.getAndroidConstant())) { serviceSet.add(service); } } mServiceSet = Collections.unmodifiableSet(serviceSet); } } } return mServiceSet; }
/** * 扫描枪是否连接 * @return */ public boolean hasScanGun() { if (mBluetoothAdapter == null) { return false; } Set<BluetoothDevice> blueDevices = mBluetoothAdapter.getBondedDevices(); if (blueDevices == null || blueDevices.size() <= 0) { return false; } for (Iterator<BluetoothDevice> iterator = blueDevices.iterator(); iterator.hasNext(); ) { BluetoothDevice bluetoothDevice = iterator.next(); if (bluetoothDevice.getBluetoothClass().getMajorDeviceClass() == BluetoothClass.Device.Major.PERIPHERAL) { mDeviceName = bluetoothDevice.getName(); return isInputDeviceExist(mDeviceName); } } return false; }
for (BluetoothDevice device : mBluetoothAdapter.getBondedDevices()) { names.add(device.getName()); images.add(getDrawableByMajorClass(device.getBluetoothClass().getMajorDeviceClass())); addresses.add(device.getAddress());
String deviceBTMajorClass = getBTMajorDeviceClass(device .getBluetoothClass() .getMajorDeviceClass()); btArrayAdapter.add(deviceBTName + "\n"
@Override protected void onPrepareDialogBuilder(AlertDialog.Builder builder) { super.onPrepareDialogBuilder(builder); connectionState = hidDeviceProfile.getConnectionState(device); if (connectionState == BluetoothProfile.STATE_CONNECTED || connectionState == BluetoothProfile.STATE_CONNECTING) { builder.setPositiveButton( R.string.pref_bluetooth_disconnect, (dialog, which) -> hidDataSender.requestConnect(null)); } else { builder.setPositiveButton( R.string.pref_bluetooth_connect, (dialog, which) -> hidDataSender.requestConnect(device)); } if (connectionState == BluetoothProfile.STATE_CONNECTED) { builder.setNegativeButton( R.string.pref_bluetooth_select, (dialog, which) -> hidDataSender.requestConnect(device)); } else if (device.getBluetoothClass() != null && device.getBluetoothClass().getMajorDeviceClass() != BluetoothClass.Device.Major.PHONE) { builder.setNegativeButton( R.string.pref_bluetooth_forget, (dialog, which) -> requestUnpair()); } }
private void updateClass() { if (device.getBluetoothClass() == null) { return; } switch (device.getBluetoothClass().getDeviceClass()) { case BluetoothClass.Device.PHONE_CELLULAR: case BluetoothClass.Device.PHONE_SMART: case BluetoothClass.Device.PHONE_UNCATEGORIZED: setIcon(R.drawable.ic_bt_phone); break; case BluetoothClass.Device.AUDIO_VIDEO_HEADPHONES: case BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET: case BluetoothClass.Device.AUDIO_VIDEO_LOUDSPEAKER: setIcon(R.drawable.ic_bt_headset); break; case BluetoothClass.Device.WEARABLE_WRIST_WATCH: setIcon(R.drawable.ic_bt_watch); break; case BluetoothClass.Device.WEARABLE_GLASSES: setIcon(R.drawable.ic_bt_glass); break; default: // fall out } notifyChanged(); }
String deviceBTMajorClass = getBTMajorDeviceClass(device.getBluetoothClass().getMajorDeviceClass()); if (D) Log.d(TAG, "deviceBTMajorClass"+deviceBTMajorClass);
final int state = intent.getIntExtra(BluetoothHeadset.EXTRA_STATE, -1); final int previousState = intent.getIntExtra(BluetoothHeadset.EXTRA_PREVIOUS_STATE, -1); final String deviceInfo = device.getName() + "\n" + device.getAddress() + " " + (device.getBluetoothClass() != null ? device.getBluetoothClass() : "<unknown class>");
/*package*/BluetoothDeviceInfo(final BluetoothDevice device) { name = device.getName(); address = device.getAddress(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { type = device.getType(); } else { type = 0; } final BluetoothClass clazz = device.getBluetoothClass(); deviceClass = clazz != null ? clazz.getDeviceClass() : 0; bondState = device.getBondState(); }
final int state = intent.getIntExtra(BluetoothHeadset.EXTRA_STATE, -1); final int previousState = intent.getIntExtra(BluetoothHeadset.EXTRA_PREVIOUS_STATE, -1); final String deviceInfo = device.getName() + "\n" + device.getAddress() + " " + (device.getBluetoothClass() != null ? device.getBluetoothClass() : "<unknown class>");
BluetoothClass bluetoothClass = mConnectedHeadset.getBluetoothClass(); if (bluetoothClass != null) {
BluetoothClass bluetoothClass = mConnectedHeadset.getBluetoothClass(); if (bluetoothClass != null) {
type = (isMiscOrUncategorized(device.getBluetoothClass().getDeviceClass())) ? device.getBluetoothClass().getMajorDeviceClass() : device.getBluetoothClass().getDeviceClass(); } else { type = btClass.getDeviceClass();
final BluetoothClass bluetoothClass = device.getBluetoothClass(); int type = BluetoothClass.Device.Major.UNCATEGORIZED; if (bluetoothClass != null) {