Build 1.0_r1(from source)

android.server
Class BluetoothDeviceService

java.lang.Object
  extended by android.os.Binder
      extended by android.bluetooth.IBluetoothDevice.Stub
          extended by android.server.BluetoothDeviceService
All Implemented Interfaces:
IBluetoothDevice, IBinder, IInterface

public class BluetoothDeviceService
extends IBluetoothDevice.Stub


Nested Class Summary
 
Nested classes/interfaces inherited from interface android.bluetooth.IBluetoothDevice
IBluetoothDevice.Stub
 
Nested classes/interfaces inherited from interface android.os.IBinder
IBinder.DeathRecipient
 
Field Summary
 
Fields inherited from interface android.os.IBinder
DUMP_TRANSACTION, FIRST_CALL_TRANSACTION, FLAG_ONEWAY, INTERFACE_TRANSACTION, LAST_CALL_TRANSACTION, PING_TRANSACTION
 
Constructor Summary
BluetoothDeviceService(Context context)
           
 
Method Summary
 boolean cancelBondingProcess(String address)
          This method cancels a pending bonding request.
 boolean cancelDiscovery()
          Cancel a remote-device discovery.
 boolean cancelPin(String address)
           
 boolean clearRemoteAlias(String address)
          Removes the alias of a remote device.
 boolean createBonding(String address, IBluetoothDeviceCallback callback)
          This method initiates a Bonding request to a remote device.
 boolean disable()
          Disable bluetooth.
 boolean disconnectRemoteDeviceAcl(String address)
           
protected  void dump(FileDescriptor fd, PrintWriter pw, String[] args)
          Print the object's state into the given stream.
 boolean enable(IBluetoothDeviceCallback callback)
          Enable this Bluetooth device, asynchronously.
protected  void finalize()
          Called by the virtual machine when there are no longer any (non-weak) references to the receiver.
(package private)  String getAdapterPathNative()
           
 String getAddress()
           
 String getCompany()
          Returns the company name from the OUI database of the Bluetooth device address.
 int getDiscoverableTimeout()
          Get the discoverability window for the device.
 String getMajorClass()
           
 String getManufacturer()
          Returns the manufacturer of the Bluetooth chip.
 String getMinorClass()
           
 int getMode()
          Determines which one of three modes this adapter is in: discoverable and connectable, not discoverable but connectable, or neither.
 String getName()
           
 String getRemoteAlias(String address)
          Retrieves the alias of a remote device.
 int getRemoteClass(String address)
          Gets the remote major, minor, and service classes encoded as a 32-bit integer.
 String getRemoteCompany(String address)
          Like getCompany(), but for a remote device.
 byte[] getRemoteFeatures(String address)
          Gets the remote features encoded as bit mask.
 String getRemoteMajorClass(String address)
          Gets the major device class of the specified device.
 String getRemoteManufacturer(String address)
          Like getManufacturer(), but for a remote device.
 String getRemoteMinorClass(String address)
          Gets the minor device class of the specified device.
 String getRemoteName(String address)
          Returns the user-friendly name of a remote device.
 String getRemoteRevision(String address)
          Like getRevision(), but for a remote device.
 boolean getRemoteServiceChannel(String address, int uuid16, IBluetoothDeviceCallback callback)
           
 String[] getRemoteServiceClasses(String address)
          Gets the service classes of the specified device.
 int[] getRemoteServiceHandles(String address, String match)
          This method and getRemoteServiceRecord(java.lang.String, int) query the SDP service on a remote device.
 byte[] getRemoteServiceRecord(String address, int handle)
          This method retrieves the service records corresponding to a given service handle (method getRemoteServiceHandles(java.lang.String, java.lang.String) retrieves the service handles.) This method and getRemoteServiceHandles(java.lang.String, java.lang.String) do not interpret their data, but simply return it raw to the user.
 String getRemoteVersion(String address)
          Like getVersion(), but for a remote device.
 String getRevision()
          Returns the revision of the Bluetooth chip.
 String getVersion()
          Returns the version of the Bluetooth chip.
 boolean hasBonding(String address)
           
 void init()
          Must be called after construction, and before any other method.
 boolean isAclConnected(String address)
           
 boolean isConnectable()
          Detetermines whether this device is connectable (that is, whether remote devices can connect to it.)
 boolean isDiscoverable()
          Detetermines whether this device is discoverable.
 boolean isDiscovering()
           
 boolean isEnabled()
           
 boolean isPeriodicDiscovery()
           
 String lastSeen(String address)
          Returns the date and time when the specified remote device has been seen by a discover procedure.
 String lastUsed(String address)
          Returns the date and time when the specified remote device has last been connected to Example: "2006-02-08 12:00:00 GMT"
 String[] listAclConnections()
           
 String[] listBondings()
           
 String[] listRemoteDevices()
          This method lists all remote devices that this adapter is aware of.
 boolean removeBonding(String address)
          This method removes a bonding to a remote device.
 boolean setDiscoverableTimeout(int timeout)
          Set the discoverability window for the device.
