Java Code Examples for android.bluetooth.BluetoothClass

The following are top voted examples for showing how to use android.bluetooth.BluetoothClass. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: BlueDroid   File: Device.java   Source Code and License 6 votes vote down vote up
public int getDeviceClassIcon() {
    Log.d("TAG", "Device.getDeviceClass() = " + getDeviceClass());

    final int deviceClass = getDeviceClass();
    final int deviceClassMasked = deviceClass & 0x1F00;

    if (deviceClass == BluetoothClass.Device.AUDIO_VIDEO_HEADPHONES) {
        return R.drawable.headphone;
    } else if (deviceClass == BluetoothClass.Device.AUDIO_VIDEO_MICROPHONE) {
        return R.drawable.microphone;
    } else if (deviceClassMasked == BluetoothClass.Device.Major.COMPUTER) {
        return R.drawable.computer;
    } else if (deviceClassMasked == BluetoothClass.Device.Major.PHONE) {
        return R.drawable.cell_phone;
    } else if (deviceClassMasked == BluetoothClass.Device.Major.HEALTH) {
        return R.drawable.heart;
    } else {
        return R.drawable.bluetooth;
    }
}
 
Example 2
Project: truth-android   File: BluetoothClassSubject.java   Source Code and License 6 votes vote down vote up
public static SubjectFactory<BluetoothClassSubject, BluetoothClass> type() {
  return new SubjectFactory<BluetoothClassSubject, BluetoothClass>() {
    @Override
    public BluetoothClassSubject getSubject(FailureStrategy fs, BluetoothClass that) {
      return new BluetoothClassSubject(fs, that);
    }
  };
}
 
Example 3
Project: mytracks   File: BluetoothDeviceUtils.java   Source Code and License 6 votes vote down vote up
/**
 * Populates the device names and the device addresses with all the suitable
 * bluetooth devices.
 * 
 * @param bluetoothAdapter the bluetooth adapter
 * @param deviceNames list of device names
 * @param deviceAddresses list of device addresses
 */
public static void populateDeviceLists(
    BluetoothAdapter bluetoothAdapter, List<String> deviceNames, List<String> deviceAddresses) {
  // Ensure the bluetooth adapter is not in discovery mode.
  bluetoothAdapter.cancelDiscovery();

  Set<BluetoothDevice> pairedDevices = bluetoothAdapter.getBondedDevices();
  for (BluetoothDevice device : pairedDevices) {
    BluetoothClass bluetoothClass = device.getBluetoothClass();
    if (bluetoothClass != null) {
      // Not really sure what we want, but I know what we don't want.
      switch (bluetoothClass.getMajorDeviceClass()) {
        case BluetoothClass.Device.Major.COMPUTER:
        case BluetoothClass.Device.Major.PHONE:
          break;
        default:
          deviceAddresses.add(device.getAddress());
          deviceNames.add(device.getName());
      }
    }
  }
}
 
Example 4
Project: gadgetbridge_artikcloud   File: AbstractDeviceCoordinator.java   Source Code and License 6 votes vote down vote up
public boolean isHealthWearable(BluetoothDevice device) {
    BluetoothClass bluetoothClass = device.getBluetoothClass();
    if (bluetoothClass == null) {
        LOG.warn("unable to determine bluetooth device class of " + device);
        return false;
    }
    if (bluetoothClass.getMajorDeviceClass() == BluetoothClass.Device.Major.WEARABLE
        || bluetoothClass.getMajorDeviceClass() == BluetoothClass.Device.Major.UNCATEGORIZED) {
        int deviceClasses =
                BluetoothClass.Device.HEALTH_BLOOD_PRESSURE
                | BluetoothClass.Device.HEALTH_DATA_DISPLAY
                | BluetoothClass.Device.HEALTH_PULSE_RATE
                | BluetoothClass.Device.HEALTH_WEIGHING
                | BluetoothClass.Device.HEALTH_UNCATEGORIZED
                | BluetoothClass.Device.HEALTH_PULSE_OXIMETER
                | BluetoothClass.Device.HEALTH_GLUCOSE;

        return (bluetoothClass.getDeviceClass() & deviceClasses) != 0;
    }
    return false;
}
 
Example 5
Project: scangon   File: ScanGunKeyEventHelper.java   Source Code and License 6 votes vote down vote up
/**
 * 扫描枪是否连接
 * @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;

}
 
Example 6
Project: nxt-remote-control   File: ChooseDeviceActivity.java   Source Code and License 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    
    if (BluetoothDevice.ACTION_FOUND.equals(action)) {
        BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
        if ((device.getBondState() != BluetoothDevice.BOND_BONDED) && (device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.TOY_ROBOT)) {
            mNewDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
            findViewById(R.id.title_new_devices).setVisibility(View.VISIBLE);
            findViewById(R.id.no_devices).setVisibility(View.GONE);
        }
    } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
        setProgressBarIndeterminateVisibility(false);
        setTitle("Select device");
        findViewById(R.id.button_scan).setVisibility(View.VISIBLE);
    }
}
 
Example 7
Project: moveon   File: BluetoothDeviceUtils.java   Source Code and License 6 votes vote down vote up
/**
 * Populates the device names and the device addresses with all the suitable
 * bluetooth devices.
 * 
 * @param bluetoothAdapter
 *            the bluetooth adapter
 * @param deviceNames
 *            list of device names
 * @param deviceAddresses
 *            list of device addresses
 */
public static void populateDeviceLists(BluetoothAdapter bluetoothAdapter, List<String> deviceNames,
		List<String> deviceAddresses) {
	// Ensure the bluetooth adapter is not in discovery mode.
	bluetoothAdapter.cancelDiscovery();

	Set<BluetoothDevice> pairedDevices = bluetoothAdapter.getBondedDevices();
	for (BluetoothDevice device : pairedDevices) {
		BluetoothClass bluetoothClass = device.getBluetoothClass();
		if (bluetoothClass != null) {
			// Not really sure what we want, but I know what we don't want.
			switch (bluetoothClass.getMajorDeviceClass()) {
			case BluetoothClass.Device.Major.COMPUTER:
			case BluetoothClass.Device.Major.PHONE:
				break;
			default:
				deviceAddresses.add(device.getAddress());
				deviceNames.add(device.getName());
			}
		}
	}
}
 
