java类android.bluetooth.BluetoothClass的实例源码

Device.java 文件源码 项目:BlueDroid 阅读 41 收藏 0 点赞 0 评论 0
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;
    }
}
BluetoothDeviceUtils.java 文件源码 项目:mytracks 阅读 24 收藏 0 点赞 0 评论 0
/**
 * 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());
      }
    }
  }
}
AbstractDeviceCoordinator.java 文件源码 项目:gadgetbridge_artikcloud 阅读 18 收藏 0 点赞 0 评论 0
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;
}
ScanGunKeyEventHelper.java 文件源码 项目:scangon 阅读 21 收藏 0 点赞 0 评论 0
/**
 * 扫描枪是否连接
 * @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;

}
ChooseDeviceActivity.java 文件源码 项目:nxt-remote-control 阅读 20 收藏 0 点赞 0 评论 0
@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);
    }
}
BluetoothDeviceUtils.java 文件源码 项目:moveon 阅读 18 收藏 0 点赞 0 评论 0
/**
 * 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());
            }
        }
    }
}
BTDataPersistence.java 文件源码 项目:EasyBluetooth 阅读 22 收藏 0 点赞 0 评论 0
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);
            }
        }
    }
}
MainActivity.java 文件源码 项目:WearMusicPlayer 阅读 24 收藏 0 点赞 0 评论 0
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;
}
BluetoothPairedListDialog.java 文件源码 项目:an2linuxclient 阅读 20 收藏 0 点赞 0 评论 0
@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;
}
BluetoothFinder.java 文件源码 项目:mobile-store 阅读 20 收藏 0 点赞 0 评论 0
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));
    }
}
BluetoothStateManager.java 文件源码 项目:PeSanKita-android 阅读 21 收藏 0 点赞 0 评论 0
@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();
}
BluetoothUtils8.java 文件源码 项目:CSipSimple 阅读 22 收藏 0 点赞 0 评论 0
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;
}
BluetoothReceiver.java 文件源码 项目:LittleBitLouder 阅读 26 收藏 0 点赞 0 评论 0
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;
}
BluetoothClassResolver.java 文件源码 项目:AndroidMuseumBleManager 阅读 18 收藏 0 点赞 0 评论 0
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+ ")";
    }
}
BluetoothStateManager.java 文件源码 项目:Cable-Android 阅读 24 收藏 0 点赞 0 评论 0
@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();
}
XiotBluetoothLeManager.java 文件源码 项目:android-xmpp-iot-demo 阅读 25 收藏 0 点赞 0 评论 0
@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);
}
BluetoothClassResolver.java 文件源码 项目:BLE 阅读 18 收藏 0 点赞 0 评论 0
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 + ")";
    }
}
BluetoothDeviceInfo.java 文件源码 项目:libcommon 阅读 18 收藏 0 点赞 0 评论 0
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();
}
GobbedBluetooth.java 文件源码 项目:gobbed 阅读 19 收藏 0 点赞 0 评论 0
@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();
}
BluetoothClassSubject.java 文件源码 项目:truth-android 阅读 18 收藏 0 点赞 0 评论 0
public static SubjectFactory<BluetoothClassSubject, BluetoothClass> type() {
  return new SubjectFactory<BluetoothClassSubject, BluetoothClass>() {
    @Override
    public BluetoothClassSubject getSubject(FailureStrategy fs, BluetoothClass that) {
      return new BluetoothClassSubject(fs, that);
    }
  };
}
BluetoothClassSubject.java 文件源码 项目:truth-android 阅读 17 收藏 0 点赞 0 评论 0
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();
}
BluetoothClassSubject.java 文件源码 项目:truth-android 阅读 18 收藏 0 点赞 0 评论 0
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();
}
BluetoothClassResolver.java 文件源码 项目:AndroidBleManager 阅读 20 收藏 0 点赞 0 评论 0
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+ ")";
    }
}
BluetoothFinder.java 文件源码 项目:fdroid 阅读 21 收藏 0 点赞 0 评论 0
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));
    }
}
BluetoothFinder.java 文件源码 项目:AppHub 阅读 23 收藏 0 点赞 0 评论 0
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));
        }
    }
BTService4Printer.java 文件源码 项目:miniPrinter 阅读 23 收藏 0 点赞 0 评论 0
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());
}
BluetoothWrapper.java 文件源码 项目:ring-client-android 阅读 21 收藏 0 点赞 0 评论 0
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;
}
MyBluetoothAdapter.java 文件源码 项目:android-tv-launcher 阅读 21 收藏 0 点赞 0 评论 0
@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;
}
Bluetooth.java 文件源码 项目:cInterphone 阅读 19 收藏 0 点赞 0 评论 0
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;
}
BluetoothClassResolver.java 文件源码 项目:Bluetooth-LE-Library---Android 阅读 19 收藏 0 点赞 0 评论 0
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+ ")";
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号