(package private)  void setIsDiscovering(boolean isDiscovering)
           
 boolean setMode(int mode)
          Set the discoverability and connectability mode of this adapter.
 boolean setName(String name)
           
 boolean setPin(String address, byte[] pin)
           
 boolean setRemoteAlias(String address, String alias)
          Changes the alias of a remote device.
 boolean startDiscovery(boolean resolveNames)
          Initiate a remote-device-discovery procedure.
 boolean startPeriodicDiscovery()
           
 boolean stopPeriodicDiscovery()
           
 
Methods inherited from class android.bluetooth.IBluetoothDevice.Stub
asBinder, asInterface, onTransact
 
Methods inherited from class android.os.Binder
attachInterface, clearCallingIdentity, flushPendingCommands, getCallingPid, getCallingUid, getInterfaceDescriptor, isBinderAlive, joinThreadPool, linkToDeath, pingBinder, queryLocalInterface, restoreCallingIdentity, transact, unlinkToDeath
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BluetoothDeviceService

public BluetoothDeviceService(Context context)
Method Detail

init

public void init()
Must be called after construction, and before any other method.


finalize

protected void finalize()
                 throws Throwable
Description copied from class: Object
Called by the virtual machine when there are no longer any (non-weak) references to the receiver. Subclasses can use this facility to guarantee that any associated resources are cleaned up before the receiver is garbage collected. Uncaught exceptions which are thrown during the running of the method cause it to terminate immediately, but are otherwise ignored.

Note: The virtual machine assumes that the implementation in class Object is empty.

Overrides:
finalize in class Binder
Throws:
Throwable - The virtual machine ignores any exceptions which are thrown during finalization.

isEnabled

public boolean isEnabled()

disable

public boolean disable()
Disable bluetooth. Returns true on success.


enable

public boolean enable(IBluetoothDeviceCallback callback)
Enable this Bluetooth device, asynchronously. This turns on/off the underlying hardware.

Returns:
True on success (so far), guarenteeing the callback with be notified when complete.

getAddress

public String getAddress()

getName

public String getName()

setName

public boolean setName(String name)

listBondings

public String[] listBondings()

getMajorClass

public String getMajorClass()

getMinorClass

public String getMinorClass()

getRemoteName

public String getRemoteName(String address)
Returns the user-friendly name of a remote device. This value is retrned from our local cache, which is updated during device discovery. Do not expect to retrieve the updated remote name immediately after changing the name on the remote device.

Parameters:
address - Bluetooth address of remote device.
Returns:
The user-friendly name of the specified remote device.

getAdapterPathNative

String getAdapterPathNative()

startDiscovery

public boolean startDiscovery(boolean resolveNames)
Initiate a remote-device-discovery procedure. This procedure may be canceled by calling #stopDiscovery. Remote-device discoveries are returned as intents

Typically, when a remote device is found, your android.bluetooth.DiscoveryEventNotifier#notifyRemoteDeviceFound method will be invoked, and subsequently, your android.bluetooth.RemoteDeviceEventNotifier#notifyRemoteNameUpdated will tell you the user-friendly name of the remote device. However, it is possible that the name update may fail for various reasons, so you should display the device's Bluetooth address as soon as you get a notifyRemoteDeviceFound event, and update the name when you get the remote name.

Returns:
true if discovery has started, false otherwise.

cancelDiscovery

