Methods Summary |
---|
public synchronized int | addServiceRecord(byte[] record)Add a new service record.
int handle = addServiceRecordNative(record);
Log.i(sLogName, "Added SDP record: " + Integer.toHexString(handle));
return handle;
|
public synchronized int | addServiceRecordFromXml(java.lang.String record)Add a new service record, using XML.
int handle = addServiceRecordFromXmlNative(record);
Log.i(sLogName, "Added SDP record: " + Integer.toHexString(handle));
return handle;
|
private native int | addServiceRecordFromXmlNative(java.lang.String record)
|
private native int | addServiceRecordNative(byte[] record)
|
public int | advertiseRfcommService(android.bluetooth.RfcommSocket socket, java.lang.String serviceName, java.util.UUID uuid)Advertise a service with an RfcommSocket.
This adds the service the SDP Database with the following attributes
set: Service Name, Protocol Descriptor List, Service Class ID List
TODO: Construct a byte[] record directly, rather than via XML.
String xmlRecord =
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
"<record>\n" +
" <attribute id=\"0x0001\">\n" + // ServiceClassIDList
" <sequence>\n" +
" <uuid value=\""
+ uuid.toString() + // UUID for this service
"\"/>\n" +
" </sequence>\n" +
" </attribute>\n" +
" <attribute id=\"0x0004\">\n" + // ProtocolDescriptorList
" <sequence>\n" +
" <sequence>\n" +
" <uuid value=\"0x0100\"/>\n" + // L2CAP
" </sequence>\n" +
" <sequence>\n" +
" <uuid value=\"0x0003\"/>\n" + // RFCOMM
" <uint8 value=\"" +
socket.getPort() + // RFCOMM port
"\" name=\"channel\"/>\n" +
" </sequence>\n" +
" </sequence>\n" +
" </attribute>\n" +
" <attribute id=\"0x0100\">\n" + // ServiceName
" <text value=\"" + serviceName + "\"/>\n" +
" </attribute>\n" +
"</record>\n";
Log.i(sLogName, xmlRecord);
return addServiceRecordFromXml(xmlRecord);
|
private static native void | classInitNative()Class load time initialization
|
private native void | cleanupNativeDataNative()
|
protected void | finalize()
try {
cleanupNativeDataNative();
} finally {
super.finalize();
}
|
public static synchronized android.bluetooth.Database | getInstance()Singelton accessor
if (mInstance == null) {
mInstance = new Database();
}
return mInstance;
|
private native void | initializeNativeDataNative()
|
public synchronized void | removeServiceRecord(int handle)Remove a service record.
It is only possible to remove service records that were added by the
current connection.
try {
removeServiceRecordNative(handle);
} catch (IOException e) {
Log.e(getClass().toString(), e.getMessage());
}
|
private native void | removeServiceRecordNative(int handle)
|
public synchronized void | updateServiceRecord(int handle, byte[] record)Update an exisiting service record.
try {
updateServiceRecordNative(handle, record);
} catch (IOException e) {
Log.e(getClass().toString(), e.getMessage());
}
|
public synchronized void | updateServiceRecordFromXml(int handle, java.lang.String record)Update an exisiting record, using XML.
try {
updateServiceRecordFromXmlNative(handle, record);
} catch (IOException e) {
Log.e(getClass().toString(), e.getMessage());
}
|
private native void | updateServiceRecordFromXmlNative(int handle, java.lang.String record)
|
private native void | updateServiceRecordNative(int handle, byte[] record)
|