diff options
author | Nick Pelly <npelly@google.com> | 2009-05-19 15:21:03 -0700 |
---|---|---|
committer | Nick Pelly <npelly@google.com> | 2009-05-29 16:16:04 -0700 |
commit | 9b50ade5b7d186354087cf7cca339c17cbd3622d (patch) | |
tree | 8e4fe98145c74b3e8080e71b15fc78accaf4be39 /core | |
parent | f5b70ef0f244eec1dc3642e05f555598de84e98a (diff) | |
download | frameworks_base-9b50ade5b7d186354087cf7cca339c17cbd3622d.zip frameworks_base-9b50ade5b7d186354087cf7cca339c17cbd3622d.tar.gz frameworks_base-9b50ade5b7d186354087cf7cca339c17cbd3622d.tar.bz2 |
Remove Database.java API.
This provided SDP functionality to Java, but is not currently used by any Apps.
I will shortly be providing SDP functionality in a new API, but it will be
quite different to this one, and in the mean-time keeping this stale code
updated with other API changes is a pain.
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/bluetooth/Database.java | 200 | ||||
-rw-r--r-- | core/jni/Android.mk | 1 | ||||
-rw-r--r-- | core/jni/AndroidRuntime.cpp | 2 | ||||
-rw-r--r-- | core/jni/android_bluetooth_Database.cpp | 183 |
4 files changed, 0 insertions, 386 deletions
diff --git a/core/java/android/bluetooth/Database.java b/core/java/android/bluetooth/Database.java deleted file mode 100644 index fef641a..0000000 --- a/core/java/android/bluetooth/Database.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.bluetooth; - -import android.bluetooth.RfcommSocket; - -import android.util.Log; - -import java.io.*; -import java.util.*; - -/** - * The Android Bluetooth API is not finalized, and *will* change. Use at your - * own risk. - * - * A low-level API to the Service Discovery Protocol (SDP) Database. - * - * Allows service records to be added to the local SDP database. Once added, - * these services will be advertised to remote devices when they make SDP - * queries on this device. - * - * Currently this API is a thin wrapper to the bluez SDP Database API. See: - * http://wiki.bluez.org/wiki/Database - * http://wiki.bluez.org/wiki/HOWTO/ManagingServiceRecords - * @hide - */ -public final class Database { - private static Database mInstance; - - private static final String sLogName = "android.bluetooth.Database"; - - /** - * Class load time initialization - */ - static { - classInitNative(); - } - private native static void classInitNative(); - - /** - * Private to enforce singleton property - */ - private Database() { - initializeNativeDataNative(); - } - private native void initializeNativeDataNative(); - - protected void finalize() throws Throwable { - try { - cleanupNativeDataNative(); - } finally { - super.finalize(); - } - } - private native void cleanupNativeDataNative(); - - /** - * Singelton accessor - * @return The singleton instance of Database - */ - public static synchronized Database getInstance() { - if (mInstance == null) { - mInstance = new Database(); - } - return mInstance; - } - - /** - * 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. - * @param socket The rfcomm socket to advertise (by channel). - * @param serviceName A short name for this service - * @param uuid - * Unique identifier for this service, by which clients - * can search for your service - * @return Handle to the new service record - */ - public int advertiseRfcommService(RfcommSocket socket, - String serviceName, - UUID uuid) throws IOException { - 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); - } - - - /** - * Add a new service record. - * @param record The byte[] record - * @return A handle to the new record - */ - public synchronized int addServiceRecord(byte[] record) throws IOException { - int handle = addServiceRecordNative(record); - Log.i(sLogName, "Added SDP record: " + Integer.toHexString(handle)); - return handle; - } - private native int addServiceRecordNative(byte[] record) - throws IOException; - - /** - * Add a new service record, using XML. - * @param record The record as an XML string - * @return A handle to the new record - */ - public synchronized int addServiceRecordFromXml(String record) throws IOException { - int handle = addServiceRecordFromXmlNative(record); - Log.i(sLogName, "Added SDP record: " + Integer.toHexString(handle)); - return handle; - } - private native int addServiceRecordFromXmlNative(String record) - throws IOException; - - /** - * Update an exisiting service record. - * @param handle Handle to exisiting record - * @param record The updated byte[] record - */ - public synchronized void updateServiceRecord(int handle, byte[] record) { - try { - updateServiceRecordNative(handle, record); - } catch (IOException e) { - Log.e(getClass().toString(), e.getMessage()); - } - } - private native void updateServiceRecordNative(int handle, byte[] record) - throws IOException; - - /** - * Update an exisiting record, using XML. - * @param handle Handle to exisiting record - * @param record The record as an XML string. - */ - public synchronized void updateServiceRecordFromXml(int handle, String record) { - try { - updateServiceRecordFromXmlNative(handle, record); - } catch (IOException e) { - Log.e(getClass().toString(), e.getMessage()); - } - } - private native void updateServiceRecordFromXmlNative(int handle, String record) - throws IOException; - - /** - * Remove a service record. - * It is only possible to remove service records that were added by the - * current connection. - * @param handle Handle to exisiting record to be removed - */ - public synchronized void removeServiceRecord(int handle) { - try { - removeServiceRecordNative(handle); - } catch (IOException e) { - Log.e(getClass().toString(), e.getMessage()); - } - } - private native void removeServiceRecordNative(int handle) throws IOException; -} diff --git a/core/jni/Android.mk b/core/jni/Android.mk index 18f2878..9ad93eb 100644 --- a/core/jni/Android.mk +++ b/core/jni/Android.mk @@ -99,7 +99,6 @@ LOCAL_SRC_FILES:= \ android_util_FileObserver.cpp \ android/opengl/poly_clip.cpp.arm \ android/opengl/util.cpp.arm \ - android_bluetooth_Database.cpp \ android_bluetooth_HeadsetBase.cpp \ android_bluetooth_common.cpp \ android_bluetooth_BluetoothAudioGateway.cpp \ diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp index f4643f4..c3104b8 100644 --- a/core/jni/AndroidRuntime.cpp +++ b/core/jni/AndroidRuntime.cpp @@ -138,7 +138,6 @@ extern int register_android_security_Md5MessageDigest(JNIEnv *env); extern int register_android_text_AndroidCharacter(JNIEnv *env); extern int register_android_text_KeyCharacterMap(JNIEnv *env); extern int register_android_opengl_classes(JNIEnv *env); -extern int register_android_bluetooth_Database(JNIEnv* env); extern int register_android_bluetooth_HeadsetBase(JNIEnv* env); extern int register_android_bluetooth_BluetoothAudioGateway(JNIEnv* env); extern int register_android_bluetooth_RfcommSocket(JNIEnv *env); @@ -1097,7 +1096,6 @@ static const RegJNIRec gRegJNI[] = { REG_JNI(register_android_media_ToneGenerator), REG_JNI(register_android_opengl_classes), - REG_JNI(register_android_bluetooth_Database), REG_JNI(register_android_bluetooth_HeadsetBase), REG_JNI(register_android_bluetooth_BluetoothAudioGateway), REG_JNI(register_android_bluetooth_RfcommSocket), diff --git a/core/jni/android_bluetooth_Database.cpp b/core/jni/android_bluetooth_Database.cpp deleted file mode 100644 index 136c9a3..0000000 --- a/core/jni/android_bluetooth_Database.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define DBUS_CLASS_NAME BLUEZ_DBUS_BASE_IFC ".Database" -#define LOG_TAG "bluetooth_Database.cpp" - -#include "android_bluetooth_common.h" -#include "android_runtime/AndroidRuntime.h" -#include "JNIHelp.h" -#include "jni.h" -#include "utils/Log.h" - -#ifdef HAVE_BLUETOOTH -#include <dbus/dbus.h> -#endif - -namespace android { - -#ifdef HAVE_BLUETOOTH -static DBusConnection* conn = NULL; // Singleton thread-safe connection -#endif - -static void classInitNative(JNIEnv* env, jclass clazz) { - LOGV(__FUNCTION__); -#ifdef HAVE_BLUETOOTH - conn = NULL; -#endif -} - -static void initializeNativeDataNative(JNIEnv* env, jobject object) { - LOGV(__FUNCTION__); - -#ifdef HAVE_BLUETOOTH - if (conn == NULL) { - DBusError err; - dbus_error_init(&err); - dbus_threads_init_default(); - conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err); - if (dbus_error_is_set(&err)) { - LOGE("Could not get onto the system bus!"); - dbus_error_free(&err); - } - } -#endif -} - -static void cleanupNativeDataNative(JNIEnv* env, jobject object) { - LOGV(__FUNCTION__); -} - -static jint addServiceRecordNative(JNIEnv *env, jobject object, - jbyteArray record) { - LOGV(__FUNCTION__); -#ifdef HAVE_BLUETOOTH - if (conn != NULL) { - jbyte* c_record = env->GetByteArrayElements(record, NULL); - DBusMessage *reply = dbus_func_args(env, - conn, - BLUEZ_DBUS_BASE_PATH, - DBUS_CLASS_NAME, - "AddServiceRecord", - DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, - &c_record, - env->GetArrayLength(record), - DBUS_TYPE_INVALID); - env->ReleaseByteArrayElements(record, c_record, JNI_ABORT); - return reply ? dbus_returns_uint32(env, reply) : -1; - } -#endif - return -1; -} - -static jint addServiceRecordFromXmlNative(JNIEnv *env, jobject object, - jstring record) { - LOGV(__FUNCTION__); -#ifdef HAVE_BLUETOOTH - if (conn != NULL) { - const char *c_record = env->GetStringUTFChars(record, NULL); - DBusMessage *reply = dbus_func_args(env, - conn, - BLUEZ_DBUS_BASE_PATH, - DBUS_CLASS_NAME, - "AddServiceRecordFromXML", - DBUS_TYPE_STRING, &c_record, - DBUS_TYPE_INVALID); - env->ReleaseStringUTFChars(record, c_record); - return reply ? dbus_returns_uint32(env, reply) : -1; - } -#endif - return -1; -} - -static void updateServiceRecordNative(JNIEnv *env, jobject object, - jint handle, - jbyteArray record) { - LOGV(__FUNCTION__); -#ifdef HAVE_BLUETOOTH - if (conn != NULL) { - jbyte* c_record = env->GetByteArrayElements(record, NULL); - DBusMessage *reply = dbus_func_args(env, - conn, - BLUEZ_DBUS_BASE_PATH, - DBUS_CLASS_NAME, - "UpdateServiceRecord", - DBUS_TYPE_UINT32, &handle, - DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, - &c_record, - env->GetArrayLength(record), - DBUS_TYPE_INVALID); - env->ReleaseByteArrayElements(record, c_record, JNI_ABORT); - } -#endif -} - -static void updateServiceRecordFromXmlNative(JNIEnv *env, jobject object, - jint handle, - jstring record) { - LOGV(__FUNCTION__); -#ifdef HAVE_BLUETOOTH - if (conn != NULL) { - const char *c_record = env->GetStringUTFChars(record, NULL); - DBusMessage *reply = dbus_func_args(env, - conn, - BLUEZ_DBUS_BASE_PATH, - DBUS_CLASS_NAME, - "UpdateServiceRecordFromXML", - DBUS_TYPE_UINT32, &handle, - DBUS_TYPE_STRING, &c_record, - DBUS_TYPE_INVALID); - env->ReleaseStringUTFChars(record, c_record); - } -#endif -} - -/* private static native void removeServiceRecordNative(int handle); */ -static void removeServiceRecordNative(JNIEnv *env, jobject object, - jint handle) { - LOGV(__FUNCTION__); -#ifdef HAVE_BLUETOOTH - if (conn != NULL) { - DBusMessage *reply = dbus_func_args(env, - conn, - BLUEZ_DBUS_BASE_PATH, - DBUS_CLASS_NAME, - "RemoveServiceRecord", - DBUS_TYPE_UINT32, &handle, - DBUS_TYPE_INVALID); - } -#endif -} - - -static JNINativeMethod sMethods[] = { - /* name, signature, funcPtr */ - {"classInitNative", "()V", (void*)classInitNative}, - {"initializeNativeDataNative", "()V", (void *)initializeNativeDataNative}, - {"cleanupNativeDataNative", "()V", (void *)cleanupNativeDataNative}, - {"addServiceRecordNative", "([B)I", (void*)addServiceRecordNative}, - {"addServiceRecordFromXmlNative", "(Ljava/lang/String;)I", (void*)addServiceRecordFromXmlNative}, - {"updateServiceRecordNative", "(I[B)V", (void*)updateServiceRecordNative}, - {"updateServiceRecordFromXmlNative", "(ILjava/lang/String;)V", (void*)updateServiceRecordFromXmlNative}, - {"removeServiceRecordNative", "(I)V", (void*)removeServiceRecordNative}, -}; - -int register_android_bluetooth_Database(JNIEnv *env) { - return AndroidRuntime::registerNativeMethods(env, - "android/bluetooth/Database", sMethods, NELEM(sMethods)); -} - -} /* namespace android */ |