Esempio n. 1
0
 public static synchronized A2dpService getA2dpService() {
   if (sAd2dpService != null && sAd2dpService.isAvailable()) {
     if (DBG) Log.d(TAG, "getA2DPService(): returning " + sAd2dpService);
     return sAd2dpService;
   }
   if (DBG) {
     if (sAd2dpService == null) {
       Log.d(TAG, "getA2dpService(): service is NULL");
     } else if (!(sAd2dpService.isAvailable())) {
       Log.d(TAG, "getA2dpService(): service is not available");
     }
   }
   return null;
 }
Esempio n. 2
0
 private static synchronized void setA2dpService(A2dpService instance) {
   if (instance != null && instance.isAvailable()) {
     if (DBG) Log.d(TAG, "setA2dpService(): set to: " + sAd2dpService);
     sAd2dpService = instance;
   } else {
     if (DBG) {
       if (sAd2dpService == null) {
         Log.d(TAG, "setA2dpService(): service not available");
       } else if (!sAd2dpService.isAvailable()) {
         Log.d(TAG, "setA2dpService(): service is cleaning up");
       }
     }
   }
 }
Esempio n. 3
0
    private A2dpService getService() {
      if (!Utils.checkCaller()) {
        Log.w(TAG, "A2dp call not allowed for non-active user");
        return null;
      }

      if (mService != null && mService.isAvailable()) {
        return mService;
      }
      return null;
    }
Esempio n. 4
0
 boolean okToConnect(BluetoothDevice device) {
   AdapterService adapterService = AdapterService.getAdapterService();
   int priority = mService.getPriority(device);
   boolean ret = false;
   // check if this is an incoming connection in Quiet mode.
   if ((adapterService == null)
       || ((adapterService.isQuietModeEnabled() == true) && (mTargetDevice == null))) {
     ret = false;
   }
   // check priority and accept or reject the connection. if priority is undefined
   // it is likely that our SDP has not completed and peer is initiating the
   // connection. Allow this connection, provided the device is bonded
   else if ((BluetoothProfile.PRIORITY_OFF < priority)
       || ((BluetoothProfile.PRIORITY_UNDEFINED == priority)
           && (device.getBondState() != BluetoothDevice.BOND_NONE))) {
     ret = true;
   }
   return ret;
 }
Esempio n. 5
0
 public boolean isA2dpPlaying(BluetoothDevice device) {
   A2dpService service = getService();
   if (service == null) return false;
   return service.isA2dpPlaying(device);
 }
Esempio n. 6
0
 public void setAvrcpAbsoluteVolume(int volume) {
   A2dpService service = getService();
   if (service == null) return;
   service.setAvrcpAbsoluteVolume(volume);
 }
Esempio n. 7
0
 public void adjustAvrcpAbsoluteVolume(int direction) {
   A2dpService service = getService();
   if (service == null) return;
   service.adjustAvrcpAbsoluteVolume(direction);
 }
Esempio n. 8
0
 public boolean isAvrcpAbsoluteVolumeSupported() {
   A2dpService service = getService();
   if (service == null) return false;
   return service.isAvrcpAbsoluteVolumeSupported();
 }
Esempio n. 9
0
 public int getPriority(BluetoothDevice device) {
   A2dpService service = getService();
   if (service == null) return BluetoothProfile.PRIORITY_UNDEFINED;
   return service.getPriority(device);
 }
Esempio n. 10
0
 public boolean setPriority(BluetoothDevice device, int priority) {
   A2dpService service = getService();
   if (service == null) return false;
   return service.setPriority(device, priority);
 }
Esempio n. 11
0
 public int getConnectionState(BluetoothDevice device) {
   A2dpService service = getService();
   if (service == null) return BluetoothProfile.STATE_DISCONNECTED;
   return service.getConnectionState(device);
 }
Esempio n. 12
0
 public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
   A2dpService service = getService();
   if (service == null) return new ArrayList<BluetoothDevice>(0);
   return service.getDevicesMatchingConnectionStates(states);
 }
Esempio n. 13
0
 public List<BluetoothDevice> getConnectedDevices() {
   A2dpService service = getService();
   if (service == null) return new ArrayList<BluetoothDevice>(0);
   return service.getConnectedDevices();
 }
Esempio n. 14
0
 public boolean disconnect(BluetoothDevice device) {
   A2dpService service = getService();
   if (service == null) return false;
   return service.disconnect(device);
 }