Esempio n. 1
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;
 }