Example #1
0
 /**
  * Initiate resume from an suspended A2DP sink. Listen for SINK_STATE_CHANGED_ACTION to find out
  * when resume is completed.
  *
  * @param device Remote BT device.
  * @return false on immediate error, true otherwise
  * @hide
  */
 public boolean resumeSink(BluetoothDevice device) {
   try {
     return mService.resumeSink(device);
   } catch (RemoteException e) {
     Log.e(TAG, "", e);
     return false;
   }
 }
Example #2
0
 /**
  * Allow or disallow incoming connection
  *
  * @param device Sink
  * @param value True / False
  * @return Success or Failure of the binder call.
  */
 public boolean allowIncomingConnect(BluetoothDevice device, boolean value) {
   if (DBG) log("allowIncomingConnect(" + device + ":" + value + ")");
   try {
     return mService.allowIncomingConnect(device, value);
   } catch (RemoteException e) {
     Log.e(TAG, "", e);
     return false;
   }
 }
Example #3
0
 /**
  * Get priority of a2dp sink.
  *
  * @param device Sink
  * @return non-negative priority, or negative error code on error.
  */
 public int getSinkPriority(BluetoothDevice device) {
   if (DBG) log("getSinkPriority(" + device + ")");
   try {
     return mService.getSinkPriority(device);
   } catch (RemoteException e) {
     Log.e(TAG, "", e);
     return PRIORITY_OFF;
   }
 }
Example #4
0
 /**
  * Set priority of a2dp sink. Priority is a non-negative integer. By default paired sinks will
  * have a priority of PRIORITY_AUTO, and unpaired headset PRIORITY_NONE (0). Sinks with priority
  * greater than zero will accept incoming connections (if no sink is currently connected).
  * Priority for unpaired sink must be PRIORITY_NONE.
  *
  * @param device Paired sink
  * @param priority Integer priority, for example PRIORITY_AUTO or PRIORITY_NONE
  * @return true if priority is set, false on error
  */
 public boolean setSinkPriority(BluetoothDevice device, int priority) {
   if (DBG) log("setSinkPriority(" + device + ", " + priority + ")");
   try {
     return mService.setSinkPriority(device, priority);
   } catch (RemoteException e) {
     Log.e(TAG, "", e);
     return false;
   }
 }
Example #5
0
 /**
  * Get the state of an A2DP sink
  *
  * @param device Remote BT device.
  * @return State code, one of STATE_
  * @hide
  */
 public int getSinkState(BluetoothDevice device) {
   if (DBG) log("getSinkState(" + device + ")");
   try {
     return mService.getSinkState(device);
   } catch (RemoteException e) {
     Log.e(TAG, "", e);
     return BluetoothA2dp.STATE_DISCONNECTED;
   }
 }
Example #6
0
 /**
  * Initiate disconnect from an A2DP sink. Listen for SINK_STATE_CHANGED_ACTION to find out when
  * disconnect is completed.
  *
  * @param device Remote BT device.
  * @return false on immediate error, true otherwise
  * @hide
  */
 public boolean disconnectSink(BluetoothDevice device) {
   if (DBG) log("disconnectSink(" + device + ")");
   try {
     return mService.disconnectSink(device);
   } catch (RemoteException e) {
     Log.e(TAG, "", e);
     return false;
   }
 }
Example #7
0
 /**
  * Check if any A2DP sink is in Non Disconnected state i.e playing, connected, connecting,
  * disconnecting.
  *
  * @return a unmodifiable set of connected A2DP sinks, or null on error.
  * @hide
  */
 public Set<BluetoothDevice> getNonDisconnectedSinks() {
   if (DBG) log("getNonDisconnectedSinks()");
   try {
     return Collections.unmodifiableSet(
         new HashSet<BluetoothDevice>(Arrays.asList(mService.getNonDisconnectedSinks())));
   } catch (RemoteException e) {
     Log.e(TAG, "", e);
     return null;
   }
 }
Example #8
0
 /**
  * Initiate resume from a suspended A2DP sink.
  *
  * <p>This API will return false in scenarios like the A2DP device is not in suspended state etc.
  * When this API returns, true, it is guaranteed that {@link #ACTION_SINK_STATE_CHANGED} intent
  * will be broadcasted with the state. Users can get the state of the A2DP device from this
  * intent.
  *
  * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}
  *
  * @param device Remote A2DP sink
  * @return false on immediate error, true otherwise
  * @hide
  */
 public boolean resumeSink(BluetoothDevice device) {
   if (mService != null && isEnabled() && isValidDevice(device)) {
     try {
       return mService.resumeSink(device);
     } catch (RemoteException e) {
       Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
       return false;
     }
   }
   if (mService == null) Log.w(TAG, "Proxy not attached to service");
   return false;
 }