public boolean cancelDiscovery()
Cancel a remote-device discovery. Note: you may safely call this method even when discovery has not been started.


isDiscovering

public boolean isDiscovering()

setIsDiscovering

void setIsDiscovering(boolean isDiscovering)

startPeriodicDiscovery

public boolean startPeriodicDiscovery()

stopPeriodicDiscovery

public boolean stopPeriodicDiscovery()

isPeriodicDiscovery

public boolean isPeriodicDiscovery()

setDiscoverableTimeout

public boolean setDiscoverableTimeout(int timeout)
Set the discoverability window for the device. A timeout of zero makes the device permanently discoverable (if the device is discoverable). Setting the timeout to a nonzero value does not make a device discoverable; you need to call setMode() to make the device explicitly discoverable.

Parameters:
timeout_s - The discoverable timeout in seconds.

getDiscoverableTimeout

public int getDiscoverableTimeout()
Get the discoverability window for the device. A timeout of zero means that the device is permanently discoverable (if the device is in the discoverable mode).

Returns:
The discoverability window of the device, in seconds. A negative value indicates an error.

isAclConnected

public boolean isAclConnected(String address)

isConnectable

public boolean isConnectable()
Detetermines whether this device is connectable (that is, whether remote devices can connect to it.)

Note: A Bluetooth adapter has separate connectable and discoverable states, and you could have any combination of those. Although any combination is possible (such as discoverable but not connectable), we restrict the possible combinations to one of three possibilities: discoverable and connectable, connectable but not discoverable, and neither connectable nor discoverable.

Returns:
true if this adapter is connectable false otherwise
See Also:
isDiscoverable(), getMode(), setMode(int)

isDiscoverable

public boolean isDiscoverable()
Detetermines whether this device is discoverable. Note: a Bluetooth adapter has separate connectable and discoverable states, and you could have any combination of those. Although any combination is possible (such as discoverable but not connectable), we restrict the possible combinations to one of three possibilities: discoverable and connectable, connectable but not discoverable, and neither connectable nor discoverable.

Returns:
true if this adapter is discoverable false otherwise
See Also:
isConnectable(), getMode(), setMode(int)

getMode

public int getMode()
Determines which one of three modes this adapter is in: discoverable and connectable, not discoverable but connectable, or neither.

Returns:
Mode enumeration containing the current mode.
See Also:
setMode(int)

setMode

public boolean setMode(int mode)
Set the discoverability and connectability mode of this adapter. The possibilities are discoverable and connectable (MODE_DISCOVERABLE), connectable but not discoverable (MODE_CONNECTABLE), and neither (MODE_OFF). Note: MODE_OFF does not mean that the adapter is physically off. It may be neither discoverable nor connectable, but it could still initiate outgoing connections, or could participate in a connection initiated by a remote device before its mode was set to MODE_OFF.

Parameters:
mode - the new mode
See Also:
getMode()

getRemoteAlias

public String getRemoteAlias(String address)
Retrieves the alias of a remote device. The alias is a local feature, and allows us to associate a name with a remote device that is different from that remote device's user-friendly name. The remote device knows nothing about this. The alias can be changed with setRemoteAlias(java.lang.String, java.lang.String), and it may be removed with clearRemoteAlias(java.lang.String)

Parameters:
address - Bluetooth address of remote device.
Returns:
The alias of the remote device.

setRemoteAlias

public boolean setRemoteAlias(String address,
                              String alias)
Changes the alias of a remote device. The alias is a local feature, from that remote device's user-friendly name. The remote device knows nothing about this. The alias can be retrieved with getRemoteAlias(java.lang.String), and it may be removed with clearRemoteAlias(java.lang.String).

Parameters:
address - Bluetooth address of remote device
alias - Alias for the remote device

clearRemoteAlias

public boolean clearRemoteAlias(String address)
Removes the alias of a remote device. The alias is a local feature, from that remote device's user-friendly name. The remote device knows nothing about this. The alias can be retrieved with getRemoteAlias(java.lang.String).

Parameters:
address - Bluetooth address of remote device

disconnectRemoteDeviceAcl

public boolean disconnectRemoteDeviceAcl(String address)

createBonding

public boolean createBonding(String address,
                             IBluetoothDeviceCallback callback)