Example 8
Project: EasyBluetooth   File: BTDataPersistence.java   Source Code and License 6 votes vote down vote up
public static void getBluetoothDevices(){
    BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

    mBluetoothAdapter.enable();
    btDeviceNames = new ArrayList<String>();
    Set<BluetoothDevice> a= mBluetoothAdapter.getBondedDevices();
    Iterator I=a.iterator();
    BluetoothDevice n=null;
    while(I.hasNext()) {
        n = (BluetoothDevice) I.next();
        BluetoothClass x=n.getBluetoothClass();
        if(x!=null){
            int xc=x.getDeviceClass();
            if((xc==BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO)||
                    (xc==BluetoothClass.Device.AUDIO_VIDEO_PORTABLE_AUDIO)||
                    (xc==BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET)||
                    (xc==BluetoothClass.Device.AUDIO_VIDEO_LOUDSPEAKER))
            {
                String k = n.getName();
                btDeviceNames.add(k);
            }
        }
    }
}
 
Example 9
Project: WearMusicPlayer   File: MainActivity.java   Source Code and License 6 votes vote down vote up
private boolean isContainBTHeadphone(BluetoothAdapter mBluetoothAdapter) {
    Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
    // If there are paired devices
    if (pairedDevices.size() > 0) {
        // Loop through paired devices
        for (BluetoothDevice device : pairedDevices) {
            if (device.getBluetoothClass().getDeviceClass() ==
                    BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO) {
                return true;
            } else if (device.getBluetoothClass().getDeviceClass() ==
                    BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE) {
                return true;
            } else if (device.getBluetoothClass().getDeviceClass() ==
                    BluetoothClass.Device.AUDIO_VIDEO_HEADPHONES) {
                return true;
            } else if (device.getBluetoothClass().getDeviceClass() ==
                    BluetoothClass.Device.AUDIO_VIDEO_LOUDSPEAKER) {
                return true;
            } else if (device.getBluetoothClass().getDeviceClass() ==
                    BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET) {
                return true;
            }
        }
    }
    return false;
}
 
Example 10
Project: an2linuxclient   File: BluetoothPairedListDialog.java   Source Code and License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);

    View view = inflater.inflate(R.layout.view_add_bluetooth_server, container);

    ListView listViewBtPairedPCs = (ListView) view.findViewById(R.id.listViewBtPairedPCs);

    ArrayList<BluetoothDevice> pairedBluetoothList = new ArrayList<>();

    BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    Set<BluetoothDevice> pairedDevices = bluetoothAdapter.getBondedDevices();

    if (pairedDevices.size() > 0) {
        for (BluetoothDevice device : pairedDevices) {
            if(device.getBluetoothClass().getMajorDeviceClass() == BluetoothClass.Device.Major.COMPUTER) {
                pairedBluetoothList.add(device);
            }
        }
        if (pairedBluetoothList.size() == 0) {
            Toast.makeText(getActivity().getApplicationContext(), R.string.bluetooth_no_paired_found, Toast.LENGTH_LONG).show();
            return null;
        }
    } else {
        Toast.makeText(getActivity().getApplicationContext(), R.string.bluetooth_no_paired_found, Toast.LENGTH_LONG).show();
        return null;
    }
    BluetoothPairedDevicesAdapter adapter = new BluetoothPairedDevicesAdapter(getActivity(), pairedBluetoothList, this);
    listViewBtPairedPCs.setAdapter(adapter);
    return view;
}
 
Example 11
Project: mobile-store   File: BluetoothFinder.java   Source Code and License 5 votes vote down vote up
private void onDeviceFound(BluetoothDevice device) {
    if (device != null && device.getName() != null &&
            (device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.COMPUTER_HANDHELD_PC_PDA ||
            device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.COMPUTER_PALM_SIZE_PC_PDA ||
            device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.PHONE_SMART)) {
        subscriber.onNext(new BluetoothPeer(device));
    }
}
 
Example 12
Project: PeSanKita-android   File: BluetoothStateManager.java   Source Code and License 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    if (intent == null) return;
    Log.w(TAG, "onReceive");

    synchronized (LOCK) {
        if (getScoChangeIntent().equals(intent.getAction())) {
            int status = intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE, AudioManager.SCO_AUDIO_STATE_ERROR);

            if (status == AudioManager.SCO_AUDIO_STATE_CONNECTED) {
                if (Build.VERSION.SDK_INT >= 11 && bluetoothHeadset != null) {
                    List<BluetoothDevice> devices = bluetoothHeadset.getConnectedDevices();

                    for (BluetoothDevice device : devices) {
                        if (bluetoothHeadset.isAudioConnected(device)) {
                            int deviceClass = device.getBluetoothClass().getDeviceClass();

                            if (deviceClass == BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE ||
                                    deviceClass == BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO ||
                                    deviceClass == BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET)
                            {
                                scoConnection = ScoConnection.CONNECTED;

                                if (wantsConnection) {
                                    AudioManager audioManager = ServiceUtil.getAudioManager(context);
                                    audioManager.setBluetoothScoOn(true);
                                }
                            }
                        }
                    }

                }
            }
        }
    }

    handleBluetoothStateChange();
}
 
Example 13
Project: CSipSimple   File: BluetoothUtils8.java   Source Code and License 5 votes vote down vote up
public boolean canBluetooth() {
	// Detect if any bluetooth a device is available for call
	if (bluetoothAdapter == null) {
	    // Device does not support Bluetooth
		return false;
	}
	boolean hasConnectedDevice = false;
	//If bluetooth is on
	if(bluetoothAdapter.isEnabled()) {
		
		//We get all bounded bluetooth devices
		// bounded is not enough, should search for connected devices....
		Set<BluetoothDevice> pairedDevices = bluetoothAdapter.getBondedDevices();
		for(BluetoothDevice device : pairedDevices) {
			BluetoothClass bluetoothClass = device.getBluetoothClass();
               if (bluetoothClass != null) {
               	int deviceClass = bluetoothClass.getDeviceClass();
               	if(bluetoothClass.hasService(Service.RENDER) ||
               		deviceClass == Device.AUDIO_VIDEO_WEARABLE_HEADSET ||
               		deviceClass == Device.AUDIO_VIDEO_CAR_AUDIO ||
               		deviceClass == Device.AUDIO_VIDEO_HANDSFREE ) {
                    	//And if any can be used as a audio handset
                    	hasConnectedDevice = true;
                    	break;
               	}
			}
		}
	}
	boolean retVal = hasConnectedDevice && audioManager.isBluetoothScoAvailableOffCall();
	Log.d(THIS_FILE, "Can I do BT ? "+retVal);
	return retVal;
}
 