Example #9
0
 /**
  * Get the priority of the profile.
  *
  * <p>The priority can be any of: {@link #PRIORITY_AUTO_CONNECT}, {@link #PRIORITY_OFF}, {@link
  * #PRIORITY_ON}, {@link #PRIORITY_UNDEFINED}
  *
  * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
  *
  * @param device Bluetooth device
  * @return priority of the device
  * @hide
  */
 public int getPriority(BluetoothDevice device) {
   if (DBG) log("getPriority(" + device + ")");
   if (mService != null && isEnabled() && isValidDevice(device)) {
     try {
       return mService.getPriority(device);
     } catch (RemoteException e) {
       Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
       return BluetoothProfile.PRIORITY_OFF;
     }
   }
   if (mService == null) Log.w(TAG, "Proxy not attached to service");
   return BluetoothProfile.PRIORITY_OFF;
 }
Example #10
0
 /** {@inheritDoc} */
 public int getConnectionState(BluetoothDevice device) {
   if (DBG) log("getState(" + device + ")");
   if (mService != null && isEnabled() && isValidDevice(device)) {
     try {
       return mService.getConnectionState(device);
     } catch (RemoteException e) {
       Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
       return BluetoothProfile.STATE_DISCONNECTED;
     }
   }
   if (mService == null) Log.w(TAG, "Proxy not attached to service");
   return BluetoothProfile.STATE_DISCONNECTED;
 }
Example #11
0
 /** {@inheritDoc} */
 public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
   if (DBG) log("getDevicesMatchingStates()");
   if (mService != null && isEnabled()) {
     try {
       return mService.getDevicesMatchingConnectionStates(states);
     } catch (RemoteException e) {
       Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
       return new ArrayList<BluetoothDevice>();
     }
   }
   if (mService == null) Log.w(TAG, "Proxy not attached to service");
   return new ArrayList<BluetoothDevice>();
 }
Example #12
0
 /**
  * Initiate disconnection from a profile
  *
  * <p>This API will return false in scenarios like the profile on the Bluetooth device is not in
  * connected state etc. When this API returns, true, it is guaranteed that the connection state
  * change intent will be broadcasted with the state. Users can get the disconnection state of the
  * profile from this intent.
  *
  * <p>If the disconnection is initiated by a remote device, the state will transition from {@link
  * #STATE_CONNECTED} to {@link #STATE_DISCONNECTED}. If the disconnect is initiated by the host
  * (local) device the state will transition from {@link #STATE_CONNECTED} to state {@link
  * #STATE_DISCONNECTING} to state {@link #STATE_DISCONNECTED}. The transition to {@link
  * #STATE_DISCONNECTING} can be used to distinguish between the two scenarios.
  *
  * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} permission.
  *
  * @param device Remote Bluetooth Device
  * @return false on immediate error, true otherwise
  * @hide
  */
 public boolean disconnect(BluetoothDevice device) {
   if (DBG) log("disconnect(" + device + ")");
   if (mService != null && isEnabled() && isValidDevice(device)) {
     try {
       return mService.disconnect(device);
     } catch (RemoteException e) {
       Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
       return false;
     }
   }
   if (mService == null) Log.w(TAG, "Proxy not attached to service");
   return false;
 }
Example #13
0
 /**
  * Set priority of the profile
  *
  * <p>The device should already be paired. Priority can be one of {@link #PRIORITY_ON} or {@link
  * #PRIORITY_OFF},
  *
  * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} permission.
  *
  * @param device Paired bluetooth device
  * @param priority
  * @return true if priority is set, false on error
  * @hide
  */
 public boolean setPriority(BluetoothDevice device, int priority) {
   if (DBG) log("setPriority(" + device + ", " + priority + ")");
   if (mService != null && isEnabled() && isValidDevice(device)) {
     if (priority != BluetoothProfile.PRIORITY_OFF && priority != BluetoothProfile.PRIORITY_ON) {
       return false;
     }
     try {
       return mService.setPriority(device, priority);
     } catch (RemoteException e) {
       Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
       return false;
     }
   }
   if (mService == null) Log.w(TAG, "Proxy not attached to service");
   return false;
 }