This method initiates a Bonding request to a remote device.

Parameters:
address - The Bluetooth address of the remote device
See Also:
createBonding(java.lang.String, android.bluetooth.IBluetoothDeviceCallback), cancelBondingProcess(java.lang.String), removeBonding(java.lang.String), hasBonding(java.lang.String), listBondings(), android.bluetooth.PasskeyAgent

cancelBondingProcess

public boolean cancelBondingProcess(String address)
This method cancels a pending bonding request.

Parameters:
address - The Bluetooth address of the remote device to which a bonding request has been initiated. Note: When a request is canceled, method CreateBondingResultNotifier#notifyAuthenticationFailed will be called on the object passed to method createBonding(java.lang.String, android.bluetooth.IBluetoothDeviceCallback). Note: it is safe to call this method when there is no outstanding bonding request.
See Also:
createBonding(java.lang.String, android.bluetooth.IBluetoothDeviceCallback), cancelBondingProcess(java.lang.String), removeBonding(java.lang.String), hasBonding(java.lang.String), listBondings()

removeBonding

public boolean removeBonding(String address)
This method removes a bonding to a remote device. This is a local operation only, resulting in this adapter "forgetting" the bonding information about the specified remote device. The other device itself does not know what the bonding has been torn down. The next time either device attemps to connect to the other, the connection will fail, and the pairing procedure will have to be re-initiated.

Parameters:
address - The Bluetooth address of the remote device.
See Also:
createBonding(java.lang.String, android.bluetooth.IBluetoothDeviceCallback), cancelBondingProcess(java.lang.String), removeBonding(java.lang.String), hasBonding(java.lang.String), listBondings()

hasBonding

public boolean hasBonding(String address)

listAclConnections

public String[] listAclConnections()

listRemoteDevices

public String[] listRemoteDevices()
This method lists all remote devices that this adapter is aware of. This is a list not only of all most-recently discovered devices, but of all devices discovered by this adapter up to some point in the past. Note that many of these devices may not be in the neighborhood anymore, and attempting to connect to them will result in an error.

Returns:
An array of strings representing the Bluetooth addresses of all remote devices that this adapter is aware of.

getVersion

public String getVersion()
Returns the version of the Bluetooth chip. This version is compiled from the LMP version. In case of EDR the features attribute must be checked. Example: "Bluetooth 2.0 + EDR".

Returns:
a String representation of the this Adapter's underlying Bluetooth-chip version.

getRevision

public String getRevision()
Returns the revision of the Bluetooth chip. This is a vendor-specific value and in most cases it represents the firmware version. This might derive from the HCI revision and LMP subversion values or via extra vendord specific commands. In case the revision of a chip is not available. This method should return the LMP subversion value as a string. Example: "HCI 19.2"

Returns:
The HCI revision of this adapter.

getManufacturer

public String getManufacturer()
Returns the manufacturer of the Bluetooth chip. If the company id is not known the sting "Company ID %d" where %d should be replaced with the numeric value from the manufacturer field. Example: "Cambridge Silicon Radio"

Returns:
Manufacturer name.

getCompany

public String getCompany()
Returns the company name from the OUI database of the Bluetooth device address. This function will need a valid and up-to-date oui.txt from the IEEE. This value will be different from the manufacturer string in the most cases. If the oui.txt file is not present or the OUI part of the Bluetooth address is not listed, it should return the string "OUI %s" where %s is the actual OUI. Example: "Apple Computer"

Returns:
company name

getRemoteVersion

public String getRemoteVersion(String address)
Like getVersion(), but for a remote device.

Parameters:
address - The Bluetooth address of the remote device.
Returns:
remote-device Bluetooth version
See Also:
getVersion()

getRemoteRevision

public String getRemoteRevision(String address)
Like getRevision(), but for a remote device.

Parameters:
address - The Bluetooth address of the remote device.
Returns:
remote-device HCI revision
See Also:
getRevision()

getRemoteManufacturer

public String getRemoteManufacturer(String address)
Like getManufacturer(), but for a remote device.

Parameters:
address - The Bluetooth address of the remote device.
Returns:
remote-device Bluetooth chip manufacturer
See Also:
getManufacturer()

getRemoteCompany

