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)); } }
public BluetoothClassAssert hasMajorDeviceClass(int majorDeviceClass) { isNotNull(); int actualMajorDeviceClass = actual.getMajorDeviceClass(); assertThat(majorDeviceClass) // .overridingErrorMessage("Expected major device class <%s> but was <%s>.", majorDeviceClassToString(majorDeviceClass), majorDeviceClassToString(actualMajorDeviceClass)) // .isEqualTo(majorDeviceClass); return this; }
public BluetoothClassAssert hasService(int service) { isNotNull(); assertThat(actual.hasService(service)) // .overridingErrorMessage("Expected to have service <%s> but did not.", serviceToString(service)) // .isTrue(); return this; }
BluetoothClass cls = device.getBluetoothClass(); switch (cls.getMajorDeviceClass()) { case BluetoothClass.Device.Major.PERIPHERAL: switch (cls.getDeviceClass() & 0x05C0) { case 0x0540: // Keyboard - 1314 break; case 0x05C0: // Keyboard + mouse combo. break; case 0x0580: // Mouse - 1408 break; default: // Other. break; } }
public Fragment getItem(int i){ switch (i) { case 0: // The first section of the app is the most interesting -- it offers // a launchpad into the other demonstrations in this example application. return new LaunchpadSectionFragment(); case 1: return new BluetoothClass(); default: // The GPS section of the app . Fragment fragment = new DummySectionFragment(); Bundle args = new Bundle(); args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, i + 1); fragment.setArguments(args); return fragment; } }
type = (isMiscOrUncategorized(device.getBluetoothClass().getDeviceClass())) ? device.getBluetoothClass().getMajorDeviceClass() : device.getBluetoothClass().getDeviceClass(); } else { type = btClass.getDeviceClass();
public BluetoothClassAssert hasDeviceClass(int deviceClass) { isNotNull(); int actualClass = actual.getDeviceClass(); assertThat(actualClass) // .overridingErrorMessage("Expected device class <%s> but was <%s>.", deviceClassToString(deviceClass), deviceClassToString(actualClass)) // .isEqualTo(actualClass); return this; }
int type = BluetoothClass.Device.Major.UNCATEGORIZED; if (bluetoothClass != null) { final int deviceClass = bluetoothClass.getDeviceClass(); type = (deviceClass == 0 || deviceClass == BluetoothClass.Device.Major.UNCATEGORIZED) ? bluetoothClass.getMajorDeviceClass() : deviceClass; bluetoothClass == null ? null : bluetoothClass.getDeviceClass()); final SharedPreferences prefs = mainActivity.getSharedPreferences( ListFragment.SHARED_PREFS, 0 );
/** * Gets the bluetooth device major class name. * * @return the bluetooth device major class name */ public String getBluetoothDeviceMajorClassName() { return BluetoothClassResolver.resolveMajorDeviceClass(mDevice.getBluetoothClass().getMajorDeviceClass()); }
public BluetoothClassAssert doesNotHave(int service) { isNotNull(); assertThat(actual.hasService(service)) // .overridingErrorMessage("Expected to not have service <%s> but did.", serviceToString(service)) // .isFalse(); return this; }
int deviceClass = bluetoothClass.getDeviceClass(); if (deviceClass == BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE || deviceClass == BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET)
public BluetoothClassAssert hasMajorDeviceClass(int majorDeviceClass) { isNotNull(); int actualMajorDeviceClass = actual.getMajorDeviceClass(); assertThat(majorDeviceClass) // .overridingErrorMessage("Expected major device class <%s> but was <%s>.", majorDeviceClassToString(majorDeviceClass), majorDeviceClassToString(actualMajorDeviceClass)) // .isEqualTo(majorDeviceClass); return this; }
public BluetoothClassAssert doesNotHave(int service) { isNotNull(); assertThat(actual.hasService(service)) // .overridingErrorMessage("Expected to not have service <%s> but did.", serviceToString(service)) // .isFalse(); return this; }
BluetoothClass bluetoothClass = bluetoothDevice.getBluetoothClass(); if(bluetoothClass.getDeviceClass() == BluetoothClass.Device.AUDIO_VIDEO_HEADPHONES) { // allow user to select this device. I'm not sure exactly which type // headphones will be but this is a good guess. You can connect to // your Bluetooth headset to find out for sure. }
/** * 扫描枪是否连接 * @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; }
public BluetoothClassAssert hasService(int service) { isNotNull(); assertThat(actual.hasService(service)) // .overridingErrorMessage("Expected to have service <%s> but did not.", serviceToString(service)) // .isTrue(); return this; }
/** * Gets the bluetooth device class name. * * @return the bluetooth device class name */ public String getBluetoothDeviceClassName() { return BluetoothClassResolver.resolveDeviceClass(mDevice.getBluetoothClass().getDeviceClass()); }
@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()); } }
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; }
public BluetoothClassAssert hasDeviceClass(int deviceClass) { isNotNull(); int actualClass = actual.getDeviceClass(); assertThat(actualClass) // .overridingErrorMessage("Expected device class <%s> but was <%s>.", deviceClassToString(deviceClass), deviceClassToString(actualClass)) // .isEqualTo(actualClass); return this; }