Example 14
Project: LittleBitLouder   File: BluetoothReceiver.java   Source Code and License 5 votes vote down vote up
public boolean foundDevice (BluetoothDevice device)
{
    boolean resultIsNew = false;

    if (device != null && device.getName() != null &&
            (device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.COMPUTER_HANDHELD_PC_PDA ||
                    device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.COMPUTER_PALM_SIZE_PC_PDA ||
                    device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.PHONE_SMART)) {


        if (mPairedDevicesOnly && device.getBondState() == BluetoothDevice.BOND_NONE)
            return false; //we can only support paired devices


        if (!mFoundDevices.containsKey(device.getAddress())) {
            mFoundDevices.put(device.getAddress(), device);
            resultIsNew = true;

            if (mNearbyListener != null) {
                Neighbor neighbor = new Neighbor(device.getAddress(),device.getName(),Neighbor.TYPE_BLUETOOTH);
                mNearbyListener.foundNeighbor(neighbor);
            }
        }

        if (clientThreads.containsKey(device.getAddress()))
            if (clientThreads.get(device.getAddress()).isAlive())
                return false; //we have a running thread here people!

        log("Found device: " + device.getName() + ":" + device.getAddress());

        ClientThread clientThread = new ClientThread(device, mHandler, mPairedDevicesOnly);
        clientThread.start();

        clientThreads.put(device.getAddress(), clientThread);

    }

    return resultIsNew;
}
 
Example 15
Project: AndroidMuseumBleManager   File: BluetoothClassResolver.java   Source Code and License 5 votes vote down vote up
public static String resolveMajorDeviceClass(final int majorBtClass) {
    switch (majorBtClass) {
        case BluetoothClass.Device.Major.AUDIO_VIDEO:
            return "Audio/ Video";
        case BluetoothClass.Device.Major.COMPUTER:
            return "Computer";
        case BluetoothClass.Device.Major.HEALTH:
            return "Health";
        case BluetoothClass.Device.Major.IMAGING:
            return "Imaging";
        case BluetoothClass.Device.Major.MISC:
            return "Misc";
        case BluetoothClass.Device.Major.NETWORKING:
            return "Networking";
        case BluetoothClass.Device.Major.PERIPHERAL:
            return "Peripheral";
        case BluetoothClass.Device.Major.PHONE:
            return "Phone";
        case BluetoothClass.Device.Major.TOY:
            return "Toy";
        case BluetoothClass.Device.Major.UNCATEGORIZED:
            return "Uncategorized";
        case BluetoothClass.Device.Major.WEARABLE:
            return "Wearable";
        default:
            return "Unknown (" +majorBtClass+ ")";
    }
}
 
Example 16
Project: Cable-Android   File: BluetoothStateManager.java   Source Code and License 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
  if (intent == null) return;
  Log.w(TAG, "onReceive");

  synchronized (LOCK) {
    if (getScoChangeIntent().equals(intent.getAction())) {
      int status = intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE, AudioManager.SCO_AUDIO_STATE_ERROR);

      if (status == AudioManager.SCO_AUDIO_STATE_CONNECTED) {
        if (Build.VERSION.SDK_INT >= 11 && bluetoothHeadset != null) {
          List<BluetoothDevice> devices = bluetoothHeadset.getConnectedDevices();

          for (BluetoothDevice device : devices) {
            if (bluetoothHeadset.isAudioConnected(device)) {
              int deviceClass = device.getBluetoothClass().getDeviceClass();

              if (deviceClass == BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE ||
                  deviceClass == BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO ||
                  deviceClass == BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET)
              {
                scoConnection = ScoConnection.CONNECTED;

                if (wantsConnection) {
                  AudioManager audioManager = ServiceUtil.getAudioManager(context);
                  audioManager.setBluetoothScoOn(true);
                }
              }
            }
          }

        }
      }
    }
  }

  handleBluetoothStateChange();
}
 
Example 17
Project: android-xmpp-iot-demo   File: XiotBluetoothLeManager.java   Source Code and License 5 votes vote down vote up
@Override
public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord) {
	String name = device.getName();
	BluetoothClass bluetoothClass = device.getBluetoothClass();
	String address = device.getAddress();
	int type = device.getType();
	ParcelUuid[] uuids = device.getUuids();

	StringBuilder deviceInfo = new StringBuilder();
	deviceInfo.append(name + " - " + bluetoothClass + " (" + address + ',' + type + ") [");
	if (uuids != null) {
		for (ParcelUuid uuid : uuids) {
			deviceInfo.append(uuid).append(", ");
		}
	}
	deviceInfo.append(']');

	LOGGER.info("Found Bluetooth device '" + deviceInfo + "' with rssi " + rssi);

	if (name == null || !name.startsWith("Polar H7")) return;

	MainActivity.withMainActivity((ma) -> {
		Toast.makeText(ma, "Found Polar H7 device, trying to discover services", Toast.LENGTH_SHORT).show();
	});
	stopBleDeviceDiscovery();

	device.connectGatt(mContext, true, mBluetoothGattCallback);
}
 
Example 18
Project: BLE   File: BluetoothClassResolver.java   Source Code and License 5 votes vote down vote up
public static String resolveMajorDeviceClass(final int majorBtClass) {
    switch (majorBtClass) {
        case BluetoothClass.Device.Major.AUDIO_VIDEO:
            return "Audio/ Video";
        case BluetoothClass.Device.Major.COMPUTER:
            return "Computer";
        case BluetoothClass.Device.Major.HEALTH:
            return "Health";
        case BluetoothClass.Device.Major.IMAGING:
            return "Imaging";
        case BluetoothClass.Device.Major.MISC:
            return "Misc";
        case BluetoothClass.Device.Major.NETWORKING:
            return "Networking";
        case BluetoothClass.Device.Major.PERIPHERAL:
            return "Peripheral";
        case BluetoothClass.Device.Major.PHONE:
            return "Phone";
        case BluetoothClass.Device.Major.TOY:
            return "Toy";
        case BluetoothClass.Device.Major.UNCATEGORIZED:
            return "Uncategorized";
        case BluetoothClass.Device.Major.WEARABLE:
            return "Wearable";
        default:
            return "Unknown (" + majorBtClass + ")";
    }
}
 
Example 19
Project: libcommon   File: BluetoothDeviceInfo.java   Source Code and License 5 votes vote down vote up
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();
}
 
