From 1ff6591ccffac61e070243b30c9862e5e756fb22 Mon Sep 17 00:00:00 2001 From: Simon Wilson Date: Tue, 21 Jun 2011 14:09:10 -0700 Subject: audio: voice call support - Also ensured that PRODUCT_PACKAGES is set so that the HAL is copied into the filesystem. Change-Id: I89790e5aec1d6beb7d4650316ec070503a35c436 --- audio/ril_interface.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 audio/ril_interface.c (limited to 'audio/ril_interface.c') diff --git a/audio/ril_interface.c b/audio/ril_interface.c new file mode 100644 index 0000000..b20d42b --- /dev/null +++ b/audio/ril_interface.c @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2011 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. + */ + +#include + +#include + +#include "ril_interface.h" + +int ril_open(void **ril_handle, void **ril_client) +{ + void *handle; + void *client; + + handle = dlopen(RIL_CLIENT_LIBPATH, RTLD_NOW); + + if (!handle) { + LOGE("Cannot open '%s'", RIL_CLIENT_LIBPATH); + return -1; + } + + ril_open_client = dlsym(handle, "OpenClient_RILD"); + ril_close_client = dlsym(handle, "CloseClient_RILD"); + ril_connect = dlsym(handle, "Connect_RILD"); + ril_is_connected = dlsym(handle, "isConnected_RILD"); + ril_disconnect = dlsym(handle, "Disconnect_RILD"); + ril_set_call_volume = dlsym(handle, "SetCallVolume"); + ril_set_call_audio_path = dlsym(handle, "SetCallAudioPath"); + ril_set_call_clock_sync = dlsym(handle, "SetCallClockSync"); + + if (!ril_open_client || !ril_close_client || !ril_connect || + !ril_is_connected || !ril_disconnect || !ril_set_call_volume || + !ril_set_call_audio_path || !ril_set_call_clock_sync) { + LOGE("Cannot get symbols from '%s'", RIL_CLIENT_LIBPATH); + dlclose(handle); + return -1; + } + + client = ril_open_client(); + if (!client) { + LOGE("ril_open_client() failed"); + dlclose(handle); + return -1; + } + + if (ril_connect(client) != RIL_CLIENT_ERR_SUCCESS || + !ril_is_connected(client)) { + LOGE("ril_connect() failed"); + ril_close_client(client); + dlclose(handle); + return -1; + } + + *ril_handle = handle; + *ril_client = client; + return 0; +} + +int ril_close(void *ril_handle, void *ril_client) +{ + if (!ril_handle) + return -1; + + if ((ril_disconnect(ril_client) != RIL_CLIENT_ERR_SUCCESS) || + (ril_close_client(ril_client) != RIL_CLIENT_ERR_SUCCESS)) { + LOGE("ril_disconnect() or ril_close_client() failed"); + return -1; + } + + dlclose(ril_handle); + return 0; +} + -- cgit v1.1