Exemplo n.º 1
0
 public void l2CloseClientConnection(long handle) throws IOException {
   assertClosed();
   EmulatorL2CAPClient c = ((EmulatorL2CAPClient) localDevice.getConnection(handle));
   try {
     c.close();
   } finally {
     localDevice.removeConnection(c);
   }
 }
Exemplo n.º 2
0
 public void l2ServerClose(long handle, ServiceRecordImpl serviceRecord) throws IOException {
   assertClosed();
   EmulatorL2CAPService s = ((EmulatorL2CAPService) localDevice.getConnection(handle));
   try {
     s.close(serviceRecord);
   } finally {
     localDevice.removeConnection(s);
   }
 }
Exemplo n.º 3
0
 public void connectionRfCloseClientConnection(long handle) throws IOException {
   assertClosed();
   if (localDevice == null) {
     return;
   }
   EmulatorRFCOMMClient c = ((EmulatorRFCOMMClient) localDevice.getConnection(handle));
   try {
     c.close();
   } finally {
     if (localDevice != null) {
       localDevice.removeConnection(c);
     }
   }
 }
Exemplo n.º 4
0
 public long l2ServerAcceptAndOpenServerConnection(long handle) throws IOException {
   EmulatorL2CAPService s = ((EmulatorL2CAPService) activeLocalDevice().getConnection(handle));
   if (!localDevice.isConnectable()) {
     throw new BluetoothStateException("Local device is not connectable");
   }
   long clientHandle = 0;
   boolean success = false;
   while (!success) {
     long connectionHandle = s.accept();
     try {
       long remoteAddress =
           localDevice
               .getDeviceManagerService()
               .getRemoteAddress(localDevice.getAddress(), connectionHandle);
       EmulatorL2CAPClient c = localDevice.createL2CAPClient(remoteAddress);
       c.connect(remoteAddress, connectionHandle, s.getReceiveMTU(), s.getTransmitMTU());
       localDevice
           .getDeviceManagerService()
           .connectionAccepted(localDevice.getAddress(), connectionHandle);
       success = true;
       clientHandle = c.getHandle();
     } catch (IOException e) {
       DebugLog.debug("fail to accept connection", e);
       continue;
     } finally {
       if (!success) {
         localDevice
             .getDeviceManagerService()
             .closeConnection(localDevice.getAddress(), connectionHandle);
       }
     }
   }
   return clientHandle;
 }
Exemplo n.º 5
0
 public void rfServerClose(long handle, ServiceRecordImpl serviceRecord) throws IOException {
   assertClosed();
   if (localDevice == null) {
     return;
   }
   EmulatorRFCOMMService s = ((EmulatorRFCOMMService) localDevice.getConnection(handle));
   try {
     s.close(serviceRecord);
   } finally {
     if (localDevice != null) {
       localDevice.removeConnection(s);
     }
   }
 }
Exemplo n.º 6
0
 private EmulatorLocalDevice activeLocalDevice() throws BluetoothStateException {
   assertClosed();
   if (!localDevice.isActive()) {
     throw new BluetoothStateException("Bluetooth system is off");
   }
   return localDevice;
 }
Exemplo n.º 7
0
 public String toString() {
   if (localDevice != null) {
     return getStackID() + ":" + RemoteDeviceHelper.getBluetoothAddress(localDevice.getAddress());
   } else {
     return getStackID();
   }
 }
Exemplo n.º 8
0
 public boolean populateServicesRecordAttributeValues(
     ServiceRecordImpl serviceRecord, int[] attrIDs) throws IOException {
   if (attrIDs.length > localDevice.getBluetooth_sd_attr_retrievable_max()) {
     throw new IllegalArgumentException();
   }
   return EmulatorSearchServices.populateServicesRecordAttributeValues(
       activeLocalDevice(),
       serviceRecord,
       attrIDs,
       RemoteDeviceHelper.getAddress(serviceRecord.getHostDevice()),
       serviceRecord.getHandle());
 }
Exemplo n.º 9
0
 public long connectionRfOpenClientConnection(BluetoothConnectionParams params)
     throws IOException {
   EmulatorRFCOMMClient c = activeLocalDevice().createRFCOMMClient(params.address);
   boolean success = false;
   try {
     c.connect(params);
     success = true;
   } finally {
     if (!success) {
       localDevice.removeConnection(c);
     }
   }
   return c.getHandle();
 }