Example 20
Project: gobbed   File: GobbedBluetooth.java   Source Code and License 5 votes vote down vote up
@JavascriptInterface
public String getDevices() {
    boolean added = populatePairedDevices();
    JSONArray devices = new JSONArray();
    for (GobbedDevice gdev: mDeviceList.values()) {
        JSONObject j = new JSONObject();
        try {
            String s = gdev.btDev.getName();
            if (s != null) j.put("name", s);
            s = gdev.btDev.getAddress();
            if (s != null) j.put("address", s);
            j.put("paired", gdev.isPaired);
            if (gdev.isPaired) {
                j.put("connected", gdev.isConnected);
                j.put("connecting", gdev.isConnecting);
                j.put("connectable", gdev.isConnectable);
            }
            BluetoothClass devclass = gdev.btDev.getBluetoothClass();
            if (devclass != null) j.put("deviceClass", devclass.getDeviceClass());
            JSONArray uuids = new JSONArray();
            // If you have never attempted to pair or connect with dev before, getUuids() will
            // return null (no uuids in cache).
            if (Build.VERSION.SDK_INT >= 15 && gdev.btDev.getUuids() != null) { // API 15: Icecream MR1
                for (ParcelUuid uuid : gdev.btDev.getUuids()) {
                    uuids.put(uuid.toString());
                }
            }
            j.put("uuids", uuids);
        } catch (JSONException e) {
            // Must never happen. put(String, bool) may only throw if:
            // 1. key is null - the above code will never have a null key.
            // 2. testValidity() throws for a String.
            throw new RuntimeException("JSONException for put(non-null String, String)", e);
        }
        devices.put(j);
    }
    return devices.toString();
}
 
Example 21
Project: truth-android   File: BluetoothClassSubject.java   Source Code and License 5 votes vote down vote up
public static String majorDeviceClassToString(int majorDeviceClass) {
  return buildNamedValueString(majorDeviceClass)
      .value(BluetoothClass.Device.Major.AUDIO_VIDEO, "audio_video")
      .value(BluetoothClass.Device.Major.COMPUTER, "computer")
      .value(BluetoothClass.Device.Major.HEALTH, "health")
      .value(BluetoothClass.Device.Major.IMAGING, "imaging")
      .value(BluetoothClass.Device.Major.MISC, "misc")
      .value(BluetoothClass.Device.Major.NETWORKING, "networking")
      .value(BluetoothClass.Device.Major.PERIPHERAL, "peripheral")
      .value(BluetoothClass.Device.Major.PHONE, "phone")
      .value(BluetoothClass.Device.Major.TOY, "toy")
      .value(BluetoothClass.Device.Major.UNCATEGORIZED, "uncategorized")
      .value(BluetoothClass.Device.Major.WEARABLE, "wearable")
      .get();
}
 
Example 22
Project: truth-android   File: BluetoothClassSubject.java   Source Code and License 5 votes vote down vote up
public static String serviceToString(int service) {
  return buildNamedValueString(service)
      .value(BluetoothClass.Service.AUDIO, "audio")
      .value(BluetoothClass.Service.CAPTURE, "capture")
      .value(BluetoothClass.Service.INFORMATION, "information")
      .value(BluetoothClass.Service.LIMITED_DISCOVERABILITY, "limited_discoverability")
      .value(BluetoothClass.Service.NETWORKING, "networking")
      .value(BluetoothClass.Service.OBJECT_TRANSFER, "object_transfer")
      .value(BluetoothClass.Service.POSITIONING, "positioning")
      .value(BluetoothClass.Service.RENDER, "render")
      .value(BluetoothClass.Service.TELEPHONY, "telephony")
      .get();
}
 
Example 23
Project: AndroidBleManager   File: BluetoothClassResolver.java   Source Code and License 5 votes vote down vote up
public static String resolveMajorDeviceClass(final int majorBtClass) {
    switch (majorBtClass) {
        case BluetoothClass.Device.Major.AUDIO_VIDEO:
            return "Audio/ Video";
        case BluetoothClass.Device.Major.COMPUTER:
            return "Computer";
        case BluetoothClass.Device.Major.HEALTH:
            return "Health";
        case BluetoothClass.Device.Major.IMAGING:
            return "Imaging";
        case BluetoothClass.Device.Major.MISC:
            return "Misc";
        case BluetoothClass.Device.Major.NETWORKING:
            return "Networking";
        case BluetoothClass.Device.Major.PERIPHERAL:
            return "Peripheral";
        case BluetoothClass.Device.Major.PHONE:
            return "Phone";
        case BluetoothClass.Device.Major.TOY:
            return "Toy";
        case BluetoothClass.Device.Major.UNCATEGORIZED:
            return "Uncategorized";
        case BluetoothClass.Device.Major.WEARABLE:
            return "Wearable";
        default:
            return "Unknown (" +majorBtClass+ ")";
    }
}
 
Example 24
Project: fdroid   File: BluetoothFinder.java   Source Code and License 5 votes vote down vote up
private void onDeviceFound(BluetoothDevice device) {
    if (device != null && device.getName() != null &&
            (device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.COMPUTER_HANDHELD_PC_PDA ||
            device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.COMPUTER_PALM_SIZE_PC_PDA ||
            device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.PHONE_SMART)) {
        subscriber.onNext(new BluetoothPeer(device));
    }
}
 
Example 25
Project: AppHub   File: BluetoothFinder.java   Source Code and License 5 votes vote down vote up
private void onDeviceFound(BluetoothDevice device) {

        if (device != null && device.getName() != null &&
                (device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.COMPUTER_HANDHELD_PC_PDA ||
                device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.COMPUTER_PALM_SIZE_PC_PDA ||
                device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.PHONE_SMART)) {
            foundPeer(new BluetoothPeer(device));
        }
    }
 
Example 26
Project: miniPrinter   File: BTService4Printer.java   Source Code and License 5 votes vote down vote up
private boolean checkPrinter(BluetoothDevice device)
{
	if(device==null)
		return false;
	BluetoothClass btcls = device.getBluetoothClass();

	if(btcls==null)
		return false;
	
	return PrinterConst.BTPrinterClasses.equals(btcls.toString());
}
 
Example 27
Project: ring-client-android   File: BluetoothWrapper.java   Source Code and License 5 votes vote down vote up
public boolean canBluetooth() {
    // Detect if any bluetooth a device is available for call
    if (bluetoothAdapter == null) {
        // Device does not support Bluetooth
        return false;
    }
    boolean hasConnectedDevice = false;
    //If bluetooth is on
    if (bluetoothAdapter.isEnabled()) {

        //We get all bounded bluetooth devices
        // bounded is not enough, should search for connected devices....
        Set<BluetoothDevice> pairedDevices = bluetoothAdapter.getBondedDevices();
        for (BluetoothDevice device : pairedDevices) {
            BluetoothClass bluetoothClass = device.getBluetoothClass();
            if (bluetoothClass != null) {
                int deviceClass = bluetoothClass.getDeviceClass();
                if (bluetoothClass.hasService(BluetoothClass.Service.RENDER) ||
                        deviceClass == BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET ||
                        deviceClass == BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO ||
                        deviceClass == BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE) {
                    //And if any can be used as a audio handset
                    hasConnectedDevice = true;
                    break;
                }
            }
        }
    }
    boolean retVal = hasConnectedDevice && audioManager.isBluetoothScoAvailableOffCall();
    Log.d(TAG, "Can I do BT ? " + retVal);
    return retVal;
}
 
