Exemplo n.º 1
0
  boolean disconnect(BluetoothDevice device) {
    enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH ADMIN permission");
    int connectionState = mStateMachine.getConnectionState(device);
    if (connectionState != BluetoothProfile.STATE_CONNECTED
        && connectionState != BluetoothProfile.STATE_CONNECTING) {
      return false;
    }

    mStateMachine.sendMessage(A2dpStateMachine.DISCONNECT, device);
    return true;
  }
Exemplo n.º 2
0
 protected boolean stop() {
   if (mStateMachine != null) {
     mStateMachine.doQuit();
   }
   if (mAvrcp != null) {
     mAvrcp.doQuit();
   }
   return true;
 }
Exemplo n.º 3
0
 protected boolean cleanup() {
   if (mStateMachine != null) {
     mStateMachine.cleanup();
   }
   if (mAvrcp != null) {
     mAvrcp.cleanup();
     mAvrcp = null;
   }
   clearA2dpService();
   return true;
 }
Exemplo n.º 4
0
  public boolean connect(BluetoothDevice device) {
    enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH ADMIN permission");

    if (getPriority(device) == BluetoothProfile.PRIORITY_OFF) {
      return false;
    }
    ParcelUuid[] featureUuids = device.getUuids();
    if ((BluetoothUuid.containsAnyUuid(featureUuids, A2DP_SOURCE_UUID))
        && !(BluetoothUuid.containsAllUuids(featureUuids, A2DP_SOURCE_SINK_UUIDS))) {
      Log.e(TAG, "Remote does not have A2dp Sink UUID");
      return false;
    }

    int connectionState = mStateMachine.getConnectionState(device);
    if (connectionState == BluetoothProfile.STATE_CONNECTED
        || connectionState == BluetoothProfile.STATE_CONNECTING) {
      return false;
    }

    mStateMachine.sendMessage(A2dpStateMachine.CONNECT, device);
    return true;
  }
Exemplo n.º 5
0
  public boolean setPriority(BluetoothDevice device, int priority) {
    enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission");

    if ((mStateMachine.isConnectedSrc(device))
        && (priority == BluetoothProfile.PRIORITY_AUTO_CONNECT)) {
      if (DBG) Log.d(TAG, "Peer Device is SRC Ignore AutoConnect");
      return false;
    }
    Settings.Global.putInt(
        getContentResolver(),
        Settings.Global.getBluetoothA2dpSinkPriorityKey(device.getAddress()),
        priority);
    if (DBG) Log.d(TAG, "Saved priority " + device + " = " + priority);
    return true;
  }
Exemplo n.º 6
0
 protected boolean start() {
   mAvrcp = Avrcp.make(this);
   mStateMachine = A2dpStateMachine.make(this, this);
   setA2dpService(this);
   return true;
 }
Exemplo n.º 7
0
 synchronized boolean isA2dpPlaying(BluetoothDevice device) {
   enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
   if (DBG) Log.d(TAG, "isA2dpPlaying(" + device + ")");
   return mStateMachine.isPlaying(device);
 }
Exemplo n.º 8
0
 int getConnectionState(BluetoothDevice device) {
   enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
   return mStateMachine.getConnectionState(device);
 }
Exemplo n.º 9
0
 List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
   enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
   return mStateMachine.getDevicesMatchingConnectionStates(states);
 }
Exemplo n.º 10
0
 public List<BluetoothDevice> getConnectedDevices() {
   enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
   return mStateMachine.getConnectedDevices();
 }
Exemplo n.º 11
0
 static A2dpStateMachine make(A2dpService svc, Context context) {
   Log.d("A2dpStateMachine", "make");
   A2dpStateMachine a2dpSm = new A2dpStateMachine(svc, context);
   a2dpSm.start();
   return a2dpSm;
 }