Methods Summary |
---|
private static native int | getRecordHandle(java.lang.String url)Retrieves service record handle for a service maintained by
Bluetooth push subsytem.
|
public static ServiceRecordImpl | getServiceRecord(BluetoothNotifier notifier, java.lang.String url)Retrieves service record associated with a service maintained by
Bluetooth push subsytem.
return SDDB.getInstance().getServiceRecord(getRecordHandle(url),
notifier);
|
public static void | registerUrl(java.lang.String url)Registers URL within Bluetooth push subsytem.
ServiceRecordImpl record = null;
String protocol = url.substring(0, url.indexOf(':")).toUpperCase();
if (protocol.equals("BTL2CAP")) {
record = L2CAPNotifierImpl.createServiceRecord(url);
} else if (protocol.equals("BTSPP")) {
record = BTSPPNotifierImpl.createServiceRecord(url);
} else if (protocol.equals("BTGOEP")) {
record = BTSPPNotifierImpl.createServiceRecord(url);
} else {
throw new RuntimeException("Unsupported Bluetooth protocol.");
}
if (!BCC.getInstance().isBluetoothEnabled() &&
!BCC.getInstance().enableBluetooth()) {
throw new IOException("Bluetooth radio is not enabled.");
}
if (!registerUrl(url, srs.serialize(record))) {
throw new IOException("Error registering Bluetooth URL.");
}
if (BCC.getInstance().getAccessCode() != DiscoveryAgent.GIAC) {
BCC.getInstance().setAccessCode(DiscoveryAgent.GIAC);
}
// get the emulation services up and running
SDDB.getInstance();
|
private static native boolean | registerUrl(java.lang.String url, byte[] data)Registers URL within Bluetooth push subsystem.
|
public static void | verifyFilter(java.lang.String filter)Checks if the specified AllowedSender field is valid.
if (filter.length() == 0) {
throw new IllegalArgumentException();
}
filter = filter.toUpperCase();
int i = 0;
while (i < filter.length() && i < 12) {
char c = filter.charAt(i++);
if (c == '*" || c == '?") {
continue;
}
if (c == ';") {
i--;
if (i == 0) {
throw new IllegalArgumentException(
"Invalid Bluetooth address.");
}
break;
}
if ((c < '0" || c > '9") && (c < 'A" || c > 'F")) {
throw new IllegalArgumentException(
"Invalid Bluetooth address.");
}
}
filter = filter.substring(i);
if (filter.length() == 0) {
return;
}
if (filter.startsWith(AUTHENTICATED)) {
filter = filter.substring(AUTHENTICATED.length());
} else if (filter.startsWith(AUTHORIZED)) {
filter = filter.substring(AUTHORIZED.length());
}
if (filter.length() == 0) {
return;
}
if (!filter.startsWith(BLACKLIST)) {
throw new IllegalArgumentException("Invalid parameter.");
}
filter = filter.substring(BLACKLIST.length());
if (filter.length() == 0) {
throw new IllegalArgumentException("Invalid blacklist.");
}
int count = 0;
while (true) {
if (++count > 1024) {
throw new IllegalArgumentException("Blacklist too long.");
}
i = 0;
while (i < filter.length() && i < 12) {
char c = filter.charAt(i++);
if (c == '*" || c == '?") {
continue;
}
if (c == ';") {
i--;
break;
}
if ((c < '0" || c > '9") && (c < 'A" || c > 'F")) {
throw new IllegalArgumentException(
"Invalid blacklist address.");
}
}
filter = filter.substring(i);
if (filter.length() == 0) {
return;
}
if (filter.charAt(0) != ';" || filter.length() == 1) {
throw new IllegalArgumentException("Invalid blacklist.");
}
filter = filter.substring(1);
}
|
public static void | verifyUrl(java.lang.String url)Checks if the specified URL is valid.
BluetoothUrl btUrl = new BluetoothUrl(url);
if ((btUrl.encrypt || btUrl.authorize) && !btUrl.authenticate) {
throw new IllegalArgumentException(
"'authenticate=true' parameter is required.");
}
|