Example 28
Project: android-tv-launcher   File: MyBluetoothAdapter.java   Source Code and License 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    if (convertView == null) {
        holder = new Holder();
        convertView = LayoutInflater.from(context).inflate(
                R.layout.item_bluetooth, null);
        holder.name = (TextView) convertView
                .findViewById(R.id.item_bluetooth_name);
        holder.icon = (ImageView) convertView
                .findViewById(R.id.item_bluetooth_iv);
        convertView.setTag(holder);
    } else {
        holder = (Holder) convertView.getTag();
    }
    Map<String,Object> map = list.get(position);
    String name = (String) map.get("name");
    if(name != null){
        holder.name.setText((String) map.get("name"));
    }
    int type = (Integer)map.get("type");
    //根据设备类型 设置相应图片
    if(type> BluetoothClass.Device.PHONE_UNCATEGORIZED&&type<BluetoothClass.Device.PHONE_ISDN){
        holder.icon.setBackgroundResource(R.drawable.phone);
    }else if(type> BluetoothClass.Device.COMPUTER_UNCATEGORIZED&&type<BluetoothClass.Device.COMPUTER_WEARABLE){
        holder.icon.setBackgroundResource(R.drawable.pc);
    }else if(type> BluetoothClass.Device.TOY_UNCATEGORIZED&&type<BluetoothClass.Device.TOY_GAME){
        holder.icon.setBackgroundResource(R.drawable.handle);
    }
    return convertView;
}
 
Example 29
Project: cInterphone   File: Bluetooth.java   Source Code and License 5 votes vote down vote up
public static boolean isAvailable() {
	if (!ba.isEnabled())
		return false;
	Set<BluetoothDevice> devs = ba.getBondedDevices();
	for (final BluetoothDevice dev : devs) {
		BluetoothClass cl = dev.getBluetoothClass();
		if (cl != null && (cl.hasService(Service.RENDER) ||
				cl.getDeviceClass() == Device.AUDIO_VIDEO_HANDSFREE ||
				cl.getDeviceClass() == Device.AUDIO_VIDEO_CAR_AUDIO ||
				cl.getDeviceClass() == Device.AUDIO_VIDEO_WEARABLE_HEADSET))
			return true;
	}
	return false;
}
 
Example 30
Project: Bluetooth-LE-Library---Android   File: BluetoothClassResolver.java   Source Code and License 5 votes vote down vote up
public static String resolveMajorDeviceClass(final int majorBtClass) {
    switch (majorBtClass) {
        case BluetoothClass.Device.Major.AUDIO_VIDEO:
            return "Audio/ Video";
        case BluetoothClass.Device.Major.COMPUTER:
            return "Computer";
        case BluetoothClass.Device.Major.HEALTH:
            return "Health";
        case BluetoothClass.Device.Major.IMAGING:
            return "Imaging";
        case BluetoothClass.Device.Major.MISC:
            return "Misc";
        case BluetoothClass.Device.Major.NETWORKING:
            return "Networking";
        case BluetoothClass.Device.Major.PERIPHERAL:
            return "Peripheral";
        case BluetoothClass.Device.Major.PHONE:
            return "Phone";
        case BluetoothClass.Device.Major.TOY:
            return "Toy";
        case BluetoothClass.Device.Major.UNCATEGORIZED:
            return "Uncategorized";
        case BluetoothClass.Device.Major.WEARABLE:
            return "Wearable";
        default:
            return "Unknown (" +majorBtClass+ ")";
    }
}
 
Example 31
Project: fdroidclient   File: BluetoothFinder.java   Source Code and License 5 votes vote down vote up
private void onDeviceFound(BluetoothDevice device) {
    if (device != null && device.getName() != null &&
            (device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.COMPUTER_HANDHELD_PC_PDA ||
            device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.COMPUTER_PALM_SIZE_PC_PDA ||
            device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.PHONE_SMART)) {
        subscriber.onNext(new BluetoothPeer(device));
    }
}
 
Example 32
Project: TryAndroid   File: CardItem.java   Source Code and License 5 votes vote down vote up
public CharSequence getMsg() {
    StringBuilder sb = new StringBuilder();

    // MACアドレス
    sb.append("address: " + mBluetoothDevice.getAddress() + "\n");

    // デバイスクラス
    // 電波強度が分かるらしい。
    // http://ja.wikipedia.org/wiki/Bluetooth#.E3.82.AF.E3.83.A9.E3.82.B9
    BluetoothClass bluetoothClass = mBluetoothDevice.getBluetoothClass();
    int majoreClass = mBluetoothDevice.getBluetoothClass().getMajorDeviceClass() >> 8;
    int minorClass = mBluetoothDevice.getBluetoothClass().getDeviceClass() & 0xFF;
    sb.append("majore class: " + majoreClass + "\n");
    sb.append("minor class: " + minorClass + "\n");

    // 接続状態
    CharSequence bondStateStr;
    switch (mBluetoothDevice.getBondState()) {
        case BluetoothDevice.BOND_BONDING:
            bondStateStr = "接続中";
            break;
        case BluetoothDevice.BOND_BONDED:
            bondStateStr = "接続履歴あり";
            break;
        case BluetoothDevice.BOND_NONE:
            bondStateStr = "新規デバイス";
            break;
        default:
            bondStateStr = "接続状態不明";
            break;
    }
    sb.append("bond state: " + bondStateStr + "\n");

    return sb.toString();
}
 
Example 33
Project: ok-oh   File: MainActivity.java   Source Code and License 5 votes vote down vote up
private boolean existBluetoothHeadset() {
	for (BluetoothDevice dispositivo: bluetoothAdapter.getBondedDevices()) {
		BluetoothClass clase= dispositivo.getBluetoothClass();
		switch (clase.getDeviceClass()) {
		case BluetoothClass.Device.AUDIO_VIDEO_HEADPHONES:
			return true;
		case BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET:
			return true;
		case BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE:
			return true;
		}
	}
	return false;
}
 
