From 269e81a563cfe080d7f241d0d46411d3c946c111 Mon Sep 17 00:00:00 2001 From: Matthew Xie Date: Tue, 26 Jul 2011 18:36:49 -0700 Subject: Provide an API to set the friendly name of a remote device. BluetoothDevice setName overwrite the locally cached remote name. The changed name is saved in the local storage so that the change is preserved over power cycle. bug 5081605 Change-Id: I486966033828d153bfb1076a99e274c8a7f41636 --- core/jni/android_server_BluetoothService.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'core/jni/android_server_BluetoothService.cpp') diff --git a/core/jni/android_server_BluetoothService.cpp b/core/jni/android_server_BluetoothService.cpp index 86e7cc0..41056fd 100644 --- a/core/jni/android_server_BluetoothService.cpp +++ b/core/jni/android_server_BluetoothService.cpp @@ -895,6 +895,18 @@ static jboolean setDevicePropertyBooleanNative(JNIEnv *env, jobject object, #endif } +static jboolean setDevicePropertyStringNative(JNIEnv *env, jobject object, + jstring path, jstring key, jstring value) { +#ifdef HAVE_BLUETOOTH + const char *c_value = env->GetStringUTFChars(value, NULL); + jboolean ret = setDevicePropertyNative(env, object, path, key, + (void *)&c_value, DBUS_TYPE_STRING); + env->ReleaseStringUTFChars(value, (char *)c_value); + return ret; +#else + return JNI_FALSE; +#endif +} static jboolean createDeviceNative(JNIEnv *env, jobject object, jstring address) { @@ -1718,6 +1730,8 @@ static JNINativeMethod sMethods[] = { (void *)cancelPairingUserInputNative}, {"setDevicePropertyBooleanNative", "(Ljava/lang/String;Ljava/lang/String;I)Z", (void *)setDevicePropertyBooleanNative}, + {"setDevicePropertyStringNative", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z", + (void *)setDevicePropertyStringNative}, {"createDeviceNative", "(Ljava/lang/String;)Z", (void *)createDeviceNative}, {"discoverServicesNative", "(Ljava/lang/String;Ljava/lang/String;)Z", (void *)discoverServicesNative}, {"addRfcommServiceRecordNative", "(Ljava/lang/String;JJS)I", (void *)addRfcommServiceRecordNative}, -- cgit v1.1