From ea600ccfb7568f60377c4abc85f56c80af7fdbfc Mon Sep 17 00:00:00 2001 From: Nick Pelly <> Date: Tue, 31 Mar 2009 14:56:26 -0700 Subject: AI 143788: am: CL 143740 Don't clear supported profiles in settings app if getRemoteClass returns error. Also clean up the error codes returned by the framework, so that the settings app can properly detect an error. Original author: npelly Merged from: //branches/cupcake/... Automated import of CL 143788 --- core/java/android/bluetooth/BluetoothDevice.java | 3 ++- core/java/android/server/BluetoothDeviceService.java | 6 +++--- core/jni/android_server_BluetoothDeviceService.cpp | 10 +++++----- 3 files changed, 10 insertions(+), 9 deletions(-) (limited to 'core') diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java index abf08cb..951b4b0 100644 --- a/core/java/android/bluetooth/BluetoothDevice.java +++ b/core/java/android/bluetooth/BluetoothDevice.java @@ -485,7 +485,8 @@ public class BluetoothDevice { * Get the major, minor and servics classes of a remote device. * These classes are encoded as a 32-bit integer. See BluetoothClass. * @param address remote device - * @return 32-bit class suitable for use with BluetoothClass. + * @return 32-bit class suitable for use with BluetoothClass, or + * BluetoothClass.ERROR on error */ public int getRemoteClass(String address) { try { diff --git a/core/java/android/server/BluetoothDeviceService.java b/core/java/android/server/BluetoothDeviceService.java index f1a7d25..8e5cee9 100644 --- a/core/java/android/server/BluetoothDeviceService.java +++ b/core/java/android/server/BluetoothDeviceService.java @@ -24,6 +24,7 @@ package android.server; +import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothError; import android.bluetooth.BluetoothHeadset; @@ -970,8 +971,8 @@ public class BluetoothDeviceService extends IBluetoothDevice.Stub { */ public synchronized int getRemoteClass(String address) { if (!BluetoothDevice.checkBluetoothAddress(address)) { - mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); - return -1; + mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); + return BluetoothClass.ERROR; } return getRemoteClassNative(address); } @@ -1254,4 +1255,3 @@ public class BluetoothDeviceService extends IBluetoothDevice.Stub { Log.d(TAG, msg); } } - diff --git a/core/jni/android_server_BluetoothDeviceService.cpp b/core/jni/android_server_BluetoothDeviceService.cpp index 796da15..a0e0b84 100644 --- a/core/jni/android_server_BluetoothDeviceService.cpp +++ b/core/jni/android_server_BluetoothDeviceService.cpp @@ -44,6 +44,8 @@ namespace android { +#define BLUETOOTH_CLASS_ERROR 0xFF000000 + #ifdef HAVE_BLUETOOTH // We initialize these variables when we load class // android.server.BluetoothDeviceService @@ -724,11 +726,11 @@ static jstring lastUsedNative(JNIEnv *env, jobject obj, jstring address) { } static jint getRemoteClassNative(JNIEnv *env, jobject object, jstring address) { + jint result = BLUETOOTH_CLASS_ERROR; #ifdef HAVE_BLUETOOTH LOGV(__FUNCTION__); native_data_t *nat = get_native_data(env, object); if (nat) { - jint ret = 0; const char *c_address = env->GetStringUTFChars(address, NULL); LOGV("... address = %s", c_address); @@ -744,17 +746,15 @@ static jint getRemoteClassNative(JNIEnv *env, jobject object, jstring address) { DBusError err; dbus_error_init(&err); if (!dbus_message_get_args(reply, &err, - DBUS_TYPE_UINT32, &ret, + DBUS_TYPE_UINT32, &result, DBUS_TYPE_INVALID)) { LOG_AND_FREE_DBUS_ERROR_WITH_MSG(&err, reply); } dbus_message_unref(reply); } - - return ret; } #endif - return 0; + return result; } static jbyteArray getRemoteFeaturesNative(JNIEnv *env, jobject object, -- cgit v1.1