Example 34
Project: NovarumBluetooth   File: NovarumbluetoothModule.java   Source Code and License 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) 
{
    Message msg = Message.obtain();
    String action = intent.getAction();
    
    if(BluetoothDevice.ACTION_FOUND.equals(action))
    {

    	bluetoothDevice        = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
    	BluetoothClass blclass = intent.getParcelableExtra(BluetoothDevice.EXTRA_CLASS);
    	
    	int Majorclass = blclass.getMajorDeviceClass();
    	int minorclass = blclass.getDeviceClass();
    	
    	
        devicelist = new KrollDict();
        
        try
        {
        	devicelist.put("name",bluetoothDevice.getName());
        	devicelist.put("macaddress",bluetoothDevice.getAddress());
        	devicelist.put("pairedstatus",bluetoothDevice.getBondState());
        }
        catch (Exception e) 
        {
            Log.w(TAG, "devicesFound exception: "+e.getMessage());
            postError(e.getMessage());
        }

        devicesFound();
        
    }           
}
 
Example 35
Project: phonty   File: Bluetooth.java   Source Code and License 5 votes vote down vote up
public static boolean isAvailable() {
	if (!ba.isEnabled())
		return false;
	Set<BluetoothDevice> devs = ba.getBondedDevices();
	for (final BluetoothDevice dev : devs) {
		BluetoothClass cl = dev.getBluetoothClass();
		if (cl != null && (cl.hasService(Service.RENDER) ||
				cl.getDeviceClass() == Device.AUDIO_VIDEO_HANDSFREE ||
				cl.getDeviceClass() == Device.AUDIO_VIDEO_CAR_AUDIO ||
				cl.getDeviceClass() == Device.AUDIO_VIDEO_WEARABLE_HEADSET))
			return true;
	}
	return false;
}
 
Example 36
Project: assertj-android   File: BluetoothClassAssert.java   Source Code and License 5 votes vote down vote up
public static String majorDeviceClassToString(int majorDeviceClass) {
  return buildNamedValueString(majorDeviceClass) //
      .value(BluetoothClass.Device.Major.AUDIO_VIDEO, "audio_video")
      .value(BluetoothClass.Device.Major.COMPUTER, "computer")
      .value(BluetoothClass.Device.Major.HEALTH, "health")
      .value(BluetoothClass.Device.Major.IMAGING, "imaging")
      .value(BluetoothClass.Device.Major.MISC, "misc")
      .value(BluetoothClass.Device.Major.NETWORKING, "networking")
      .value(BluetoothClass.Device.Major.PERIPHERAL, "peripheral")
      .value(BluetoothClass.Device.Major.PHONE, "phone")
      .value(BluetoothClass.Device.Major.TOY, "toy")
      .value(BluetoothClass.Device.Major.UNCATEGORIZED, "uncategorized")
      .value(BluetoothClass.Device.Major.WEARABLE, "wearable")
      .get();
}
 
Example 37
Project: assertj-android   File: BluetoothClassAssert.java   Source Code and License 5 votes vote down vote up
public static String serviceToString(int service) {
  return buildNamedValueString(service) //
      .value(BluetoothClass.Service.AUDIO, "audio")
      .value(BluetoothClass.Service.CAPTURE, "capture")
      .value(BluetoothClass.Service.INFORMATION, "information")
      .value(BluetoothClass.Service.LIMITED_DISCOVERABILITY, "limited_discoverability")
      .value(BluetoothClass.Service.NETWORKING, "networking")
      .value(BluetoothClass.Service.OBJECT_TRANSFER, "object_transfer")
      .value(BluetoothClass.Service.POSITIONING, "positioning")
      .value(BluetoothClass.Service.RENDER, "render")
      .value(BluetoothClass.Service.TELEPHONY, "telephony")
      .get();
}
 
Example 38
Project: truth-android   File: BluetoothClassSubject.java   Source Code and License 4 votes vote down vote up
protected BluetoothClassSubject(FailureStrategy failureStrategy, BluetoothClass subject) {
  super(failureStrategy, subject);
}
 