public String getRemoteCompany(String address)
Like getCompany(), but for a remote device.

Parameters:
address - The Bluetooth address of the remote device.
Returns:
remote-device company
See Also:
getCompany()

lastSeen

public String lastSeen(String address)
Returns the date and time when the specified remote device has been seen by a discover procedure. Example: "2006-02-08 12:00:00 GMT"

Returns:
a String with the timestamp.

lastUsed

public String lastUsed(String address)
Returns the date and time when the specified remote device has last been connected to Example: "2006-02-08 12:00:00 GMT"

Returns:
a String with the timestamp.

getRemoteMajorClass

public String getRemoteMajorClass(String address)
Gets the major device class of the specified device. Example: "computer" Note: This is simply a string desciption of the major class of the device-class information, which is returned as a 32-bit value during device discovery.

Parameters:
address - The Bluetooth address of the remote device.
Returns:
remote-device major class
See Also:
getRemoteClass(java.lang.String)

getRemoteMinorClass

public String getRemoteMinorClass(String address)
Gets the minor device class of the specified device. Example: "laptop" Note: This is simply a string desciption of the minor class of the device-class information, which is returned as a 32-bit value during device discovery.

Parameters:
address - The Bluetooth address of the remote device.
Returns:
remote-device minor class
See Also:
getRemoteClass(java.lang.String)

getRemoteServiceClasses

public String[] getRemoteServiceClasses(String address)
Gets the service classes of the specified device. Example: ["networking", "object transfer"]

Returns:
a String array with the descriptions of the service classes.
See Also:
getRemoteClass(java.lang.String)

getRemoteClass

public int getRemoteClass(String address)
Gets the remote major, minor, and service classes encoded as a 32-bit integer. Note: this value is retrieved from cache, because we get it during remote-device discovery.

Returns:
32-bit integer encoding the remote major, minor, and service classes.
See Also:
getRemoteMajorClass(java.lang.String), getRemoteMinorClass(java.lang.String), getRemoteServiceClasses(java.lang.String)

getRemoteFeatures

public byte[] getRemoteFeatures(String address)
Gets the remote features encoded as bit mask. Note: This method may be obsoleted soon.

Returns:
byte array of features.

getRemoteServiceHandles

public int[] getRemoteServiceHandles(String address,
                                     String match)
This method and getRemoteServiceRecord(java.lang.String, int) query the SDP service on a remote device. They do not interpret the data, but simply return it raw to the user. To read more about SDP service handles and records, consult the Bluetooth core documentation (www.bluetooth.com).

Parameters:
address - Bluetooth address of remote device.
match - a String match to narrow down the service-handle search. The only supported value currently is "hsp" for the headset profile. To retrieve all service handles, simply pass an empty match string.
Returns:
all service handles corresponding to the string match.
See Also:
getRemoteServiceRecord(java.lang.String, int)

getRemoteServiceRecord

public byte[] getRemoteServiceRecord(String address,
                                     int handle)
This method retrieves the service records corresponding to a given service handle (method getRemoteServiceHandles(java.lang.String, java.lang.String) retrieves the service handles.) This method and getRemoteServiceHandles(java.lang.String, java.lang.String) do not interpret their data, but simply return it raw to the user. To read more about SDP service handles and records, consult the Bluetooth core documentation (www.bluetooth.com).

Parameters:
address - Bluetooth address of remote device.
handle - Service handle returned by getRemoteServiceHandles(java.lang.String, java.lang.String)
Returns:
a byte array of all service records corresponding to the specified service handle.
See Also:
getRemoteServiceHandles(java.lang.String, java.lang.String)

getRemoteServiceChannel

public boolean getRemoteServiceChannel(String address,
                                       int uuid16,
                                       IBluetoothDeviceCallback callback)

setPin

public boolean setPin(String address,
                      byte[] pin)

cancelPin

public boolean cancelPin(String address)

dump

protected void dump(FileDescriptor fd,
                    PrintWriter pw,
                    String[] args)
Description copied from class: Binder
Print the object's state into the given stream.

Overrides:
dump in class Binder
Parameters:
fd - The raw file descriptor that the dump is being sent to.
pw - The file to which you should dump your state. This will be closed for you after you return.
args - additional arguments to the dump request.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature