Beispiel #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;
  }
Beispiel #2
0
 protected boolean stop() {
   if (mStateMachine != null) {
     mStateMachine.doQuit();
   }
   if (mAvrcp != null) {
     mAvrcp.doQuit();
   }
   return true;
 }
Beispiel #3
0
 protected boolean cleanup() {
   if (mStateMachine != null) {
     mStateMachine.cleanup();
   }
   if (mAvrcp != null) {
     mAvrcp.cleanup();
     mAvrcp = null;
   }
   clearA2dpService();
   return true;
 }
Beispiel #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;
  }
Beispiel #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;
  }
Beispiel #6
0
 protected boolean start() {
   mAvrcp = Avrcp.make(this);
   mStateMachine = A2dpStateMachine.make(this, this);
   setA2dpService(this);
   return true;
 }
Beispiel #7
0
 synchronized boolean isA2dpPlaying(BluetoothDevice device) {
   enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
   if (DBG) Log.d(TAG, "isA2dpPlaying(" + device + ")");
   return mStateMachine.isPlaying(device);
 }
Beispiel #8
0
 int getConnectionState(BluetoothDevice device) {
   enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
   return mStateMachine.getConnectionState(device);
 }
Beispiel #9
0
 List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
   enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
   return mStateMachine.getDevicesMatchingConnectionStates(states);
 }
Beispiel #10
0
 public List<BluetoothDevice> getConnectedDevices() {
   enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
   return mStateMachine.getConnectedDevices();
 }
 static A2dpStateMachine make(A2dpService svc, Context context) {
   Log.d("A2dpStateMachine", "make");
   A2dpStateMachine a2dpSm = new A2dpStateMachine(svc, context);
   a2dpSm.start();
   return a2dpSm;
 }