Example 39
Project: truth-android   File: BluetoothClassSubject.java   Source Code and License 4 votes vote down vote up
public static String deviceClassToString(int deviceClass) {
  return buildNamedValueString(deviceClass)
      .value(BluetoothClass.Device.AUDIO_VIDEO_CAMCORDER, "AUDIO_VIDEO_CAMCORDER")
      .value(BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO, "AUDIO_VIDEO_CAR_AUDIO")
      .value(BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE, "AUDIO_VIDEO_HANDSFREE")
      .value(BluetoothClass.Device.AUDIO_VIDEO_HEADPHONES, "AUDIO_VIDEO_HEADPHONES")
      .value(BluetoothClass.Device.AUDIO_VIDEO_HIFI_AUDIO, "AUDIO_VIDEO_HIFI_AUDIO")
      .value(BluetoothClass.Device.AUDIO_VIDEO_LOUDSPEAKER, "AUDIO_VIDEO_LOUDSPEAKER")
      .value(BluetoothClass.Device.AUDIO_VIDEO_MICROPHONE, "AUDIO_VIDEO_MICROPHONE")
      .value(BluetoothClass.Device.AUDIO_VIDEO_PORTABLE_AUDIO, "AUDIO_VIDEO_PORTABLE_AUDIO")
      .value(BluetoothClass.Device.AUDIO_VIDEO_SET_TOP_BOX, "AUDIO_VIDEO_SET_TOP_BOX")
      .value(BluetoothClass.Device.AUDIO_VIDEO_UNCATEGORIZED, "AUDIO_VIDEO_UNCATEGORIZED")
      .value(BluetoothClass.Device.AUDIO_VIDEO_VCR, "AUDIO_VIDEO_VCR")
      .value(BluetoothClass.Device.AUDIO_VIDEO_VIDEO_CAMERA, "AUDIO_VIDEO_VIDEO_CAMERA")
      .value(BluetoothClass.Device.AUDIO_VIDEO_VIDEO_CONFERENCING,
          "AUDIO_VIDEO_VIDEO_CONFERENCING")
      .value(BluetoothClass.Device.AUDIO_VIDEO_VIDEO_DISPLAY_AND_LOUDSPEAKER,
          "AUDIO_VIDEO_VIDEO_DISPLAY_AND_LOUDSPEAKER")
      .value(BluetoothClass.Device.AUDIO_VIDEO_VIDEO_GAMING_TOY, "AUDIO_VIDEO_VIDEO_GAMING_TOY")
      .value(BluetoothClass.Device.AUDIO_VIDEO_VIDEO_MONITOR, "AUDIO_VIDEO_VIDEO_MONITOR")
      .value(BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET, "AUDIO_VIDEO_WEARABLE_HEADSET")
      .value(BluetoothClass.Device.COMPUTER_DESKTOP, "COMPUTER_DESKTOP")
      .value(BluetoothClass.Device.COMPUTER_HANDHELD_PC_PDA, "COMPUTER_HANDHELD_PC_PDA")
      .value(BluetoothClass.Device.COMPUTER_LAPTOP, "COMPUTER_LAPTOP")
      .value(BluetoothClass.Device.COMPUTER_PALM_SIZE_PC_PDA, "COMPUTER_PALM_SIZE_PC_PDA")
      .value(BluetoothClass.Device.COMPUTER_SERVER, "COMPUTER_SERVER")
      .value(BluetoothClass.Device.COMPUTER_UNCATEGORIZED, "COMPUTER_UNCATEGORIZED")
      .value(BluetoothClass.Device.COMPUTER_WEARABLE, "COMPUTER_WEARABLE")
      .value(BluetoothClass.Device.HEALTH_BLOOD_PRESSURE, "HEALTH_BLOOD_PRESSURE")
      .value(BluetoothClass.Device.HEALTH_DATA_DISPLAY, "HEALTH_DATA_DISPLAY")
      .value(BluetoothClass.Device.HEALTH_GLUCOSE, "HEALTH_GLUCOSE")
      .value(BluetoothClass.Device.HEALTH_PULSE_OXIMETER, "HEALTH_PULSE_OXIMETER")
      .value(BluetoothClass.Device.HEALTH_PULSE_RATE, "HEALTH_PULSE_RATE")
      .value(BluetoothClass.Device.HEALTH_THERMOMETER, "HEALTH_THERMOMETER")
      .value(BluetoothClass.Device.HEALTH_UNCATEGORIZED, "HEALTH_UNCATEGORIZED")
      .value(BluetoothClass.Device.HEALTH_WEIGHING, "HEALTH_WEIGHING")
      .value(BluetoothClass.Device.PHONE_CELLULAR, "PHONE_CELLULAR")
      .value(BluetoothClass.Device.PHONE_CORDLESS, "PHONE_CORDLESS")
      .value(BluetoothClass.Device.PHONE_ISDN, "PHONE_ISDN")
      .value(BluetoothClass.Device.PHONE_MODEM_OR_GATEWAY, "PHONE_MODEM_OR_GATEWAY")
      .value(BluetoothClass.Device.PHONE_SMART, "PHONE_SMART")
      .value(BluetoothClass.Device.PHONE_UNCATEGORIZED, "PHONE_UNCATEGORIZED")
      .value(BluetoothClass.Device.TOY_CONTROLLER, "TOY_CONTROLLER")
      .value(BluetoothClass.Device.TOY_DOLL_ACTION_FIGURE, "TOY_DOLL_ACTION_FIGURE")
      .value(BluetoothClass.Device.TOY_GAME, "TOY_GAME")
      .value(BluetoothClass.Device.TOY_ROBOT, "TOY_ROBOT")
      .value(BluetoothClass.Device.TOY_UNCATEGORIZED, "TOY_UNCATEGORIZED")
      .value(BluetoothClass.Device.TOY_VEHICLE, "TOY_VEHICLE")
      .value(BluetoothClass.Device.WEARABLE_GLASSES, "WEARABLE_GLASSES")
      .value(BluetoothClass.Device.WEARABLE_HELMET, "WEARABLE_HELMET")
      .value(BluetoothClass.Device.WEARABLE_JACKET, "WEARABLE_JACKET")
      .value(BluetoothClass.Device.WEARABLE_PAGER, "WEARABLE_PAGER")
      .value(BluetoothClass.Device.WEARABLE_UNCATEGORIZED, "WEARABLE_UNCATEGORIZED")
      .value(BluetoothClass.Device.WEARABLE_WRIST_WATCH, "WEARABLE_WRIST_WATCH")
      .get();
}
 
Example 40
Project: Bletia   File: BluetoothDeviceWrapper.java   Source Code and License 4 votes vote down vote up
public BluetoothClass getBluetoothClass() {
    return mDevice.getBluetoothClass();
}
 
Example 41
Project: nxt-remote-control   File: ChooseDeviceActivity.java   Source Code and License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.device_list);
    setResult(Activity.RESULT_CANCELED);
    Button scanButton = (Button) findViewById(R.id.button_scan);
    scanButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            doDiscovery();
            v.setVisibility(View.GONE);
        }
    });
    
    mPairedDevicesArrayAdapter = new ArrayAdapter<String>(this, R.layout.device_name);
    mNewDevicesArrayAdapter = new ArrayAdapter<String>(this, R.layout.device_name);
    
    ListView pairedListView = (ListView) findViewById(R.id.paired_devices);
    pairedListView.setAdapter(mPairedDevicesArrayAdapter);
    pairedListView.setOnItemClickListener(mDeviceClickListener);
    
    ListView newDevicesListView = (ListView) findViewById(R.id.new_devices);
    newDevicesListView.setAdapter(mNewDevicesArrayAdapter);
    newDevicesListView.setOnItemClickListener(mDeviceClickListener);
    
    IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
    this.registerReceiver(mReceiver, filter);
    
    filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
    this.registerReceiver(mReceiver, filter);
    
    mBtAdapter = BluetoothAdapter.getDefaultAdapter();
    
    Set<BluetoothDevice> pairedDevices = mBtAdapter.getBondedDevices();
    
    boolean empty = true;
    
    if (pairedDevices.size() > 0) {
        for (BluetoothDevice device : pairedDevices) {
            if ((device.getBluetoothClass() != null) && (device.getBluetoothClass().getDeviceClass() == BluetoothClass.Device.TOY_ROBOT)) {
                mPairedDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
                empty = false;
            }
        }
    }
    if (!empty) {
        findViewById(R.id.title_paired_devices).setVisibility(View.VISIBLE);
        findViewById(R.id.no_devices).setVisibility(View.GONE);
    }
}
 
Example 42
Project: Blaubot   File: BlaubotBluetoothDevice.java   Source Code and License 4 votes vote down vote up
public BluetoothClass getBluetoothClass() {
	return device.getBluetoothClass();
}
 