Exemplo n.º 10
0
 public long l2OpenClientConnection(
     BluetoothConnectionParams params, int receiveMTU, int transmitMTU) throws IOException {
   validateMTU(receiveMTU, transmitMTU);
   EmulatorL2CAPClient c = activeLocalDevice().createL2CAPClient(params.address);
   boolean success = false;
   try {
     c.connect(params, receiveMTU, transmitMTU);
     success = true;
   } finally {
     if (!success) {
       localDevice.removeConnection(c);
     }
   }
   return c.getHandle();
 }
Exemplo n.º 11
0
 public long rfServerOpen(
     BluetoothConnectionNotifierParams params, ServiceRecordImpl serviceRecord)
     throws IOException {
   EmulatorRFCOMMService s = activeLocalDevice().createRFCOMMService();
   boolean success = false;
   try {
     s.open(params);
     serviceRecord.setHandle(s.getHandle());
     serviceRecord.populateRFCOMMAttributes(
         s.getHandle(), s.getChannel(), params.uuid, params.name, params.obex);
     s.updateServiceRecord(serviceRecord);
     success = true;
   } finally {
     if (!success) {
       localDevice.removeConnection(s);
     }
   }
   return s.getHandle();
 }
Exemplo n.º 12
0
 public long l2ServerOpen(
     BluetoothConnectionNotifierParams params,
     int receiveMTU,
     int transmitMTU,
     ServiceRecordImpl serviceRecord)
     throws IOException {
   validateMTU(receiveMTU, transmitMTU);
   EmulatorL2CAPService s = activeLocalDevice().createL2CAPService(params.bluecove_ext_psm);
   boolean success = false;
   try {
     s.open(params, receiveMTU, transmitMTU);
     serviceRecord.setHandle(s.getHandle());
     serviceRecord.populateL2CAPAttributes(
         (int) s.getHandle(), s.getPcm(), params.uuid, params.name);
     s.updateServiceRecord(serviceRecord);
     success = true;
   } finally {
     if (!success) {
       localDevice.removeConnection(s);
     }
   }
   return s.getHandle();
 }
Exemplo n.º 13
0
 public boolean isLocalDevicePowerOn() {
   assertClosed();
   return localDevice.isLocalDevicePowerOn();
 }
Exemplo n.º 14
0
 public int getLocalDeviceDiscoverable() {
   assertClosed();
   return localDevice.getLocalDeviceDiscoverable();
 }
Exemplo n.º 15
0
 public boolean setLocalDeviceDiscoverable(int mode) throws BluetoothStateException {
   assertClosed();
   return localDevice.setLocalDeviceDiscoverable(mode);
 }
Exemplo n.º 16
0
 public String getLocalDeviceName() {
   assertClosed();
   return localDevice.getName();
 }
Exemplo n.º 17
0
 /*
  * (non-Javadoc)
  *
  * @see com.intel.bluetooth.BluetoothStack#setLocalDeviceServiceClasses(int)
  */
 public void setLocalDeviceServiceClasses(int classOfDevice) {
   assertClosed();
   localDevice.setLocalDeviceServiceClasses(classOfDevice);
 }
Exemplo n.º 18
0
 private void validateMTU(int receiveMTU, int transmitMTU) {
   if (receiveMTU > localDevice.getBluetooth_l2cap_receiveMTU_max()) {
     throw new IllegalArgumentException("invalid ReceiveMTU value " + receiveMTU);
   }
 }
Exemplo n.º 19
0
 public int l2GetSecurityOpt(long handle, int expected) throws IOException {
   assertClosed();
   return ((EmulatorLinkedConnection) localDevice.getConnection(handle)).getSecurityOpt(expected);
 }
Exemplo n.º 20
0
 public String getLocalDeviceProperty(String property) {
   assertClosed();
   return localDevice.getLocalDeviceProperty(property);
 }
Exemplo n.º 21
0
 public DeviceClass getLocalDeviceClass() {
   assertClosed();
   return new DeviceClass(localDevice.getDeviceClass());
 }
Exemplo n.º 22
0
 /*
  * (non-Javadoc)
  *
  * @see com.intel.bluetooth.BluetoothStack#l2Encrypt(long,long,boolean)
  */
 public boolean l2Encrypt(long address, long handle, boolean on) throws IOException {
   assertClosed();
   return ((EmulatorLinkedConnection) localDevice.getConnection(handle)).encrypt(address, on);
 }
Exemplo n.º 23
0
 public String getLocalDeviceBluetoothAddress() throws BluetoothStateException {
   assertClosed();
   return RemoteDeviceHelper.getBluetoothAddress(localDevice.getAddress());
 }