Example 43
Project: dialogflow-android-client   File: BluetoothController.java   Source Code and License 4 votes vote down vote up
@SuppressWarnings({"deprecation", "synthetic-access"})
@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();

    if (action.equals(BluetoothDevice.ACTION_ACL_CONNECTED)) {
        BluetoothDevice mConnectedHeadset = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
        BluetoothClass bluetoothClass = mConnectedHeadset.getBluetoothClass();
        if (bluetoothClass != null) {
            // Check if device is a headset. Besides the 2 below, are there other
            // device classes also qualified as headset?
            int deviceClass = bluetoothClass.getDeviceClass();
            if (deviceClass == BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE
                    || deviceClass == BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET) {
                // start bluetooth Sco audio connection.
                // Calling startBluetoothSco() always returns faIL here,
                // that why a count down timer is implemented to call
                // startBluetoothSco() in the onTick.
                mAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
                mIsCountDownOn = true;
                mCountDown.start();

                // override this if you want to do other thing when the device is connected.
                onHeadsetConnected();
            }
        }

        Log.d(TAG, mConnectedHeadset.getName() + " connected");
    } else if (action.equals(BluetoothDevice.ACTION_ACL_DISCONNECTED)) {
        Log.d(TAG, "Headset disconnected");

        if (mIsCountDownOn) {
            mIsCountDownOn = false;
            mCountDown.cancel();
        }

        mAudioManager.setMode(AudioManager.MODE_NORMAL);

        // override this if you want to do other thing when the device is disconnected.
        onHeadsetDisconnected();
    } else if (action.equals(AudioManager.ACTION_SCO_AUDIO_STATE_CHANGED)) {
        int state = intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE,
                AudioManager.SCO_AUDIO_STATE_ERROR);

        if (state == AudioManager.SCO_AUDIO_STATE_CONNECTED) {
            mIsOnHeadsetSco = true;

            if (mIsStarting) {
                // When the device is connected before the application starts,
                // ACTION_ACL_CONNECTED will not be received, so call onHeadsetConnected here
                mIsStarting = false;
                onHeadsetConnected();
            }

            if (mIsCountDownOn) {
                mIsCountDownOn = false;
                mCountDown.cancel();
            }

            // override this if you want to do other thing when Sco audio is connected.
            onScoAudioConnected();

            Log.d(TAG, "Sco connected");
        } else if (state == AudioManager.SCO_AUDIO_STATE_DISCONNECTED) {
            Log.d(TAG, "Sco disconnected");

            // Always receive SCO_AUDIO_STATE_DISCONNECTED on call to startBluetooth()
            // which at that stage we do not want to do anything. Thus the if condition.
            if (!mIsStarting) {
                mIsOnHeadsetSco = false;

                // Need to call stopBluetoothSco(), otherwise startBluetoothSco()
                // will not be successful.
                mAudioManager.stopBluetoothSco();

                // override this if you want to do other thing when Sco audio is disconnected.
                onScoAudioDisconnected();
            }
        }
    }
}
 
Example 44
Project: nxt-remote-controller   File: PairedDevice.java   Source Code and License 4 votes vote down vote up
public boolean isToyRobot () {
  return this.getIntDeviceType() == BluetoothClass.Device.TOY_ROBOT;
}
 
Example 45
Project: nxt-remote-controller   File: PairedDevice.java   Source Code and License 4 votes vote down vote up
public boolean isToyGame () {
  return this.getIntDeviceType() == BluetoothClass.Device.TOY_GAME;
}
 
Example 46
Project: nxt-remote-controller   File: PairedDevice.java   Source Code and License 4 votes vote down vote up
public boolean isToyActionFigure () {
  return this.getIntDeviceType() == BluetoothClass.Device.TOY_DOLL_ACTION_FIGURE;
}
 
Example 47
Project: nxt-remote-controller   File: PairedDevice.java   Source Code and License 4 votes vote down vote up
public boolean isToyController () {
  return this.getIntDeviceType() == BluetoothClass.Device.TOY_CONTROLLER;
}
 
Example 48
Project: nxt-remote-controller   File: PairedDevice.java   Source Code and License 4 votes vote down vote up
public boolean isToyVehicle () {
  return this.getIntDeviceType() == BluetoothClass.Device.TOY_VEHICLE;
}
 
Example 49
Project: nxt-remote-controller   File: PairedDevice.java   Source Code and License 4 votes vote down vote up
public boolean isToyUncategorized () {
  return this.getIntDeviceType() == BluetoothClass.Device.TOY_UNCATEGORIZED;
}
 
Example 50
Project: nxt-remote-controller   File: PairedDevice.java   Source Code and License 4 votes vote down vote up
public boolean isWearableGlasses () {
  return this.getIntDeviceType() == BluetoothClass.Device.WEARABLE_GLASSES;
}
 
Example 51
Project: nxt-remote-controller   File: PairedDevice.java   Source Code and License 4 votes vote down vote up
public boolean isWearableHelmet () {
  return this.getIntDeviceType() == BluetoothClass.Device.WEARABLE_HELMET;
}
 
Example 52
Project: nxt-remote-controller   File: PairedDevice.java   Source Code and License 4 votes vote down vote up
public boolean isWearableJacket () {
  return this.getIntDeviceType() == BluetoothClass.Device.WEARABLE_JACKET;
}
 
Example 53
Project: nxt-remote-controller   File: PairedDevice.java   Source Code and License 4 votes vote down vote up
public boolean isWearablePager () {
  return this.getIntDeviceType() == BluetoothClass.Device.WEARABLE_PAGER;
}
 
Example 54
Project: nxt-remote-controller   File: PairedDevice.java   Source Code and License 4 votes vote down vote up
public boolean isWearableWatch () {
  return this.getIntDeviceType() == BluetoothClass.Device.WEARABLE_WRIST_WATCH;
}
 
Example 55
Project: nxt-remote-controller   File: PairedDevice.java   Source Code and License 4 votes vote down vote up
public boolean isWearableUncategorized () {
  return this.getIntDeviceType() == BluetoothClass.Device.WEARABLE_UNCATEGORIZED;
}
 
Example 56
Project: nxt-remote-controller   File: PairedDevice.java   Source Code and License 4 votes vote down vote up
public boolean isHealthBloodPressureDevice () {
  return this.getIntDeviceType() == BluetoothClass.Device.HEALTH_BLOOD_PRESSURE;
}
 
Example 57
Project: nxt-remote-controller   File: PairedDevice.java   Source Code and License 4 votes vote down vote up
public boolean isHealthDataDisplayDevice () {
  return this.getIntDeviceType() == BluetoothClass.Device.HEALTH_DATA_DISPLAY;
}
 
Example 58
Project: nxt-remote-controller   File: PairedDevice.java   Source Code and License 4 votes vote down vote up
public boolean isHealthGlucoseDevice () {
  return this.getIntDeviceType() == BluetoothClass.Device.HEALTH_GLUCOSE;
}
 
Example 59
Project: nxt-remote-controller   File: PairedDevice.java   Source Code and License 4 votes vote down vote up
public boolean isHealthPulseOximeterDevice () {
  return this.getIntDeviceType() == BluetoothClass.Device.HEALTH_PULSE_OXIMETER;
}
 
Example 60
Project: nxt-remote-controller   File: PairedDevice.java   Source Code and License 4 votes vote down vote up
public boolean isHealthPulseRateDevice () {
  return this.getIntDeviceType() == BluetoothClass.Device.HEALTH_PULSE_RATE;
}