mirror of git://git.sysmocom.de/ofono
gril: Library to communicate with rild
gril is a library used to communicate with rild, the Android telephony daemon. Communication happens using a named socket over which binder parcels are transmitted. Co-authored-by: Tony Espy <espy@canonical.com> Co-authored-by: Ricardo Salveti de Araujo <ricardo.salveti@canonical.com> Co-authored-by: Alfonso Sanchez-Beato <alfonso.sanchez-beato@canonical.com> Co-authored-by: Mikko Hurskainen <mikko.hurskainen@nomovok.com> Co-authored-by: You-Sheng Yang <vicamo.yang@canonical.com> Co-authored-by: Ratchanan Srirattanamet <peathot@hotmail.com>
This commit is contained in:
parent
ab9fedc6ef
commit
9c2af753c0
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
*
|
||||
* RIL library with GLib integration
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2012 Canonical Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __GFUNC_H
|
||||
#define __GFUNC_H
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void (*GRilDisconnectFunc)(gpointer user_data);
|
||||
typedef void (*GRilReceiveFunc)(const unsigned char *data, gsize size,
|
||||
gpointer user_data);
|
||||
typedef void (*GRilDebugFunc)(const char *str, gpointer user_data);
|
||||
typedef void (*GRilSuspendFunc)(gpointer user_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __GFUNC_H */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,172 @@
|
|||
/*
|
||||
*
|
||||
* RIL library with GLib integration
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2012 Canonical Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __GRIL_H
|
||||
#define __GRIL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "grilio.h"
|
||||
#include "grilutil.h"
|
||||
#include "parcel.h"
|
||||
#include "ril_constants.h"
|
||||
#include "drivers/rilmodem/vendor.h"
|
||||
|
||||
#define RIL_MAX_NUM_ACTIVE_DATA_CALLS 2
|
||||
|
||||
struct _GRil;
|
||||
|
||||
typedef struct _GRil GRil;
|
||||
|
||||
/*
|
||||
* This struct represents an entire RIL message read
|
||||
* from the command socket. It can hold responses or
|
||||
* unsolicited requests from RILD.
|
||||
*/
|
||||
struct ril_msg {
|
||||
gchar *buf;
|
||||
gsize buf_len;
|
||||
gboolean unsolicited;
|
||||
int req;
|
||||
int serial_no;
|
||||
int error;
|
||||
};
|
||||
|
||||
typedef void (*GRilResponseFunc)(struct ril_msg *message, gpointer user_data);
|
||||
|
||||
typedef void (*GRilNotifyFunc)(struct ril_msg *message, gpointer user_data);
|
||||
|
||||
typedef const char *(*GRilMsgIdToStrFunc)(int msg_id);
|
||||
|
||||
/**
|
||||
* TRACE:
|
||||
* @fmt: format string
|
||||
* @arg...: list of arguments
|
||||
*
|
||||
* Simple macro around ofono_debug() used for tracing RIL messages
|
||||
* name it is called in.
|
||||
*/
|
||||
#define G_RIL_TRACE(gril, fmt, arg...) do { \
|
||||
if (gril && g_ril_get_trace(gril)) \
|
||||
ofono_debug(fmt, ## arg); \
|
||||
} while (0)
|
||||
|
||||
extern char print_buf[];
|
||||
|
||||
#define g_ril_print_request(gril, token, req) \
|
||||
G_RIL_TRACE(gril, "[%d,%04d]> %s %s", \
|
||||
g_ril_get_slot(gril), token, \
|
||||
g_ril_request_id_to_string(gril, req), print_buf)
|
||||
#define g_ril_print_request_no_args(gril, token, req) \
|
||||
G_RIL_TRACE(gril, "[%d,%04d]> %s", \
|
||||
g_ril_get_slot(gril), token, \
|
||||
g_ril_request_id_to_string(gril, req))
|
||||
#define g_ril_print_response(gril, message) \
|
||||
G_RIL_TRACE(gril, "[%d,%04d]< %s %s", \
|
||||
g_ril_get_slot(gril), \
|
||||
message->serial_no, \
|
||||
g_ril_request_id_to_string(gril, message->req), \
|
||||
print_buf)
|
||||
#define g_ril_print_response_no_args(gril, message) \
|
||||
G_RIL_TRACE(gril, "[%d,%04d]< %s", \
|
||||
g_ril_get_slot(gril), message->serial_no, \
|
||||
g_ril_request_id_to_string(gril, message->req))
|
||||
|
||||
#define g_ril_append_print_buf(gril, x...) do { \
|
||||
if (gril && g_ril_get_trace(gril)) \
|
||||
sprintf(print_buf, x); \
|
||||
} while (0)
|
||||
|
||||
#define g_ril_print_unsol(gril, message) \
|
||||
G_RIL_TRACE(gril, "[%d,UNSOL]< %s %s", \
|
||||
g_ril_get_slot(gril), \
|
||||
g_ril_unsol_request_to_string(gril, \
|
||||
message->req), \
|
||||
print_buf)
|
||||
#define g_ril_print_unsol_no_args(gril, message) \
|
||||
G_RIL_TRACE(gril, "[%d,UNSOL]< %s", g_ril_get_slot(gril), \
|
||||
g_ril_unsol_request_to_string(gril, message->req))
|
||||
|
||||
void g_ril_init_parcel(const struct ril_msg *message, struct parcel *rilp);
|
||||
|
||||
GRil *g_ril_new(const char *sock_path, enum ofono_ril_vendor vendor);
|
||||
|
||||
GIOChannel *g_ril_get_channel(GRil *ril);
|
||||
GRilIO *g_ril_get_io(GRil *ril);
|
||||
|
||||
GRil *g_ril_ref(GRil *ril);
|
||||
void g_ril_unref(GRil *ril);
|
||||
|
||||
GRil *g_ril_clone(GRil *ril);
|
||||
|
||||
void g_ril_set_disconnect_function(GRil *ril, GRilDisconnectFunc disconnect,
|
||||
gpointer user_data);
|
||||
|
||||
gboolean g_ril_get_trace(GRil *ril);
|
||||
gboolean g_ril_set_trace(GRil *ril, gboolean trace);
|
||||
|
||||
int g_ril_get_slot(GRil *ril);
|
||||
gboolean g_ril_set_slot(GRil *ril, int slot);
|
||||
|
||||
/*!
|
||||
* If the function is not NULL, then on every read/write from the GIOChannel
|
||||
* provided to GRil the logging function will be called with the
|
||||
* input/output string and user data
|
||||
*/
|
||||
gboolean g_ril_set_debugf(GRil *ril, GRilDebugFunc func, gpointer user_data);
|
||||
|
||||
gboolean g_ril_set_vendor_print_msg_id_funcs(GRil *ril,
|
||||
GRilMsgIdToStrFunc req_to_string,
|
||||
GRilMsgIdToStrFunc unsol_to_string);
|
||||
|
||||
|
||||
/*!
|
||||
* Queue an RIL request for execution. The request contents are given
|
||||
* in data. Once the command executes, the callback function given by
|
||||
* func is called with user provided data in user_data.
|
||||
*
|
||||
* Returns an id of the queued command which can be canceled using
|
||||
* g_ril_cancel. If an error occurred, an id of 0 is returned.
|
||||
*
|
||||
*/
|
||||
gint g_ril_send(GRil *ril, const gint reqid, struct parcel *rilp,
|
||||
GRilResponseFunc func, gpointer user_data,
|
||||
GDestroyNotify notify);
|
||||
|
||||
guint g_ril_register(GRil *ril, const int req,
|
||||
GRilNotifyFunc func, gpointer user_data);
|
||||
|
||||
gboolean g_ril_unregister(GRil *ril, guint id);
|
||||
gboolean g_ril_unregister_all(GRil *ril);
|
||||
|
||||
enum ofono_ril_vendor g_ril_vendor(GRil *ril);
|
||||
|
||||
const char *g_ril_request_id_to_string(GRil *ril, int req);
|
||||
const char *g_ril_unsol_request_to_string(GRil *ril, int req);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __GRIL_H */
|
|
@ -0,0 +1,399 @@
|
|||
/*
|
||||
*
|
||||
* RIL chat library with GLib integration
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2012 Canonical Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "ringbuffer.h"
|
||||
#include "grilio.h"
|
||||
#include "grilutil.h"
|
||||
|
||||
struct _GRilIO {
|
||||
gint ref_count; /* Ref count */
|
||||
guint read_watch; /* GSource read id, 0 if no */
|
||||
guint write_watch; /* GSource write id, 0 if no */
|
||||
GIOChannel *channel; /* comms channel */
|
||||
GRilDisconnectFunc user_disconnect; /* user disconnect func */
|
||||
gpointer user_disconnect_data; /* user disconnect data */
|
||||
struct ring_buffer *buf; /* Current read buffer */
|
||||
guint max_read_attempts; /* max reads / select */
|
||||
GRilIOReadFunc read_handler; /* Read callback */
|
||||
gpointer read_data; /* Read callback userdata */
|
||||
gboolean use_write_watch; /* Use write select */
|
||||
GRilIOWriteFunc write_handler; /* Write callback */
|
||||
gpointer write_data; /* Write callback userdata */
|
||||
GRilDebugFunc debugf; /* debugging output function */
|
||||
gpointer debug_data; /* Data to pass to debug func */
|
||||
GRilDisconnectFunc write_done_func; /* tx empty notifier */
|
||||
gpointer write_done_data; /* tx empty data */
|
||||
gboolean destroyed; /* Re-entrancy guard */
|
||||
};
|
||||
|
||||
static void read_watcher_destroy_notify(gpointer user_data)
|
||||
{
|
||||
GRilIO *io = user_data;
|
||||
|
||||
ring_buffer_free(io->buf);
|
||||
io->buf = NULL;
|
||||
|
||||
io->debugf = NULL;
|
||||
io->debug_data = NULL;
|
||||
|
||||
io->read_watch = 0;
|
||||
io->read_handler = NULL;
|
||||
io->read_data = NULL;
|
||||
|
||||
g_io_channel_unref(io->channel);
|
||||
io->channel = NULL;
|
||||
|
||||
if (io->destroyed)
|
||||
g_free(io);
|
||||
else if (io->user_disconnect)
|
||||
io->user_disconnect(io->user_disconnect_data);
|
||||
}
|
||||
|
||||
static gboolean received_data(GIOChannel *channel, GIOCondition cond,
|
||||
gpointer data)
|
||||
{
|
||||
unsigned char *buf;
|
||||
GRilIO *io = data;
|
||||
GIOStatus status;
|
||||
gsize rbytes;
|
||||
gsize toread;
|
||||
gsize total_read = 0;
|
||||
guint read_count = 0;
|
||||
|
||||
if (cond & G_IO_NVAL)
|
||||
return FALSE;
|
||||
|
||||
/* Regardless of condition, try to read all the data available */
|
||||
do {
|
||||
toread = ring_buffer_avail_no_wrap(io->buf);
|
||||
|
||||
if (toread == 0)
|
||||
break;
|
||||
|
||||
rbytes = 0;
|
||||
buf = ring_buffer_write_ptr(io->buf, 0);
|
||||
|
||||
status = g_io_channel_read_chars(channel, (char *) buf,
|
||||
toread, &rbytes, NULL);
|
||||
|
||||
g_ril_util_debug_hexdump(TRUE, (guchar *) buf, rbytes,
|
||||
io->debugf, io->debug_data);
|
||||
|
||||
read_count++;
|
||||
|
||||
total_read += rbytes;
|
||||
|
||||
if (rbytes > 0)
|
||||
ring_buffer_write_advance(io->buf, rbytes);
|
||||
|
||||
} while (status == G_IO_STATUS_NORMAL && rbytes > 0 &&
|
||||
read_count < io->max_read_attempts);
|
||||
|
||||
if (total_read > 0 && io->read_handler)
|
||||
io->read_handler(io->buf, io->read_data);
|
||||
|
||||
if (cond & (G_IO_HUP | G_IO_ERR))
|
||||
return FALSE;
|
||||
|
||||
if (read_count > 0 && rbytes == 0 && status != G_IO_STATUS_AGAIN)
|
||||
return FALSE;
|
||||
|
||||
/* We're overflowing the buffer, shutdown the socket */
|
||||
if (ring_buffer_avail(io->buf) == 0)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gsize g_ril_io_write(GRilIO *io, const gchar *data, gsize count)
|
||||
{
|
||||
GIOStatus status;
|
||||
gsize bytes_written;
|
||||
|
||||
status = g_io_channel_write_chars(io->channel, data,
|
||||
count, &bytes_written, NULL);
|
||||
|
||||
if (status != G_IO_STATUS_NORMAL) {
|
||||
g_source_remove(io->read_watch);
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_ril_util_debug_hexdump(FALSE, (guchar *) data, bytes_written,
|
||||
io->debugf, io->debug_data);
|
||||
|
||||
return bytes_written;
|
||||
}
|
||||
|
||||
static void write_watcher_destroy_notify(gpointer user_data)
|
||||
{
|
||||
GRilIO *io = user_data;
|
||||
|
||||
io->write_watch = 0;
|
||||
io->write_handler = NULL;
|
||||
io->write_data = NULL;
|
||||
|
||||
if (io->write_done_func) {
|
||||
io->write_done_func(io->write_done_data);
|
||||
io->write_done_func = NULL;
|
||||
io->write_done_data = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean can_write_data(GIOChannel *channel, GIOCondition cond,
|
||||
gpointer data)
|
||||
{
|
||||
GRilIO *io = data;
|
||||
|
||||
if (cond & (G_IO_NVAL | G_IO_HUP | G_IO_ERR))
|
||||
return FALSE;
|
||||
|
||||
if (io->write_handler == NULL)
|
||||
return FALSE;
|
||||
|
||||
return io->write_handler(io->write_data);
|
||||
}
|
||||
|
||||
static GRilIO *create_io(GIOChannel *channel, GIOFlags flags)
|
||||
{
|
||||
GRilIO *io;
|
||||
|
||||
if (channel == NULL)
|
||||
return NULL;
|
||||
|
||||
io = g_try_new0(GRilIO, 1);
|
||||
if (io == NULL)
|
||||
return io;
|
||||
|
||||
io->ref_count = 1;
|
||||
io->debugf = NULL;
|
||||
|
||||
if (flags & G_IO_FLAG_NONBLOCK) {
|
||||
io->max_read_attempts = 3;
|
||||
io->use_write_watch = TRUE;
|
||||
} else {
|
||||
io->max_read_attempts = 1;
|
||||
io->use_write_watch = FALSE;
|
||||
}
|
||||
|
||||
io->buf = ring_buffer_new(8192);
|
||||
|
||||
if (!io->buf)
|
||||
goto error;
|
||||
|
||||
if (!g_ril_util_setup_io(channel, flags))
|
||||
goto error;
|
||||
|
||||
io->channel = channel;
|
||||
io->read_watch = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT,
|
||||
G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
|
||||
received_data, io,
|
||||
read_watcher_destroy_notify);
|
||||
|
||||
return io;
|
||||
|
||||
error:
|
||||
if (io->buf)
|
||||
ring_buffer_free(io->buf);
|
||||
|
||||
g_free(io);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GRilIO *g_ril_io_new(GIOChannel *channel)
|
||||
{
|
||||
return create_io(channel, G_IO_FLAG_NONBLOCK);
|
||||
}
|
||||
|
||||
GRilIO *g_ril_io_new_blocking(GIOChannel *channel)
|
||||
{
|
||||
return create_io(channel, 0);
|
||||
}
|
||||
|
||||
GIOChannel *g_ril_io_get_channel(GRilIO *io)
|
||||
{
|
||||
if (io == NULL)
|
||||
return NULL;
|
||||
|
||||
return io->channel;
|
||||
}
|
||||
|
||||
gboolean g_ril_io_set_read_handler(GRilIO *io, GRilIOReadFunc read_handler,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (io == NULL)
|
||||
return FALSE;
|
||||
|
||||
io->read_handler = read_handler;
|
||||
io->read_data = user_data;
|
||||
|
||||
if (read_handler && ring_buffer_len(io->buf) > 0)
|
||||
read_handler(io->buf, user_data);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean call_blocking_read(gpointer user_data)
|
||||
{
|
||||
GRilIO *io = user_data;
|
||||
|
||||
while (can_write_data(io->channel, G_IO_OUT, io) == TRUE)
|
||||
;
|
||||
|
||||
write_watcher_destroy_notify(io);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean g_ril_io_set_write_handler(GRilIO *io, GRilIOWriteFunc write_handler,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (io == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (io->write_watch > 0) {
|
||||
if (write_handler == NULL) {
|
||||
g_source_remove(io->write_watch);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (write_handler == NULL)
|
||||
return FALSE;
|
||||
|
||||
io->write_handler = write_handler;
|
||||
io->write_data = user_data;
|
||||
|
||||
if (io->use_write_watch == TRUE)
|
||||
io->write_watch = g_io_add_watch_full(io->channel,
|
||||
G_PRIORITY_HIGH,
|
||||
G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
|
||||
can_write_data, io,
|
||||
write_watcher_destroy_notify);
|
||||
else
|
||||
io->write_watch = g_idle_add(call_blocking_read, io);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GRilIO *g_ril_io_ref(GRilIO *io)
|
||||
{
|
||||
if (io == NULL)
|
||||
return NULL;
|
||||
|
||||
g_atomic_int_inc(&io->ref_count);
|
||||
|
||||
return io;
|
||||
}
|
||||
|
||||
static gboolean io_shutdown(GRilIO *io)
|
||||
{
|
||||
/* Don't trigger user disconnect on shutdown */
|
||||
io->user_disconnect = NULL;
|
||||
io->user_disconnect_data = NULL;
|
||||
|
||||
if (io->read_watch > 0)
|
||||
g_source_remove(io->read_watch);
|
||||
|
||||
if (io->write_watch > 0)
|
||||
g_source_remove(io->write_watch);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void g_ril_io_unref(GRilIO *io)
|
||||
{
|
||||
gboolean is_zero;
|
||||
|
||||
if (io == NULL)
|
||||
return;
|
||||
|
||||
is_zero = g_atomic_int_dec_and_test(&io->ref_count);
|
||||
|
||||
if (is_zero == FALSE)
|
||||
return;
|
||||
|
||||
io_shutdown(io);
|
||||
|
||||
/* glib delays the destruction of the watcher until it exits, this
|
||||
* means we can't free the data just yet, even though we've been
|
||||
* destroyed already. We have to wait until the read_watcher
|
||||
* destroy function gets called
|
||||
*/
|
||||
if (io->read_watch > 0)
|
||||
io->destroyed = TRUE;
|
||||
else
|
||||
g_free(io);
|
||||
}
|
||||
|
||||
gboolean g_ril_io_set_disconnect_function(GRilIO *io,
|
||||
GRilDisconnectFunc disconnect, gpointer user_data)
|
||||
{
|
||||
if (io == NULL)
|
||||
return FALSE;
|
||||
|
||||
io->user_disconnect = disconnect;
|
||||
io->user_disconnect_data = user_data;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean g_ril_io_set_debug(GRilIO *io, GRilDebugFunc func, gpointer user_data)
|
||||
{
|
||||
if (io == NULL)
|
||||
return FALSE;
|
||||
|
||||
io->debugf = func;
|
||||
io->debug_data = user_data;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void g_ril_io_set_write_done(GRilIO *io, GRilDisconnectFunc func,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (io == NULL)
|
||||
return;
|
||||
|
||||
io->write_done_func = func;
|
||||
io->write_done_data = user_data;
|
||||
}
|
||||
|
||||
void g_ril_io_drain_ring_buffer(GRilIO *io, guint len)
|
||||
{
|
||||
ring_buffer_drain(io->buf, len);
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
*
|
||||
* RIL chat library with GLib integration
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2012 Canonical Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __GRILIO_H
|
||||
#define __GRILIO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "gfunc.h"
|
||||
|
||||
struct _GRilIO;
|
||||
|
||||
typedef struct _GRilIO GRilIO;
|
||||
|
||||
struct ring_buffer;
|
||||
|
||||
typedef void (*GRilIOReadFunc)(struct ring_buffer *buffer, gpointer user_data);
|
||||
typedef gboolean (*GRilIOWriteFunc)(gpointer user_data);
|
||||
|
||||
GRilIO *g_ril_io_new(GIOChannel *channel);
|
||||
GRilIO *g_ril_io_new_blocking(GIOChannel *channel);
|
||||
|
||||
GIOChannel *g_ril_io_get_channel(GRilIO *io);
|
||||
|
||||
GRilIO *g_ril_io_ref(GRilIO *io);
|
||||
void g_ril_io_unref(GRilIO *io);
|
||||
|
||||
gboolean g_ril_io_set_read_handler(GRilIO *io, GRilIOReadFunc read_handler,
|
||||
gpointer user_data);
|
||||
gboolean g_ril_io_set_write_handler(GRilIO *io, GRilIOWriteFunc write_handler,
|
||||
gpointer user_data);
|
||||
void g_ril_io_set_write_done(GRilIO *io, GRilDisconnectFunc func,
|
||||
gpointer user_data);
|
||||
|
||||
void g_ril_io_drain_ring_buffer(GRilIO *io, guint len);
|
||||
|
||||
gsize g_ril_io_write(GRilIO *io, const gchar *data, gsize count);
|
||||
|
||||
gboolean g_ril_io_set_disconnect_function(GRilIO *io,
|
||||
GRilDisconnectFunc disconnect, gpointer user_data);
|
||||
|
||||
gboolean g_ril_io_set_debug(GRilIO *io, GRilDebugFunc func, gpointer user_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __GRILIO_H */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,185 @@
|
|||
/*
|
||||
*
|
||||
* RIL library with GLib integration
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2012-2014 Canonical Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __GRILREPLY_H
|
||||
#define __GRILREPLY_H
|
||||
|
||||
#include <ofono/types.h>
|
||||
#include <ofono/sim.h>
|
||||
|
||||
#include "gril.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct reply_operator {
|
||||
char *lalpha;
|
||||
char *salpha;
|
||||
char *numeric;
|
||||
char *status;
|
||||
int tech;
|
||||
};
|
||||
|
||||
struct reply_avail_ops {
|
||||
guint num_ops;
|
||||
GSList *list;
|
||||
};
|
||||
|
||||
struct reply_reg_state {
|
||||
int status;
|
||||
int lac;
|
||||
int ci;
|
||||
int tech;
|
||||
};
|
||||
|
||||
struct reply_data_reg_state {
|
||||
struct reply_reg_state reg_state;
|
||||
unsigned int max_cids;
|
||||
};
|
||||
|
||||
struct reply_sim_io {
|
||||
int sw1;
|
||||
int sw2;
|
||||
int hex_len;
|
||||
unsigned char *hex_response;
|
||||
};
|
||||
|
||||
#define MAX_UICC_APPS 16
|
||||
|
||||
struct reply_sim_app {
|
||||
guint app_type;
|
||||
guint app_state;
|
||||
guint perso_substate;
|
||||
char *aid_str;
|
||||
char *app_str;
|
||||
guint pin_replaced;
|
||||
guint pin1_state;
|
||||
guint pin2_state;
|
||||
};
|
||||
|
||||
struct reply_sim_status {
|
||||
guint card_state;
|
||||
guint pin_state;
|
||||
guint gsm_umts_index;
|
||||
guint cdma_index;
|
||||
guint ims_index;
|
||||
guint num_apps;
|
||||
struct reply_sim_app *apps[MAX_UICC_APPS];
|
||||
};
|
||||
|
||||
struct reply_clir {
|
||||
int status;
|
||||
int provisioned;
|
||||
};
|
||||
|
||||
struct reply_oem_hook {
|
||||
int length;
|
||||
void *data;
|
||||
};
|
||||
|
||||
void g_ril_reply_free_avail_ops(struct reply_avail_ops *reply);
|
||||
|
||||
struct reply_avail_ops *g_ril_reply_parse_avail_ops(GRil *gril,
|
||||
const struct ril_msg *message);
|
||||
void g_ril_reply_free_operator(struct reply_operator *reply);
|
||||
|
||||
struct reply_operator *g_ril_reply_parse_operator(GRil *gril,
|
||||
const struct ril_msg *message);
|
||||
|
||||
void g_ril_reply_free_sim_io(struct reply_sim_io *reply);
|
||||
|
||||
struct reply_sim_io *g_ril_reply_parse_sim_io(GRil *gril,
|
||||
const struct ril_msg *message);
|
||||
|
||||
gchar *g_ril_reply_parse_imsi(GRil *gril, const struct ril_msg *message);
|
||||
|
||||
struct reply_reg_state *g_ril_reply_parse_voice_reg_state(GRil *gril,
|
||||
const struct ril_msg *message);
|
||||
struct reply_data_reg_state *g_ril_reply_parse_data_reg_state(GRil *gril,
|
||||
const struct ril_msg *message);
|
||||
|
||||
void g_ril_reply_free_sim_status(struct reply_sim_status *status);
|
||||
|
||||
struct reply_sim_status *g_ril_reply_parse_sim_status(GRil *gril,
|
||||
const struct ril_msg *message);
|
||||
|
||||
struct ofono_phone_number *g_ril_reply_parse_get_smsc_address(
|
||||
GRil *gril,
|
||||
const struct ril_msg *message);
|
||||
|
||||
int g_ril_reply_parse_sms_response(GRil *gril, const struct ril_msg *message);
|
||||
|
||||
GSList *g_ril_reply_parse_get_calls(GRil *gril, const struct ril_msg *message);
|
||||
|
||||
enum ofono_disconnect_reason g_ril_reply_parse_call_fail_cause(
|
||||
GRil *gril, const struct ril_msg *message);
|
||||
|
||||
int g_ril_reply_parse_get_mute(GRil *gril, const struct ril_msg *message);
|
||||
|
||||
char *g_ril_reply_parse_baseband_version(GRil *gril,
|
||||
const struct ril_msg *message);
|
||||
|
||||
char *g_ril_reply_parse_get_imei(GRil *gril,
|
||||
const struct ril_msg *message);
|
||||
|
||||
int g_ril_reply_parse_query_call_waiting(GRil *gril,
|
||||
const struct ril_msg *message);
|
||||
|
||||
int g_ril_reply_parse_query_clip(GRil *gril,
|
||||
const struct ril_msg *message);
|
||||
|
||||
void g_ril_reply_free_get_clir(struct reply_clir *rclir);
|
||||
|
||||
struct reply_clir *g_ril_reply_parse_get_clir(GRil *gril,
|
||||
const struct ril_msg *message);
|
||||
|
||||
struct ofono_call_forwarding_condition
|
||||
*g_ril_reply_parse_query_call_fwd(GRil *gril,
|
||||
const struct ril_msg *message,
|
||||
unsigned int *list_size);
|
||||
|
||||
int g_ril_reply_parse_get_preferred_network_type(GRil *gril,
|
||||
const struct ril_msg *message);
|
||||
|
||||
int g_ril_reply_parse_query_facility_lock(GRil *gril,
|
||||
const struct ril_msg *message);
|
||||
|
||||
int g_ril_reply_parse_set_facility_lock(GRil *gril,
|
||||
const struct ril_msg *message);
|
||||
|
||||
int *g_ril_reply_parse_retries(GRil *gril, const struct ril_msg *message,
|
||||
enum ofono_sim_password_type passwd_type);
|
||||
|
||||
void g_ril_reply_free_oem_hook(struct reply_oem_hook *oem_hook);
|
||||
|
||||
struct reply_oem_hook *g_ril_reply_oem_hook_raw(GRil *gril,
|
||||
const struct ril_msg *message);
|
||||
|
||||
struct parcel_str_array *g_ril_reply_oem_hook_strings(GRil *gril,
|
||||
const struct ril_msg *message);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __GRILREPLY_H */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,293 @@
|
|||
/*
|
||||
*
|
||||
* RIL library with GLib integration
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2012-2014 Canonical Ltd.
|
||||
* Copyright (C) 2015 Ratchanan Srirattanamet.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __GRILREQUEST_H
|
||||
#define __GRILREQUEST_H
|
||||
|
||||
#include <ofono/types.h>
|
||||
#include <ofono/modem.h>
|
||||
#include <ofono/sim.h>
|
||||
|
||||
#include "gril.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct req_call_fwd {
|
||||
int action;
|
||||
int type;
|
||||
int cls;
|
||||
const struct ofono_phone_number *number;
|
||||
int time;
|
||||
};
|
||||
|
||||
struct req_deactivate_data_call {
|
||||
gint cid;
|
||||
guint reason;
|
||||
};
|
||||
|
||||
struct req_setup_data_call {
|
||||
guint tech;
|
||||
guint data_profile;
|
||||
gchar *apn;
|
||||
gchar *username;
|
||||
gchar *password;
|
||||
guint auth_type;
|
||||
guint protocol;
|
||||
unsigned req_cid;
|
||||
};
|
||||
|
||||
struct req_sim_read_info {
|
||||
guint app_type;
|
||||
gchar *aid_str;
|
||||
int fileid;
|
||||
const unsigned char *path;
|
||||
unsigned int path_len;
|
||||
};
|
||||
|
||||
|
||||
struct req_sim_read_binary {
|
||||
guint app_type;
|
||||
gchar *aid_str;
|
||||
int fileid;
|
||||
const unsigned char *path;
|
||||
unsigned int path_len;
|
||||
int start;
|
||||
int length;
|
||||
};
|
||||
|
||||
|
||||
struct req_sim_read_record {
|
||||
guint app_type;
|
||||
gchar *aid_str;
|
||||
int fileid;
|
||||
const unsigned char *path;
|
||||
unsigned int path_len;
|
||||
int record;
|
||||
int length;
|
||||
};
|
||||
|
||||
struct req_sim_write_binary {
|
||||
guint app_type;
|
||||
gchar *aid_str;
|
||||
int fileid;
|
||||
const unsigned char *path;
|
||||
unsigned int path_len;
|
||||
int start;
|
||||
int length;
|
||||
const unsigned char *data;
|
||||
};
|
||||
|
||||
enum req_record_access_mode {
|
||||
GRIL_REC_ACCESS_MODE_CURRENT,
|
||||
GRIL_REC_ACCESS_MODE_ABSOLUTE,
|
||||
GRIL_REC_ACCESS_MODE_NEXT,
|
||||
GRIL_REC_ACCESS_MODE_PREVIOUS,
|
||||
};
|
||||
|
||||
struct req_sim_write_record {
|
||||
guint app_type;
|
||||
gchar *aid_str;
|
||||
int fileid;
|
||||
const unsigned char *path;
|
||||
unsigned int path_len;
|
||||
enum req_record_access_mode mode;
|
||||
int record;
|
||||
int length;
|
||||
const unsigned char *data;
|
||||
};
|
||||
|
||||
struct req_pin_change_state {
|
||||
const gchar *aid_str;
|
||||
enum ofono_sim_password_type passwd_type;
|
||||
int enable;
|
||||
const char *passwd;
|
||||
};
|
||||
|
||||
struct req_sms_cmgs {
|
||||
const unsigned char *pdu;
|
||||
int pdu_len;
|
||||
int tpdu_len;
|
||||
};
|
||||
|
||||
gboolean g_ril_request_deactivate_data_call(GRil *gril,
|
||||
const struct req_deactivate_data_call *req,
|
||||
struct parcel *rilp,
|
||||
struct ofono_error *error);
|
||||
|
||||
void g_ril_request_power(GRil *gril,
|
||||
gboolean power,
|
||||
struct parcel *rilp);
|
||||
|
||||
void g_ril_request_set_net_select_manual(GRil *gril,
|
||||
const char *mccmnc,
|
||||
struct parcel *rilp);
|
||||
|
||||
gboolean g_ril_request_setup_data_call(GRil *gril,
|
||||
const struct req_setup_data_call *req,
|
||||
struct parcel *rilp,
|
||||
struct ofono_error *error);
|
||||
|
||||
gboolean g_ril_request_sim_read_info(GRil *gril,
|
||||
const struct req_sim_read_info *req,
|
||||
struct parcel *rilp);
|
||||
|
||||
gboolean g_ril_request_sim_read_binary(GRil *gril,
|
||||
const struct req_sim_read_binary *req,
|
||||
struct parcel *rilp);
|
||||
|
||||
gboolean g_ril_request_sim_read_record(GRil *gril,
|
||||
const struct req_sim_read_record *req,
|
||||
struct parcel *rilp);
|
||||
|
||||
gboolean g_ril_request_sim_write_binary(GRil *gril,
|
||||
const struct req_sim_write_binary *req,
|
||||
struct parcel *rilp);
|
||||
|
||||
gboolean g_ril_request_sim_write_record(GRil *gril,
|
||||
const struct req_sim_write_record *req,
|
||||
struct parcel *rilp);
|
||||
|
||||
void g_ril_request_read_imsi(GRil *gril,
|
||||
const gchar *aid_str,
|
||||
struct parcel *rilp);
|
||||
|
||||
void g_ril_request_pin_send(GRil *gril,
|
||||
const char *passwd,
|
||||
const gchar *aid_str,
|
||||
struct parcel *rilp);
|
||||
|
||||
gboolean g_ril_request_pin_change_state(GRil *gril,
|
||||
const struct req_pin_change_state *req,
|
||||
struct parcel *rilp);
|
||||
|
||||
void g_ril_request_pin_send_puk(GRil *gril,
|
||||
const char *puk,
|
||||
const char *passwd,
|
||||
const gchar *aid_str,
|
||||
struct parcel *rilp);
|
||||
|
||||
void g_ril_request_change_passwd(GRil *gril,
|
||||
const char *old_passwd,
|
||||
const char *new_passwd,
|
||||
const gchar *aid_str,
|
||||
struct parcel *rilp);
|
||||
|
||||
void g_ril_request_sms_cmgs(GRil *gril,
|
||||
const struct req_sms_cmgs *req,
|
||||
struct parcel *rilp);
|
||||
|
||||
void g_ril_request_sms_acknowledge(GRil *gril, struct parcel *rilp);
|
||||
|
||||
void g_ril_request_set_smsc_address(GRil *gril,
|
||||
const struct ofono_phone_number *sca,
|
||||
struct parcel *rilp);
|
||||
|
||||
void g_ril_request_dial(GRil *gril,
|
||||
const struct ofono_phone_number *ph,
|
||||
enum ofono_clir_option clir,
|
||||
struct parcel *rilp);
|
||||
|
||||
void g_ril_request_hangup(GRil *gril,
|
||||
unsigned call_id,
|
||||
struct parcel *rilp);
|
||||
|
||||
void g_ril_request_dtmf(GRil *gril,
|
||||
char dtmf_char,
|
||||
struct parcel *rilp);
|
||||
|
||||
void g_ril_request_separate_conn(GRil *gril,
|
||||
int call_id,
|
||||
struct parcel *rilp);
|
||||
|
||||
void g_ril_request_set_supp_svc_notif(GRil *gril,
|
||||
struct parcel *rilp);
|
||||
|
||||
void g_ril_request_set_mute(GRil *gril,
|
||||
int muted,
|
||||
struct parcel *rilp);
|
||||
|
||||
void g_ril_request_send_ussd(GRil *gril,
|
||||
const char *ussd,
|
||||
struct parcel *rilp);
|
||||
|
||||
void g_ril_request_set_call_waiting(GRil *gril,
|
||||
int enabled, int serviceclass,
|
||||
struct parcel *rilp);
|
||||
|
||||
void g_ril_request_query_call_waiting(GRil *gril,
|
||||
int serviceclass,
|
||||
struct parcel *rilp);
|
||||
|
||||
void g_ril_request_set_clir(GRil *gril,
|
||||
int mode,
|
||||
struct parcel *rilp);
|
||||
|
||||
void g_ril_request_screen_state(GRil *gril,
|
||||
int state,
|
||||
struct parcel *rilp);
|
||||
|
||||
void g_ril_request_call_fwd(GRil *gril, const struct req_call_fwd *req,
|
||||
struct parcel *rilp);
|
||||
|
||||
void g_ril_request_set_preferred_network_type(GRil *gril, int net_type,
|
||||
struct parcel *rilp);
|
||||
|
||||
void g_ril_request_query_facility_lock(GRil *gril, const char *facility,
|
||||
const char *password, int services,
|
||||
struct parcel *rilp);
|
||||
|
||||
void g_ril_request_set_facility_lock(GRil *gril, const char *facility,
|
||||
int enable, const char *passwd,
|
||||
int services, struct parcel *rilp);
|
||||
|
||||
void g_ril_request_change_barring_password(GRil *gril, const char *facility,
|
||||
const char *old_passwd,
|
||||
const char *new_passwd,
|
||||
struct parcel *rilp);
|
||||
|
||||
void g_ril_request_oem_hook_raw(GRil *gril, const void *payload, size_t length,
|
||||
struct parcel *rilp);
|
||||
|
||||
void g_ril_request_oem_hook_strings(GRil *gril, const char **strs, int num_str,
|
||||
struct parcel *rilp);
|
||||
|
||||
void g_ril_request_set_initial_attach_apn(GRil *gril, const char *apn,
|
||||
int proto,
|
||||
const char *user,
|
||||
const char *passwd,
|
||||
const char *mccmnc,
|
||||
struct parcel *rilp);
|
||||
|
||||
void g_ril_request_set_uicc_subscription(GRil *gril, int slot_id,
|
||||
int app_index,
|
||||
int sub_id,
|
||||
int sub_status,
|
||||
struct parcel *rilp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __GRILREQUEST_H */
|
|
@ -0,0 +1,638 @@
|
|||
/*
|
||||
*
|
||||
* RIL library with GLib integration
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2012-2013 Canonical Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <ofono/log.h>
|
||||
#include <ofono/modem.h>
|
||||
#include <ofono/gprs-context.h>
|
||||
#include "util.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "grilunsol.h"
|
||||
|
||||
/* Minimum size is two int32s version/number of calls */
|
||||
#define MIN_DATA_CALL_LIST_SIZE 8
|
||||
|
||||
/*
|
||||
* Minimum NITZ is: 'yy/mm/dd,hh:mm:ss'
|
||||
* TZ '(+/-)tz,dt' are optional
|
||||
*/
|
||||
#define MIN_NITZ_SIZE 17
|
||||
|
||||
static gint data_call_compare(gconstpointer a, gconstpointer b)
|
||||
{
|
||||
const struct ril_data_call *ca = a;
|
||||
const struct ril_data_call *cb = b;
|
||||
|
||||
if (ca->cid < cb->cid)
|
||||
return -1;
|
||||
|
||||
if (ca->cid > cb->cid)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void free_data_call(gpointer data, gpointer user_data)
|
||||
{
|
||||
struct ril_data_call *call = data;
|
||||
|
||||
if (call) {
|
||||
g_free(call->ifname);
|
||||
g_free(call->ip_addr);
|
||||
g_free(call->dns_addrs);
|
||||
g_free(call->gateways);
|
||||
g_free(call);
|
||||
}
|
||||
}
|
||||
|
||||
void g_ril_unsol_free_data_call_list(struct ril_data_call_list *call_list)
|
||||
{
|
||||
if (call_list) {
|
||||
g_slist_foreach(call_list->calls, (GFunc) free_data_call, NULL);
|
||||
g_slist_free(call_list->calls);
|
||||
g_free(call_list);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean handle_settings(struct ril_data_call *call, char *type,
|
||||
char *ifname, char *raw_ip_addrs,
|
||||
char *raw_dns, char *raw_gws)
|
||||
{
|
||||
gboolean result = FALSE;
|
||||
int protocol;
|
||||
char **dns_addrs = NULL, **gateways = NULL;
|
||||
char **ip_addrs = NULL, **split_ip_addr = NULL;
|
||||
|
||||
protocol = ril_protocol_string_to_ofono_protocol(type);
|
||||
if (protocol < 0) {
|
||||
ofono_error("%s: invalid type(protocol) specified: %s",
|
||||
__func__, type);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (ifname == NULL || strlen(ifname) == 0) {
|
||||
ofono_error("%s: no interface specified: %s",
|
||||
__func__, ifname);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Split DNS addresses */
|
||||
if (raw_dns)
|
||||
dns_addrs = g_strsplit(raw_dns, " ", 3);
|
||||
|
||||
/*
|
||||
* RILD can return multiple addresses; oFono only supports
|
||||
* setting a single IPv4 gateway.
|
||||
*/
|
||||
if (raw_gws)
|
||||
gateways = g_strsplit(raw_gws, " ", 3);
|
||||
|
||||
if (gateways == NULL || g_strv_length(gateways) == 0) {
|
||||
ofono_error("%s: no gateways: %s", __func__, raw_gws);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* TODO:
|
||||
* RILD can return multiple addresses; oFono only supports
|
||||
* setting a single IPv4 address. At this time, we only
|
||||
* use the first address. It's possible that a RIL may
|
||||
* just specify the end-points of the point-to-point
|
||||
* connection, in which case this code will need to
|
||||
* changed to handle such a device.
|
||||
*
|
||||
* For now split into a maximum of three, and only use
|
||||
* the first address for the remaining operations.
|
||||
*/
|
||||
if (raw_ip_addrs)
|
||||
ip_addrs = g_strsplit(raw_ip_addrs, " ", 3);
|
||||
|
||||
if (ip_addrs == NULL || g_strv_length(ip_addrs) == 0) {
|
||||
ofono_error("%s: no IP address: %s", __func__, raw_ip_addrs);
|
||||
goto done;
|
||||
}
|
||||
|
||||
DBG("num ip addrs is: %d", g_strv_length(ip_addrs));
|
||||
|
||||
if (g_strv_length(ip_addrs) > 1)
|
||||
ofono_warn("%s: more than one IP addr returned: %s", __func__,
|
||||
raw_ip_addrs);
|
||||
/*
|
||||
* Note - the address may optionally include a prefix size
|
||||
* ( Eg. "/30" ). As this confuses NetworkManager, we
|
||||
* explicitly strip any prefix after calculating the netmask.
|
||||
*/
|
||||
split_ip_addr = g_strsplit(ip_addrs[0], "/", 2);
|
||||
|
||||
if (split_ip_addr == NULL || g_strv_length(split_ip_addr) == 0) {
|
||||
ofono_error("%s: invalid IP address field returned: %s",
|
||||
__func__, ip_addrs[0]);
|
||||
goto done;
|
||||
}
|
||||
|
||||
call->protocol = protocol;
|
||||
call->ifname = g_strdup(ifname);
|
||||
call->ip_addr = g_strdup(split_ip_addr[0]);
|
||||
call->dns_addrs = g_strdupv(dns_addrs);
|
||||
call->gateways = g_strdupv(gateways);
|
||||
|
||||
result = TRUE;
|
||||
|
||||
done:
|
||||
if (dns_addrs)
|
||||
g_strfreev(dns_addrs);
|
||||
|
||||
if (gateways)
|
||||
g_strfreev(gateways);
|
||||
|
||||
if (ip_addrs)
|
||||
g_strfreev(ip_addrs);
|
||||
|
||||
if (split_ip_addr)
|
||||
g_strfreev(split_ip_addr);
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function handles RIL_UNSOL_DATA_CALL_LIST_CHANGED messages,
|
||||
* as well as RIL_REQUEST_DATA_CALL_LIST/SETUP_DATA_CALL replies, as
|
||||
* all have the same payload.
|
||||
*/
|
||||
struct ril_data_call_list *g_ril_unsol_parse_data_call_list(GRil *gril,
|
||||
const struct ril_msg *message)
|
||||
{
|
||||
struct ril_data_call *call;
|
||||
struct parcel rilp;
|
||||
struct ril_data_call_list *reply = NULL;
|
||||
unsigned int active, cid, i, num_calls, retry, status;
|
||||
char *type = NULL, *ifname = NULL, *raw_addrs = NULL;
|
||||
char *raw_dns = NULL, *raw_gws = NULL;
|
||||
|
||||
DBG("");
|
||||
|
||||
/* Can happen for RIL_REQUEST_DATA_CALL_LIST replies */
|
||||
if (message->buf_len < MIN_DATA_CALL_LIST_SIZE) {
|
||||
if (message->req == RIL_REQUEST_SETUP_DATA_CALL) {
|
||||
ofono_error("%s: message too small: %d",
|
||||
__func__,
|
||||
(int) message->buf_len);
|
||||
goto error;
|
||||
} else {
|
||||
g_ril_append_print_buf(gril, "{");
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
reply = g_try_new0(struct ril_data_call_list, 1);
|
||||
if (reply == NULL) {
|
||||
ofono_error("%s: out of memory", __func__);
|
||||
goto error;
|
||||
}
|
||||
|
||||
g_ril_init_parcel(message, &rilp);
|
||||
|
||||
/*
|
||||
* ril.h documents the reply to a RIL_REQUEST_DATA_CALL_LIST
|
||||
* as being an array of RIL_Data_Call_Response_v6 structs,
|
||||
* however in reality, the response also includes a version
|
||||
* to start.
|
||||
*/
|
||||
reply->version = parcel_r_int32(&rilp);
|
||||
num_calls = parcel_r_int32(&rilp);
|
||||
|
||||
g_ril_append_print_buf(gril,
|
||||
"{version=%d,num=%d",
|
||||
reply->version,
|
||||
num_calls);
|
||||
|
||||
for (i = 0; i < num_calls; i++) {
|
||||
status = parcel_r_int32(&rilp);
|
||||
retry = parcel_r_int32(&rilp); /* ignore */
|
||||
cid = parcel_r_int32(&rilp);
|
||||
active = parcel_r_int32(&rilp);
|
||||
type = parcel_r_string(&rilp);
|
||||
ifname = parcel_r_string(&rilp);
|
||||
raw_addrs = parcel_r_string(&rilp);
|
||||
raw_dns = parcel_r_string(&rilp);
|
||||
raw_gws = parcel_r_string(&rilp);
|
||||
|
||||
/* malformed check */
|
||||
if (rilp.malformed) {
|
||||
ofono_error("%s: malformed parcel received", __func__);
|
||||
goto error;
|
||||
}
|
||||
|
||||
g_ril_append_print_buf(gril,
|
||||
"%s [status=%d,retry=%d,cid=%d,"
|
||||
"active=%d,type=%s,ifname=%s,"
|
||||
"address=%s,dns=%s,gateways=%s]",
|
||||
print_buf,
|
||||
status,
|
||||
retry,
|
||||
cid,
|
||||
active,
|
||||
type,
|
||||
ifname,
|
||||
raw_addrs,
|
||||
raw_dns,
|
||||
raw_gws);
|
||||
|
||||
call = g_try_new0(struct ril_data_call, 1);
|
||||
if (call == NULL) {
|
||||
ofono_error("%s: out of memory", __func__);
|
||||
goto error;
|
||||
}
|
||||
|
||||
call->status = status;
|
||||
call->cid = cid;
|
||||
call->active = active;
|
||||
|
||||
if (message->req == RIL_REQUEST_SETUP_DATA_CALL &&
|
||||
status == PDP_FAIL_NONE &&
|
||||
handle_settings(call, type, ifname, raw_addrs,
|
||||
raw_dns, raw_gws) == FALSE)
|
||||
goto error;
|
||||
|
||||
g_free(type);
|
||||
g_free(ifname);
|
||||
g_free(raw_addrs);
|
||||
g_free(raw_dns);
|
||||
g_free(raw_gws);
|
||||
|
||||
reply->calls =
|
||||
g_slist_insert_sorted(reply->calls, call,
|
||||
data_call_compare);
|
||||
}
|
||||
|
||||
done:
|
||||
g_ril_append_print_buf(gril, "%s}", print_buf);
|
||||
|
||||
if (message->unsolicited)
|
||||
g_ril_print_unsol(gril, message);
|
||||
else
|
||||
g_ril_print_response(gril, message);
|
||||
|
||||
return reply;
|
||||
|
||||
error:
|
||||
g_free(type);
|
||||
g_free(ifname);
|
||||
g_free(raw_addrs);
|
||||
g_free(raw_dns);
|
||||
g_free(raw_gws);
|
||||
g_ril_unsol_free_data_call_list(reply);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *g_ril_unsol_parse_nitz(GRil *gril, const struct ril_msg *message)
|
||||
{
|
||||
struct parcel rilp;
|
||||
gchar *nitz = NULL;
|
||||
|
||||
DBG("");
|
||||
|
||||
if (message->buf_len < MIN_NITZ_SIZE) {
|
||||
ofono_error("%s: NITZ too small: %d",
|
||||
__func__,
|
||||
(int) message->buf_len);
|
||||
goto error;
|
||||
}
|
||||
|
||||
g_ril_init_parcel(message, &rilp);
|
||||
|
||||
nitz = parcel_r_string(&rilp);
|
||||
|
||||
g_ril_append_print_buf(gril, "(%s)", nitz);
|
||||
g_ril_print_unsol(gril, message);
|
||||
|
||||
error:
|
||||
return nitz;
|
||||
}
|
||||
|
||||
void g_ril_unsol_free_sms_data(struct unsol_sms_data *unsol)
|
||||
{
|
||||
if (unsol != NULL) {
|
||||
g_free(unsol->data);
|
||||
g_free(unsol);
|
||||
}
|
||||
}
|
||||
|
||||
struct unsol_sms_data *g_ril_unsol_parse_new_sms(GRil *gril,
|
||||
const struct ril_msg *message)
|
||||
{
|
||||
struct parcel rilp;
|
||||
char *ril_pdu;
|
||||
size_t ril_pdu_len;
|
||||
struct unsol_sms_data *sms_data;
|
||||
|
||||
sms_data = g_new0(struct unsol_sms_data, 1);
|
||||
if (sms_data == NULL) {
|
||||
ofono_error("%s out of memory", __func__);
|
||||
goto error;
|
||||
}
|
||||
|
||||
g_ril_init_parcel(message, &rilp);
|
||||
|
||||
ril_pdu = parcel_r_string(&rilp);
|
||||
if (ril_pdu == NULL) {
|
||||
ofono_error("%s Unable to parse notification", __func__);
|
||||
goto error;
|
||||
}
|
||||
|
||||
ril_pdu_len = strlen(ril_pdu);
|
||||
|
||||
sms_data->data = decode_hex(ril_pdu, ril_pdu_len,
|
||||
&sms_data->length, -1);
|
||||
if (sms_data->data == NULL) {
|
||||
ofono_error("%s Unable to decode notification", __func__);
|
||||
goto error_dec;
|
||||
}
|
||||
|
||||
g_ril_append_print_buf(gril, "{%s}", ril_pdu);
|
||||
g_ril_print_unsol(gril, message);
|
||||
|
||||
g_free(ril_pdu);
|
||||
|
||||
return sms_data;
|
||||
|
||||
error_dec:
|
||||
g_free(ril_pdu);
|
||||
error:
|
||||
g_ril_unsol_free_sms_data(sms_data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int g_ril_unsol_parse_radio_state_changed(GRil *gril,
|
||||
const struct ril_msg *message)
|
||||
{
|
||||
struct parcel rilp;
|
||||
int radio_state;
|
||||
|
||||
g_ril_init_parcel(message, &rilp);
|
||||
|
||||
radio_state = parcel_r_int32(&rilp);
|
||||
|
||||
if (rilp.malformed) {
|
||||
ofono_error("%s: malformed parcel received", __func__);
|
||||
radio_state = -1;
|
||||
}
|
||||
|
||||
g_ril_append_print_buf(gril, "(state: %s)",
|
||||
ril_radio_state_to_string(radio_state));
|
||||
|
||||
g_ril_print_unsol(gril, message);
|
||||
|
||||
return radio_state;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function makes a similar processing to was is done by validateInput()
|
||||
* and getLteLevel() in $AOSP/frameworks/base/telephony/java/android/telephony/
|
||||
* SignalStrength.java. The main difference is that we linearly transform the
|
||||
* ranges to ofono's one, while AOSP gives number of bars in a non-linear way
|
||||
* (bins for each bar have different size). We rely on the indicator to obtain
|
||||
* a translation to bars that makes sense for humans.
|
||||
*/
|
||||
static int get_lte_strength(int signal, int rsrp, int rssnr)
|
||||
{
|
||||
int s_rsrp = -1, s_rssnr = -1, s_signal = -1;
|
||||
|
||||
/*
|
||||
* The range of signal is specified to be [0, 31] by ril.h, but the code
|
||||
* in SignalStrength.java contradicts this: valid values are (0-63, 99)
|
||||
* as defined in TS 36.331 for E-UTRA rssi.
|
||||
*/
|
||||
signal = (signal >= 0 && signal <= 63) ? signal : INT_MAX;
|
||||
rsrp = (rsrp >= 44 && rsrp <= 140) ? -rsrp : INT_MAX;
|
||||
rssnr = (rssnr >= -200 && rssnr <= 300) ? rssnr : INT_MAX;
|
||||
|
||||
/* Linearly transform [-140, -44] to [0, 100] */
|
||||
if (rsrp != INT_MAX)
|
||||
s_rsrp = (25 * rsrp + 3500) / 24;
|
||||
|
||||
/* Linearly transform [-200, 300] to [0, 100] */
|
||||
if (rssnr != INT_MAX)
|
||||
s_rssnr = (rssnr + 200) / 5;
|
||||
|
||||
if (s_rsrp != -1 && s_rssnr != -1)
|
||||
return s_rsrp < s_rssnr ? s_rsrp : s_rssnr;
|
||||
|
||||
if (s_rssnr != -1)
|
||||
return s_rssnr;
|
||||
|
||||
if (s_rsrp != -1)
|
||||
return s_rsrp;
|
||||
|
||||
/* Linearly transform [0, 63] to [0, 100] */
|
||||
if (signal != INT_MAX)
|
||||
s_signal = (100 * signal) / 63;
|
||||
|
||||
return s_signal;
|
||||
}
|
||||
|
||||
/*
|
||||
* Comments to get_lte_strength() apply here also, changing getLteLevel() with
|
||||
* getGsmLevel(). The atmodem driver does exactly the same transformation with
|
||||
* the rssi from AT+CSQ command.
|
||||
*/
|
||||
static int get_gsm_strength(int signal)
|
||||
{
|
||||
/* Checking the range contemplates also the case signal=99 (invalid) */
|
||||
if (signal >= 0 && signal <= 31)
|
||||
return (signal * 100) / 31;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
int g_ril_unsol_parse_signal_strength(GRil *gril, const struct ril_msg *message,
|
||||
int ril_tech)
|
||||
{
|
||||
struct parcel rilp;
|
||||
int gw_sigstr, gw_signal, cdma_dbm, evdo_dbm;
|
||||
int lte_sigstr = -1, lte_rsrp = -1, lte_rssnr = -1;
|
||||
int lte_signal;
|
||||
int signal;
|
||||
|
||||
g_ril_init_parcel(message, &rilp);
|
||||
|
||||
/* RIL_SignalStrength_v5 */
|
||||
/* GW_SignalStrength */
|
||||
gw_sigstr = parcel_r_int32(&rilp);
|
||||
gw_signal = get_gsm_strength(gw_sigstr);
|
||||
parcel_r_int32(&rilp); /* bitErrorRate */
|
||||
|
||||
/*
|
||||
* CDMA/EVDO values are not processed as CDMA is not supported
|
||||
*/
|
||||
|
||||
/* CDMA_SignalStrength */
|
||||
cdma_dbm = parcel_r_int32(&rilp);
|
||||
parcel_r_int32(&rilp); /* ecio */
|
||||
|
||||
/* EVDO_SignalStrength */
|
||||
evdo_dbm = parcel_r_int32(&rilp);
|
||||
parcel_r_int32(&rilp); /* ecio */
|
||||
parcel_r_int32(&rilp); /* signalNoiseRatio */
|
||||
|
||||
/* Present only for RIL_SignalStrength_v6 or newer */
|
||||
if (parcel_data_avail(&rilp) > 0) {
|
||||
/* LTE_SignalStrength */
|
||||
lte_sigstr = parcel_r_int32(&rilp);
|
||||
lte_rsrp = parcel_r_int32(&rilp);
|
||||
parcel_r_int32(&rilp); /* rsrq */
|
||||
lte_rssnr = parcel_r_int32(&rilp);
|
||||
parcel_r_int32(&rilp); /* cqi */
|
||||
lte_signal = get_lte_strength(lte_sigstr, lte_rsrp, lte_rssnr);
|
||||
} else {
|
||||
lte_signal = -1;
|
||||
}
|
||||
|
||||
g_ril_append_print_buf(gril,
|
||||
"{gw: %d, cdma: %d, evdo: %d, lte: %d %d %d}",
|
||||
gw_sigstr, cdma_dbm, evdo_dbm, lte_sigstr,
|
||||
lte_rsrp, lte_rssnr);
|
||||
|
||||
if (message->unsolicited)
|
||||
g_ril_print_unsol(gril, message);
|
||||
else
|
||||
g_ril_print_response(gril, message);
|
||||
|
||||
/* Return the first valid one */
|
||||
if (gw_signal != -1 && lte_signal != -1)
|
||||
if (ril_tech == RADIO_TECH_LTE)
|
||||
signal = lte_signal;
|
||||
else
|
||||
signal = gw_signal;
|
||||
else if (gw_signal != -1)
|
||||
signal = gw_signal;
|
||||
else if (lte_signal != -1)
|
||||
signal = lte_signal;
|
||||
else
|
||||
signal = -1;
|
||||
|
||||
return signal;
|
||||
}
|
||||
|
||||
void g_ril_unsol_free_supp_svc_notif(struct unsol_supp_svc_notif *unsol)
|
||||
{
|
||||
g_free(unsol);
|
||||
}
|
||||
|
||||
struct unsol_supp_svc_notif *g_ril_unsol_parse_supp_svc_notif(GRil *gril,
|
||||
struct ril_msg *message)
|
||||
{
|
||||
struct parcel rilp;
|
||||
char *tmp_number;
|
||||
int type;
|
||||
struct unsol_supp_svc_notif *unsol =
|
||||
g_new0(struct unsol_supp_svc_notif, 1);
|
||||
|
||||
g_ril_init_parcel(message, &rilp);
|
||||
|
||||
unsol->notif_type = parcel_r_int32(&rilp);
|
||||
unsol->code = parcel_r_int32(&rilp);
|
||||
unsol->index = parcel_r_int32(&rilp);
|
||||
type = parcel_r_int32(&rilp);
|
||||
tmp_number = parcel_r_string(&rilp);
|
||||
|
||||
if (tmp_number != NULL) {
|
||||
strncpy(unsol->number.number, tmp_number,
|
||||
OFONO_MAX_PHONE_NUMBER_LENGTH);
|
||||
unsol->number.type = type;
|
||||
g_free(tmp_number);
|
||||
}
|
||||
|
||||
g_ril_append_print_buf(gril, "{%d,%d,%d,%d,%s}",
|
||||
unsol->notif_type, unsol->code, unsol->index,
|
||||
type, tmp_number);
|
||||
g_ril_print_unsol(gril, message);
|
||||
|
||||
return unsol;
|
||||
}
|
||||
|
||||
void g_ril_unsol_free_ussd(struct unsol_ussd *unsol)
|
||||
{
|
||||
if (unsol != NULL) {
|
||||
g_free(unsol->message);
|
||||
g_free(unsol);
|
||||
}
|
||||
}
|
||||
|
||||
struct unsol_ussd *g_ril_unsol_parse_ussd(GRil *gril, struct ril_msg *message)
|
||||
{
|
||||
struct parcel rilp;
|
||||
struct unsol_ussd *ussd;
|
||||
char *typestr = NULL;
|
||||
int numstr;
|
||||
|
||||
ussd = g_try_malloc0(sizeof(*ussd));
|
||||
if (ussd == NULL) {
|
||||
ofono_error("%s out of memory", __func__);
|
||||
goto error;
|
||||
}
|
||||
|
||||
g_ril_init_parcel(message, &rilp);
|
||||
|
||||
numstr = parcel_r_int32(&rilp);
|
||||
if (numstr < 1) {
|
||||
ofono_error("%s malformed parcel", __func__);
|
||||
goto error;
|
||||
}
|
||||
|
||||
typestr = parcel_r_string(&rilp);
|
||||
if (typestr == NULL || *typestr == '\0') {
|
||||
ofono_error("%s wrong type", __func__);
|
||||
goto error;
|
||||
}
|
||||
|
||||
ussd->type = *typestr - '0';
|
||||
|
||||
g_free(typestr);
|
||||
|
||||
if (numstr > 1)
|
||||
ussd->message = parcel_r_string(&rilp);
|
||||
|
||||
g_ril_append_print_buf(gril, "{%d,%s}", ussd->type, ussd->message);
|
||||
|
||||
g_ril_print_unsol(gril, message);
|
||||
|
||||
return ussd;
|
||||
|
||||
error:
|
||||
g_free(typestr);
|
||||
g_free(ussd);
|
||||
|
||||
return NULL;
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
*
|
||||
* RIL library with GLib integration
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2012-2013 Canonical Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __GRILUNSOL_H
|
||||
#define __GRILUNSOL_H
|
||||
|
||||
#include <ofono/types.h>
|
||||
|
||||
#include "gril.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ril_data_call {
|
||||
guint status;
|
||||
gint cid;
|
||||
guint active;
|
||||
guint protocol;
|
||||
char *ifname;
|
||||
gchar *ip_addr;
|
||||
gchar **dns_addrs;
|
||||
gchar **gateways;
|
||||
};
|
||||
|
||||
struct ril_data_call_list {
|
||||
guint version;
|
||||
GSList *calls;
|
||||
};
|
||||
|
||||
struct unsol_sms_data {
|
||||
long length;
|
||||
unsigned char *data;
|
||||
};
|
||||
|
||||
struct unsol_supp_svc_notif {
|
||||
int notif_type;
|
||||
int code;
|
||||
int index;
|
||||
struct ofono_phone_number number;
|
||||
};
|
||||
|
||||
struct unsol_ussd {
|
||||
int type;
|
||||
char *message;
|
||||
};
|
||||
|
||||
void g_ril_unsol_free_data_call_list(struct ril_data_call_list *data_call_list);
|
||||
|
||||
|
||||
struct ril_data_call_list *g_ril_unsol_parse_data_call_list(GRil *gril,
|
||||
const struct ril_msg *message);
|
||||
|
||||
char *g_ril_unsol_parse_nitz(GRil *gril, const struct ril_msg *message);
|
||||
|
||||
void g_ril_unsol_free_sms_data(struct unsol_sms_data *unsol);
|
||||
|
||||
struct unsol_sms_data *g_ril_unsol_parse_new_sms(GRil *gril,
|
||||
const struct ril_msg *message);
|
||||
|
||||
int g_ril_unsol_parse_radio_state_changed(GRil *gril,
|
||||
const struct ril_msg *message);
|
||||
|
||||
int g_ril_unsol_parse_signal_strength(GRil *gril, const struct ril_msg *message,
|
||||
int ril_tech);
|
||||
|
||||
void g_ril_unsol_free_supp_svc_notif(struct unsol_supp_svc_notif *unsol);
|
||||
|
||||
struct unsol_supp_svc_notif *g_ril_unsol_parse_supp_svc_notif(GRil *gril,
|
||||
struct ril_msg *message);
|
||||
|
||||
void g_ril_unsol_free_ussd(struct unsol_ussd *unsol);
|
||||
|
||||
struct unsol_ussd *g_ril_unsol_parse_ussd(GRil *gril, struct ril_msg *message);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __GRILUNSOL_H */
|
|
@ -0,0 +1,830 @@
|
|||
/*
|
||||
*
|
||||
* RIL library with GLib integration
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2012 Canonical Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <ofono/modem.h>
|
||||
#include <ofono/gprs-context.h>
|
||||
#include <ofono/types.h>
|
||||
|
||||
#include "grilutil.h"
|
||||
#include "parcel.h"
|
||||
#include "ril_constants.h"
|
||||
|
||||
/* Constants used by CALL_LIST, and SETUP_DATA_CALL RIL requests */
|
||||
#define PROTO_IP_STR "IP"
|
||||
#define PROTO_IPV6_STR "IPV6"
|
||||
#define PROTO_IPV4V6_STR "IPV4V6"
|
||||
|
||||
static char temp_str[32];
|
||||
|
||||
const char *ril_ofono_protocol_to_ril_string(guint protocol)
|
||||
{
|
||||
char *result;
|
||||
|
||||
switch (protocol) {
|
||||
case OFONO_GPRS_PROTO_IPV6:
|
||||
result = PROTO_IPV6_STR;
|
||||
break;
|
||||
case OFONO_GPRS_PROTO_IPV4V6:
|
||||
result = PROTO_IPV4V6_STR;
|
||||
break;
|
||||
case OFONO_GPRS_PROTO_IP:
|
||||
result = PROTO_IP_STR;
|
||||
break;
|
||||
default:
|
||||
result = NULL;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int ril_protocol_string_to_ofono_protocol(gchar *protocol_str)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (g_strcmp0(protocol_str, PROTO_IPV6_STR) == 0)
|
||||
result = OFONO_GPRS_PROTO_IPV6;
|
||||
else if (g_strcmp0(protocol_str, PROTO_IPV4V6_STR) == 0)
|
||||
result = OFONO_GPRS_PROTO_IPV4V6;
|
||||
else if (g_strcmp0(protocol_str, PROTO_IP_STR) == 0)
|
||||
result = OFONO_GPRS_PROTO_IP;
|
||||
else
|
||||
result = -1;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const char *ril_appstate_to_string(int app_state)
|
||||
{
|
||||
switch (app_state) {
|
||||
case RIL_APPSTATE_UNKNOWN:
|
||||
return "UNKNOWN";
|
||||
case RIL_APPSTATE_DETECTED:
|
||||
return "DETECTED";
|
||||
case RIL_APPSTATE_PIN:
|
||||
return "PIN";
|
||||
case RIL_APPSTATE_PUK:
|
||||
return "PUK";
|
||||
case RIL_APPSTATE_SUBSCRIPTION_PERSO:
|
||||
return "";
|
||||
case RIL_APPSTATE_READY:
|
||||
return "READY";
|
||||
default:
|
||||
return "<INVALID>";
|
||||
}
|
||||
}
|
||||
|
||||
const char *ril_apptype_to_string(int app_type)
|
||||
{
|
||||
|
||||
switch (app_type) {
|
||||
case RIL_APPTYPE_UNKNOWN:
|
||||
return "UNKNOWN";
|
||||
case RIL_APPTYPE_SIM:
|
||||
return "SIM";
|
||||
case RIL_APPTYPE_USIM:
|
||||
return "USIM";
|
||||
case RIL_APPTYPE_RUIM:
|
||||
return "RUIM";
|
||||
case RIL_APPTYPE_CSIM:
|
||||
return "CSIM";
|
||||
case RIL_APPTYPE_ISIM:
|
||||
return "ISIM";
|
||||
default:
|
||||
return "<INVALID>";
|
||||
}
|
||||
}
|
||||
|
||||
const char *ril_authtype_to_string(int auth_type)
|
||||
{
|
||||
switch (auth_type) {
|
||||
case RIL_AUTH_NONE:
|
||||
return "NONE";
|
||||
case RIL_AUTH_PAP:
|
||||
return "PAP";
|
||||
case RIL_AUTH_CHAP:
|
||||
return "CHAP";
|
||||
case RIL_AUTH_BOTH:
|
||||
return "BOTH";
|
||||
case RIL_AUTH_ANY:
|
||||
return "ANY";
|
||||
default:
|
||||
return "<INVALID>";
|
||||
}
|
||||
}
|
||||
|
||||
const char *ril_cardstate_to_string(int card_state)
|
||||
{
|
||||
switch (card_state) {
|
||||
case RIL_CARDSTATE_ABSENT:
|
||||
return "ABSENT";
|
||||
case RIL_CARDSTATE_PRESENT:
|
||||
return "PRESENT";
|
||||
case RIL_CARDSTATE_ERROR:
|
||||
return "ERROR";
|
||||
default:
|
||||
return "<INVALID>";
|
||||
}
|
||||
}
|
||||
|
||||
const char *ril_error_to_string(int error)
|
||||
{
|
||||
switch (error) {
|
||||
case RIL_E_SUCCESS: return "SUCCESS";
|
||||
case RIL_E_RADIO_NOT_AVAILABLE: return "RADIO_NOT_AVAILABLE";
|
||||
case RIL_E_GENERIC_FAILURE: return "GENERIC_FAILURE";
|
||||
case RIL_E_PASSWORD_INCORRECT: return "PASSWORD_INCORRECT";
|
||||
case RIL_E_SIM_PIN2: return "SIM_PIN2";
|
||||
case RIL_E_SIM_PUK2: return "SIM_PUK2";
|
||||
case RIL_E_REQUEST_NOT_SUPPORTED: return "REQUEST_NOT_SUPPORTED";
|
||||
case RIL_E_CANCELLED: return "CANCELLED";
|
||||
case RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL:
|
||||
return "OP_NOT_ALLOWED_DURING_VOICE_CALL";
|
||||
case RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW:
|
||||
return "OP_NOT_ALLOWED_BEFORE_REG_TO_NW";
|
||||
case RIL_E_SMS_SEND_FAIL_RETRY: return "SMS_SEND_FAIL_RETRY";
|
||||
case RIL_E_SIM_ABSENT: return "SIM_ABSENT";
|
||||
case RIL_E_SUBSCRIPTION_NOT_AVAILABLE:
|
||||
return "SUBSCRIPTION_NOT_AVAILABLE";
|
||||
case RIL_E_MODE_NOT_SUPPORTED: return "MODE_NOT_SUPPORTED";
|
||||
case RIL_E_FDN_CHECK_FAILURE: return "FDN_CHECK_FAILURE";
|
||||
case RIL_E_ILLEGAL_SIM_OR_ME: return "ILLEGAL_SIM_OR_ME";
|
||||
case RIL_E_DIAL_MODIFIED_TO_USSD: return "DIAL_MODIFIED_TO_USSD";
|
||||
case RIL_E_DIAL_MODIFIED_TO_SS: return "DIAL_MODIFIED_TO_SS";
|
||||
case RIL_E_DIAL_MODIFIED_TO_DIAL: return "DIAL_MODIFIED_TO_DIAL";
|
||||
case RIL_E_USSD_MODIFIED_TO_DIAL: return "USSD_MODIFIED_TO_DIAL";
|
||||
case RIL_E_USSD_MODIFIED_TO_SS: return "USSD_MODIFIED_TO_SS";
|
||||
case RIL_E_USSD_MODIFIED_TO_USSD: return "USSD_MODIFIED_TO_USSD";
|
||||
case RIL_E_SS_MODIFIED_TO_DIAL: return "SS_MODIFIED_TO_DIAL";
|
||||
case RIL_E_SS_MODIFIED_TO_USSD: return "SS_MODIFIED_TO_USSD";
|
||||
case RIL_E_SS_MODIFIED_TO_SS: return "SS_MODIFIED_TO_SS";
|
||||
case RIL_E_SUBSCRIPTION_NOT_SUPPORTED:
|
||||
return "SUBSCRIPTION_NOT_SUPPORTED";
|
||||
default: return "<unknown errno>";
|
||||
}
|
||||
}
|
||||
|
||||
const char *ril_pinstate_to_string(int pin_state)
|
||||
{
|
||||
switch (pin_state) {
|
||||
case RIL_PINSTATE_UNKNOWN:
|
||||
return "UNKNOWN";
|
||||
case RIL_PINSTATE_ENABLED_NOT_VERIFIED:
|
||||
return "ENABLED_NOT_VERIFIED";
|
||||
case RIL_PINSTATE_ENABLED_VERIFIED:
|
||||
return "ENABLED_VERIFIED";
|
||||
case RIL_PINSTATE_DISABLED:
|
||||
return "DISABLED";
|
||||
case RIL_PINSTATE_ENABLED_BLOCKED:
|
||||
return "ENABLED_BLOCKED";
|
||||
case RIL_PINSTATE_ENABLED_PERM_BLOCKED:
|
||||
return "ENABLED_PERM_BLOCKED";
|
||||
default:
|
||||
return "<INVALID>";
|
||||
}
|
||||
}
|
||||
|
||||
const char *ril_radio_state_to_string(int radio_state)
|
||||
{
|
||||
switch (radio_state) {
|
||||
case RADIO_STATE_OFF:
|
||||
return "OFF";
|
||||
case RADIO_STATE_UNAVAILABLE:
|
||||
return "UNAVAILABLE";
|
||||
case RADIO_STATE_SIM_NOT_READY:
|
||||
return "SIM_NOT_READY";
|
||||
case RADIO_STATE_SIM_LOCKED_OR_ABSENT:
|
||||
return "SIM_LOCKED_OR_ABSENT";
|
||||
case RADIO_STATE_SIM_READY:
|
||||
return "SIM_READY";
|
||||
case RADIO_STATE_ON:
|
||||
return "ON";
|
||||
default:
|
||||
return "<INVALID>";
|
||||
}
|
||||
}
|
||||
|
||||
const char *ril_radio_tech_to_string(int radio_tech)
|
||||
{
|
||||
switch (radio_tech) {
|
||||
case RADIO_TECH_UNKNOWN:
|
||||
return "UNKNOWN";
|
||||
case RADIO_TECH_GPRS:
|
||||
return "GPRS";
|
||||
case RADIO_TECH_EDGE:
|
||||
return "EDGE";
|
||||
case RADIO_TECH_UMTS:
|
||||
return "UMTS";
|
||||
case RADIO_TECH_IS95A:
|
||||
return "IS95A";
|
||||
case RADIO_TECH_IS95B:
|
||||
return "IS95B";
|
||||
case RADIO_TECH_1xRTT:
|
||||
return "1xRTT";
|
||||
case RADIO_TECH_EVDO_0:
|
||||
return "EVDO_0";
|
||||
case RADIO_TECH_EVDO_A:
|
||||
return "EVDO_A";
|
||||
case RADIO_TECH_HSDPA:
|
||||
return "HSDPA";
|
||||
case RADIO_TECH_HSUPA:
|
||||
return "HSUPA";
|
||||
case RADIO_TECH_HSPA:
|
||||
return "HSPA";
|
||||
case RADIO_TECH_EVDO_B:
|
||||
return "EVDO_B";
|
||||
case RADIO_TECH_EHRPD:
|
||||
return "EHRPD";
|
||||
case RADIO_TECH_LTE:
|
||||
return "LTE";
|
||||
case RADIO_TECH_HSPAP:
|
||||
return "HSPAP";
|
||||
case RADIO_TECH_GSM:
|
||||
return "GSM";
|
||||
case MTK_RADIO_TECH_HSDPAP:
|
||||
return "MTK_HSDPAP";
|
||||
case MTK_RADIO_TECH_HSDPAP_UPA:
|
||||
return "MTK_HSDPAP_UPA";
|
||||
case MTK_RADIO_TECH_HSUPAP:
|
||||
return "MTK_HSUPAP";
|
||||
case MTK_RADIO_TECH_HSUPAP_DPA:
|
||||
return "MTK_HSUPAP_DPA";
|
||||
case MTK_RADIO_TECH_DC_DPA:
|
||||
return "MTK_DC_DPA";
|
||||
case MTK_RADIO_TECH_DC_UPA:
|
||||
return "MTK_DC_UPA";
|
||||
case MTK_RADIO_TECH_DC_HSDPAP:
|
||||
return "MTK_DC_HSDPAP";
|
||||
case MTK_RADIO_TECH_DC_HSDPAP_UPA:
|
||||
return "MTK_DC_HSDPAP_UPA";
|
||||
case MTK_RADIO_TECH_DC_HSDPAP_DPA:
|
||||
return "MTK_DC_HSDPAP_DPA";
|
||||
case MTK_RADIO_TECH_DC_HSPAP:
|
||||
return "MTK_DC_HSPAP";
|
||||
default:
|
||||
if (g_snprintf(temp_str, sizeof(temp_str),
|
||||
"<INVALID (%d)>",
|
||||
radio_tech))
|
||||
return temp_str;
|
||||
else
|
||||
return "<INVALID>";
|
||||
}
|
||||
}
|
||||
|
||||
const char *ril_request_id_to_string(int req)
|
||||
{
|
||||
switch (req) {
|
||||
case RIL_REQUEST_GET_SIM_STATUS:
|
||||
return "RIL_REQUEST_GET_SIM_STATUS";
|
||||
case RIL_REQUEST_ENTER_SIM_PIN:
|
||||
return "RIL_REQUEST_ENTER_SIM_PIN";
|
||||
case RIL_REQUEST_ENTER_SIM_PUK:
|
||||
return "RIL_REQUEST_ENTER_SIM_PUK";
|
||||
case RIL_REQUEST_ENTER_SIM_PIN2:
|
||||
return "RIL_REQUEST_ENTER_SIM_PIN2";
|
||||
case RIL_REQUEST_ENTER_SIM_PUK2:
|
||||
return "RIL_REQUEST_ENTER_SIM_PUK2";
|
||||
case RIL_REQUEST_CHANGE_SIM_PIN:
|
||||
return "RIL_REQUEST_CHANGE_SIM_PIN";
|
||||
case RIL_REQUEST_CHANGE_SIM_PIN2:
|
||||
return "RIL_REQUEST_CHANGE_SIM_PIN2";
|
||||
case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION:
|
||||
return "RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION";
|
||||
case RIL_REQUEST_GET_CURRENT_CALLS:
|
||||
return "RIL_REQUEST_GET_CURRENT_CALLS";
|
||||
case RIL_REQUEST_DIAL:
|
||||
return "RIL_REQUEST_DIAL";
|
||||
case RIL_REQUEST_GET_IMSI:
|
||||
return "RIL_REQUEST_GET_IMSI";
|
||||
case RIL_REQUEST_HANGUP:
|
||||
return "RIL_REQUEST_HANGUP";
|
||||
case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND:
|
||||
return "RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND";
|
||||
case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND:
|
||||
return "RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND";
|
||||
case RIL_REQUEST_SWITCH_HOLDING_AND_ACTIVE:
|
||||
return "RIL_REQUEST_SWITCH_HOLDING_AND_ACTIVE";
|
||||
case RIL_REQUEST_CONFERENCE:
|
||||
return "RIL_REQUEST_CONFERENCE";
|
||||
case RIL_REQUEST_UDUB:
|
||||
return "RIL_REQUEST_UDUB";
|
||||
case RIL_REQUEST_LAST_CALL_FAIL_CAUSE:
|
||||
return "RIL_REQUEST_LAST_CALL_FAIL_CAUSE";
|
||||
case RIL_REQUEST_SIGNAL_STRENGTH:
|
||||
return "RIL_REQUEST_SIGNAL_STRENGTH";
|
||||
case RIL_REQUEST_VOICE_REGISTRATION_STATE:
|
||||
return "RIL_REQUEST_VOICE_REGISTRATION_STATE";
|
||||
case RIL_REQUEST_DATA_REGISTRATION_STATE:
|
||||
return "RIL_REQUEST_DATA_REGISTRATION_STATE";
|
||||
case RIL_REQUEST_OPERATOR:
|
||||
return "RIL_REQUEST_OPERATOR";
|
||||
case RIL_REQUEST_RADIO_POWER:
|
||||
return "RIL_REQUEST_RADIO_POWER";
|
||||
case RIL_REQUEST_DTMF:
|
||||
return "RIL_REQUEST_DTMF";
|
||||
case RIL_REQUEST_SEND_SMS:
|
||||
return "RIL_REQUEST_SEND_SMS";
|
||||
case RIL_REQUEST_SEND_SMS_EXPECT_MORE:
|
||||
return "RIL_REQUEST_SEND_SMS_EXPECT_MORE";
|
||||
case RIL_REQUEST_SETUP_DATA_CALL:
|
||||
return "RIL_REQUEST_SETUP_DATA_CALL";
|
||||
case RIL_REQUEST_SIM_IO:
|
||||
return "RIL_REQUEST_SIM_IO";
|
||||
case RIL_REQUEST_SEND_USSD:
|
||||
return "RIL_REQUEST_SEND_USSD";
|
||||
case RIL_REQUEST_CANCEL_USSD:
|
||||
return "RIL_REQUEST_CANCEL_USSD";
|
||||
case RIL_REQUEST_GET_CLIR:
|
||||
return "RIL_REQUEST_GET_CLIR";
|
||||
case RIL_REQUEST_SET_CLIR:
|
||||
return "RIL_REQUEST_SET_CLIR";
|
||||
case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS:
|
||||
return "RIL_REQUEST_QUERY_CALL_FORWARD_STATUS";
|
||||
case RIL_REQUEST_SET_CALL_FORWARD:
|
||||
return "RIL_REQUEST_SET_CALL_FORWARD";
|
||||
case RIL_REQUEST_QUERY_CALL_WAITING:
|
||||
return "RIL_REQUEST_QUERY_CALL_WAITING";
|
||||
case RIL_REQUEST_SET_CALL_WAITING:
|
||||
return "RIL_REQUEST_SET_CALL_WAITING";
|
||||
case RIL_REQUEST_SMS_ACKNOWLEDGE:
|
||||
return "RIL_REQUEST_SMS_ACKNOWLEDGE ";
|
||||
case RIL_REQUEST_GET_IMEI:
|
||||
return "RIL_REQUEST_GET_IMEI";
|
||||
case RIL_REQUEST_GET_IMEISV:
|
||||
return "RIL_REQUEST_GET_IMEISV";
|
||||
case RIL_REQUEST_ANSWER:
|
||||
return "RIL_REQUEST_ANSWER";
|
||||
case RIL_REQUEST_DEACTIVATE_DATA_CALL:
|
||||
return "RIL_REQUEST_DEACTIVATE_DATA_CALL";
|
||||
case RIL_REQUEST_QUERY_FACILITY_LOCK:
|
||||
return "RIL_REQUEST_QUERY_FACILITY_LOCK";
|
||||
case RIL_REQUEST_SET_FACILITY_LOCK:
|
||||
return "RIL_REQUEST_SET_FACILITY_LOCK";
|
||||
case RIL_REQUEST_CHANGE_BARRING_PASSWORD:
|
||||
return "RIL_REQUEST_CHANGE_BARRING_PASSWORD";
|
||||
case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE:
|
||||
return "RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE";
|
||||
case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC:
|
||||
return "RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC";
|
||||
case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL:
|
||||
return "RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL";
|
||||
case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS:
|
||||
return "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS";
|
||||
case RIL_REQUEST_DTMF_START:
|
||||
return "RIL_REQUEST_DTMF_START";
|
||||
case RIL_REQUEST_DTMF_STOP:
|
||||
return "RIL_REQUEST_DTMF_STOP";
|
||||
case RIL_REQUEST_BASEBAND_VERSION:
|
||||
return "RIL_REQUEST_BASEBAND_VERSION";
|
||||
case RIL_REQUEST_SEPARATE_CONNECTION:
|
||||
return "RIL_REQUEST_SEPARATE_CONNECTION";
|
||||
case RIL_REQUEST_SET_MUTE:
|
||||
return "RIL_REQUEST_SET_MUTE";
|
||||
case RIL_REQUEST_GET_MUTE:
|
||||
return "RIL_REQUEST_GET_MUTE";
|
||||
case RIL_REQUEST_QUERY_CLIP:
|
||||
return "RIL_REQUEST_QUERY_CLIP";
|
||||
case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE:
|
||||
return "RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE";
|
||||
case RIL_REQUEST_DATA_CALL_LIST:
|
||||
return "RIL_REQUEST_DATA_CALL_LIST";
|
||||
case RIL_REQUEST_RESET_RADIO:
|
||||
return "RIL_REQUEST_RESET_RADIO";
|
||||
case RIL_REQUEST_OEM_HOOK_RAW:
|
||||
return "RIL_REQUEST_OEM_HOOK_RAW";
|
||||
case RIL_REQUEST_OEM_HOOK_STRINGS:
|
||||
return "RIL_REQUEST_OEM_HOOK_STRINGS";
|
||||
case RIL_REQUEST_SCREEN_STATE:
|
||||
return "RIL_REQUEST_SCREEN_STATE";
|
||||
case RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION:
|
||||
return "RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION";
|
||||
case RIL_REQUEST_WRITE_SMS_TO_SIM:
|
||||
return "RIL_REQUEST_WRITE_SMS_TO_SIM";
|
||||
case RIL_REQUEST_DELETE_SMS_ON_SIM:
|
||||
return "RIL_REQUEST_DELETE_SMS_ON_SIM";
|
||||
case RIL_REQUEST_SET_BAND_MODE:
|
||||
return "RIL_REQUEST_SET_BAND_MODE";
|
||||
case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE:
|
||||
return "RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE";
|
||||
case RIL_REQUEST_STK_GET_PROFILE:
|
||||
return "RIL_REQUEST_STK_GET_PROFILE";
|
||||
case RIL_REQUEST_STK_SET_PROFILE:
|
||||
return "RIL_REQUEST_STK_SET_PROFILE";
|
||||
case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND:
|
||||
return "RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND";
|
||||
case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE:
|
||||
return "RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE";
|
||||
case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM:
|
||||
return "RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM";
|
||||
case RIL_REQUEST_EXPLICIT_CALL_TRANSFER:
|
||||
return "RIL_REQUEST_EXPLICIT_CALL_TRANSFER";
|
||||
case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE:
|
||||
return "RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE";
|
||||
case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE:
|
||||
return "RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE";
|
||||
case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS:
|
||||
return "RIL_REQUEST_GET_NEIGHBORING_CELL_IDS";
|
||||
case RIL_REQUEST_SET_LOCATION_UPDATES:
|
||||
return "RIL_REQUEST_SET_LOCATION_UPDATES";
|
||||
case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE:
|
||||
return "RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE";
|
||||
case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE:
|
||||
return "RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE";
|
||||
case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE:
|
||||
return "RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE";
|
||||
case RIL_REQUEST_SET_TTY_MODE:
|
||||
return "RIL_REQUEST_SET_TTY_MODE";
|
||||
case RIL_REQUEST_QUERY_TTY_MODE:
|
||||
return "RIL_REQUEST_QUERY_TTY_MODE";
|
||||
case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE:
|
||||
return "RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE";
|
||||
case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE:
|
||||
return "RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE";
|
||||
case RIL_REQUEST_CDMA_FLASH:
|
||||
return "RIL_REQUEST_CDMA_FLASH";
|
||||
case RIL_REQUEST_CDMA_BURST_DTMF:
|
||||
return "RIL_REQUEST_CDMA_BURST_DTMF";
|
||||
case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY:
|
||||
return "RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY";
|
||||
case RIL_REQUEST_CDMA_SEND_SMS:
|
||||
return "RIL_REQUEST_CDMA_SEND_SMS";
|
||||
case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE:
|
||||
return "RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE";
|
||||
case RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG:
|
||||
return "RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG";
|
||||
case RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG:
|
||||
return "RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG";
|
||||
case RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION:
|
||||
return "RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION";
|
||||
case RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG:
|
||||
return "RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG";
|
||||
case RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG:
|
||||
return "RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG";
|
||||
case RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION:
|
||||
return "RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION";
|
||||
case RIL_REQUEST_CDMA_SUBSCRIPTION:
|
||||
return "RIL_REQUEST_CDMA_SUBSCRIPTION";
|
||||
case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM:
|
||||
return "RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM";
|
||||
case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM:
|
||||
return "RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM";
|
||||
case RIL_REQUEST_DEVICE_IDENTITY:
|
||||
return "RIL_REQUEST_DEVICE_IDENTITY";
|
||||
case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE:
|
||||
return "RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE";
|
||||
case RIL_REQUEST_GET_SMSC_ADDRESS:
|
||||
return "RIL_REQUEST_GET_SMSC_ADDRESS";
|
||||
case RIL_REQUEST_SET_SMSC_ADDRESS:
|
||||
return "RIL_REQUEST_SET_SMSC_ADDRESS";
|
||||
case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS:
|
||||
return "RIL_REQUEST_REPORT_SMS_MEMORY_STATUS";
|
||||
case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING:
|
||||
return "RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING";
|
||||
case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE:
|
||||
return "RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE";
|
||||
case RIL_REQUEST_ISIM_AUTHENTICATION:
|
||||
return "RIL_REQUEST_ISIM_AUTHENTICATION";
|
||||
case RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU:
|
||||
return "RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU";
|
||||
case RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS:
|
||||
return "RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS";
|
||||
case RIL_REQUEST_SET_INITIAL_ATTACH_APN:
|
||||
return "RIL_REQUEST_SET_INITIAL_ATTACH_APN";
|
||||
default:
|
||||
return "<INVALID>";
|
||||
}
|
||||
}
|
||||
|
||||
const char *ril_unsol_request_to_string(int request)
|
||||
{
|
||||
switch (request) {
|
||||
case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED:
|
||||
return "UNSOL_RESPONSE_RADIO_STATE_CHANGED";
|
||||
case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED:
|
||||
return "UNSOL_RESPONSE_CALL_STATE_CHANGED";
|
||||
case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED:
|
||||
return "UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED";
|
||||
case RIL_UNSOL_RESPONSE_NEW_SMS:
|
||||
return "UNSOL_RESPONSE_NEW_SMS";
|
||||
case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT:
|
||||
return "UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT";
|
||||
case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM:
|
||||
return "UNSOL_RESPONSE_NEW_SMS_ON_SIM";
|
||||
case RIL_UNSOL_ON_USSD:
|
||||
return "UNSOL_ON_USSD";
|
||||
case RIL_UNSOL_ON_USSD_REQUEST:
|
||||
return "UNSOL_ON_USSD_REQUEST(obsolete)";
|
||||
case RIL_UNSOL_NITZ_TIME_RECEIVED:
|
||||
return "UNSOL_NITZ_TIME_RECEIVED";
|
||||
case RIL_UNSOL_SIGNAL_STRENGTH:
|
||||
return "UNSOL_SIGNAL_STRENGTH";
|
||||
case RIL_UNSOL_SUPP_SVC_NOTIFICATION:
|
||||
return "UNSOL_SUPP_SVC_NOTIFICATION";
|
||||
case RIL_UNSOL_STK_SESSION_END:
|
||||
return "UNSOL_STK_SESSION_END";
|
||||
case RIL_UNSOL_STK_PROACTIVE_COMMAND:
|
||||
return "UNSOL_STK_PROACTIVE_COMMAND";
|
||||
case RIL_UNSOL_STK_EVENT_NOTIFY:
|
||||
return "UNSOL_STK_EVENT_NOTIFY";
|
||||
case RIL_UNSOL_STK_CALL_SETUP:
|
||||
return "UNSOL_STK_CALL_SETUP";
|
||||
case RIL_UNSOL_SIM_SMS_STORAGE_FULL:
|
||||
return "UNSOL_SIM_SMS_STORAGE_FUL";
|
||||
case RIL_UNSOL_SIM_REFRESH:
|
||||
return "UNSOL_SIM_REFRESH";
|
||||
case RIL_UNSOL_DATA_CALL_LIST_CHANGED:
|
||||
return "UNSOL_DATA_CALL_LIST_CHANGED";
|
||||
case RIL_UNSOL_CALL_RING:
|
||||
return "UNSOL_CALL_RING";
|
||||
case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED:
|
||||
return "UNSOL_RESPONSE_SIM_STATUS_CHANGED";
|
||||
case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS:
|
||||
return "UNSOL_NEW_CDMA_SMS";
|
||||
case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS:
|
||||
return "UNSOL_NEW_BROADCAST_SMS";
|
||||
case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL:
|
||||
return "UNSOL_CDMA_RUIM_SMS_STORAGE_FULL";
|
||||
case RIL_UNSOL_RESTRICTED_STATE_CHANGED:
|
||||
return "UNSOL_RESTRICTED_STATE_CHANGED";
|
||||
case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE:
|
||||
return "UNSOL_ENTER_EMERGENCY_CALLBACK_MODE";
|
||||
case RIL_UNSOL_CDMA_CALL_WAITING:
|
||||
return "UNSOL_CDMA_CALL_WAITING";
|
||||
case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS:
|
||||
return "UNSOL_CDMA_OTA_PROVISION_STATUS";
|
||||
case RIL_UNSOL_CDMA_INFO_REC:
|
||||
return "UNSOL_CDMA_INFO_REC";
|
||||
case RIL_UNSOL_OEM_HOOK_RAW:
|
||||
return "UNSOL_OEM_HOOK_RAW";
|
||||
case RIL_UNSOL_RINGBACK_TONE:
|
||||
return "UNSOL_RINGBACK_TONE";
|
||||
case RIL_UNSOL_RESEND_INCALL_MUTE:
|
||||
return "UNSOL_RESEND_INCALL_MUTE";
|
||||
case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED:
|
||||
return "UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED";
|
||||
case RIL_UNSOL_CDMA_PRL_CHANGED:
|
||||
return "UNSOL_CDMA_PRL_CHANGED";
|
||||
case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE:
|
||||
return "UNSOL_EXIT_EMERGENCY_CALLBACK_MODE";
|
||||
case RIL_UNSOL_RIL_CONNECTED:
|
||||
return "UNSOL_RIL_CONNECTED";
|
||||
default:
|
||||
return "<unknown request>";
|
||||
}
|
||||
}
|
||||
|
||||
const char *ril_pdp_fail_to_string(int status)
|
||||
{
|
||||
switch (status) {
|
||||
case PDP_FAIL_NONE:
|
||||
return "NONE";
|
||||
case PDP_FAIL_OPERATOR_BARRED:
|
||||
return "OPERATOR_BARRED";
|
||||
case PDP_FAIL_INSUFFICIENT_RESOURCES:
|
||||
return "INSUFFICIENT_RESOURCES";
|
||||
case PDP_FAIL_MISSING_UKNOWN_APN:
|
||||
return "MISSING_UKNOWN_APN";
|
||||
case PDP_FAIL_UNKNOWN_PDP_ADDRESS_TYPE:
|
||||
return "UNKNOWN_PDP_ADDRESS_TYPE";
|
||||
case PDP_FAIL_USER_AUTHENTICATION:
|
||||
return "USER_AUTHENTICATION";
|
||||
case PDP_FAIL_ACTIVATION_REJECT_GGSN:
|
||||
return "ACTIVATION_REJECT_GGSN";
|
||||
case PDP_FAIL_ACTIVATION_REJECT_UNSPECIFIED:
|
||||
return "ACTIVATION_REJECT_UNSPECIFIED";
|
||||
case PDP_FAIL_SERVICE_OPTION_NOT_SUPPORTED:
|
||||
return "SERVICE_OPTION_NOT_SUPPORTED";
|
||||
case PDP_FAIL_SERVICE_OPTION_NOT_SUBSCRIBED:
|
||||
return "SERVICE_OPTION_NOT_SUBSCRIBED";
|
||||
case PDP_FAIL_SERVICE_OPTION_OUT_OF_ORDER:
|
||||
return "SERVICE_OPTION_OUT_OF_ORDER";
|
||||
case PDP_FAIL_NSAPI_IN_USE:
|
||||
return "NSAPI_IN_USE";
|
||||
case PDP_FAIL_REGULAR_DEACTIVATION:
|
||||
return "REGULAR_DEACTIVATION";
|
||||
case PDP_FAIL_ONLY_IPV4_ALLOWED:
|
||||
return "ONLY_IPV4_ALLOWED";
|
||||
case PDP_FAIL_ONLY_IPV6_ALLOWED:
|
||||
return "ONLY_IPV6_ALLOWED";
|
||||
case PDP_FAIL_ONLY_SINGLE_BEARER_ALLOWED:
|
||||
return "ONLY_SINGLE_BEARER_ALLOWED";
|
||||
case PDP_FAIL_PROTOCOL_ERRORS:
|
||||
return "PROTOCOL_ERRORS";
|
||||
case PDP_FAIL_VOICE_REGISTRATION_FAIL:
|
||||
return "VOICE_REGISTRATION_FAIL";
|
||||
case PDP_FAIL_DATA_REGISTRATION_FAIL:
|
||||
return "DATA_REGISTRATION_FAIL";
|
||||
case PDP_FAIL_SIGNAL_LOST:
|
||||
return "SIGNAL_LOST";
|
||||
case PDP_FAIL_PREF_RADIO_TECH_CHANGED:
|
||||
return "PREF_RADIO_TECH_CHANGED";
|
||||
case PDP_FAIL_RADIO_POWER_OFF:
|
||||
return "RADIO_POWER_OFF";
|
||||
case PDP_FAIL_TETHERED_CALL_ACTIVE:
|
||||
return "TETHERED_CALL_ACTIVE";
|
||||
case PDP_FAIL_ERROR_UNSPECIFIED:
|
||||
return "ERROR_UNSPECIFIED";
|
||||
default:
|
||||
if (g_snprintf(temp_str, sizeof(temp_str),
|
||||
"<UNKNOWN (%d)>", status))
|
||||
return temp_str;
|
||||
else
|
||||
return "<UNKNOWN>";
|
||||
}
|
||||
}
|
||||
|
||||
void g_ril_util_debug_chat(gboolean in, const char *str, gsize len,
|
||||
GRilDebugFunc debugf, gpointer user_data)
|
||||
{
|
||||
char type = in ? '<' : '>';
|
||||
gsize escaped = 2; /* Enough for '<', ' ' */
|
||||
char *escaped_str;
|
||||
const char *esc = "<ESC>";
|
||||
gsize esc_size = strlen(esc);
|
||||
const char *ctrlz = "<CtrlZ>";
|
||||
gsize ctrlz_size = strlen(ctrlz);
|
||||
gsize i;
|
||||
|
||||
if (debugf == NULL || !len)
|
||||
return;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
char c = str[i];
|
||||
|
||||
if (g_ascii_isprint(c))
|
||||
escaped += 1;
|
||||
else if (c == '\r' || c == '\t' || c == '\n')
|
||||
escaped += 2;
|
||||
else if (c == 26)
|
||||
escaped += ctrlz_size;
|
||||
else if (c == 25)
|
||||
escaped += esc_size;
|
||||
else
|
||||
escaped += 4;
|
||||
}
|
||||
|
||||
escaped_str = g_try_malloc(escaped + 1);
|
||||
if (escaped_str == NULL)
|
||||
return;
|
||||
|
||||
escaped_str[0] = type;
|
||||
escaped_str[1] = ' ';
|
||||
escaped_str[2] = '\0';
|
||||
escaped_str[escaped] = '\0';
|
||||
|
||||
for (escaped = 2, i = 0; i < len; i++) {
|
||||
unsigned char c = str[i];
|
||||
|
||||
switch (c) {
|
||||
case '\r':
|
||||
escaped_str[escaped++] = '\\';
|
||||
escaped_str[escaped++] = 'r';
|
||||
break;
|
||||
case '\t':
|
||||
escaped_str[escaped++] = '\\';
|
||||
escaped_str[escaped++] = 't';
|
||||
break;
|
||||
case '\n':
|
||||
escaped_str[escaped++] = '\\';
|
||||
escaped_str[escaped++] = 'n';
|
||||
break;
|
||||
case 26:
|
||||
strncpy(&escaped_str[escaped], ctrlz, ctrlz_size);
|
||||
escaped += ctrlz_size;
|
||||
break;
|
||||
case 25:
|
||||
strncpy(&escaped_str[escaped], esc, esc_size);
|
||||
escaped += esc_size;
|
||||
break;
|
||||
default:
|
||||
if (g_ascii_isprint(c))
|
||||
escaped_str[escaped++] = c;
|
||||
else {
|
||||
escaped_str[escaped++] = '\\';
|
||||
escaped_str[escaped++] = '0' + ((c >> 6) & 07);
|
||||
escaped_str[escaped++] = '0' + ((c >> 3) & 07);
|
||||
escaped_str[escaped++] = '0' + (c & 07);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
debugf(escaped_str, user_data);
|
||||
g_free(escaped_str);
|
||||
}
|
||||
|
||||
void g_ril_util_debug_dump(gboolean in, const unsigned char *buf, gsize len,
|
||||
GRilDebugFunc debugf, gpointer user_data)
|
||||
{
|
||||
char type = in ? '<' : '>';
|
||||
GString *str;
|
||||
gsize i;
|
||||
|
||||
if (debugf == NULL || !len)
|
||||
return;
|
||||
|
||||
str = g_string_sized_new(1 + (len * 2));
|
||||
if (str == NULL)
|
||||
return;
|
||||
|
||||
g_string_append_c(str, type);
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
g_string_append_printf(str, " %02x", buf[i]);
|
||||
|
||||
debugf(str->str, user_data);
|
||||
g_string_free(str, TRUE);
|
||||
}
|
||||
|
||||
void g_ril_util_debug_hexdump(gboolean in, const unsigned char *buf, gsize len,
|
||||
GRilDebugFunc debugf, gpointer user_data)
|
||||
{
|
||||
static const char hexdigits[] = "0123456789abcdef";
|
||||
char str[68];
|
||||
gsize i;
|
||||
|
||||
if (debugf == NULL || !len)
|
||||
return;
|
||||
|
||||
str[0] = in ? '<' : '>';
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
str[((i % 16) * 3) + 1] = ' ';
|
||||
str[((i % 16) * 3) + 2] = hexdigits[buf[i] >> 4];
|
||||
str[((i % 16) * 3) + 3] = hexdigits[buf[i] & 0xf];
|
||||
str[(i % 16) + 51] = g_ascii_isprint(buf[i]) ? buf[i] : '.';
|
||||
|
||||
if ((i + 1) % 16 == 0) {
|
||||
str[49] = ' ';
|
||||
str[50] = ' ';
|
||||
str[67] = '\0';
|
||||
debugf(str, user_data);
|
||||
str[0] = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
if (i % 16 > 0) {
|
||||
gsize j;
|
||||
for (j = (i % 16); j < 16; j++) {
|
||||
str[(j * 3) + 1] = ' ';
|
||||
str[(j * 3) + 2] = ' ';
|
||||
str[(j * 3) + 3] = ' ';
|
||||
str[j + 51] = ' ';
|
||||
}
|
||||
str[49] = ' ';
|
||||
str[50] = ' ';
|
||||
str[67] = '\0';
|
||||
debugf(str, user_data);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean g_ril_util_setup_io(GIOChannel *io, GIOFlags flags)
|
||||
{
|
||||
GIOFlags io_flags;
|
||||
|
||||
if (g_io_channel_set_encoding(io, NULL, NULL) != G_IO_STATUS_NORMAL)
|
||||
return FALSE;
|
||||
|
||||
g_io_channel_set_buffered(io, FALSE);
|
||||
|
||||
if (flags & G_IO_FLAG_SET_MASK) {
|
||||
io_flags = g_io_channel_get_flags(io);
|
||||
|
||||
io_flags |= (flags & G_IO_FLAG_SET_MASK);
|
||||
|
||||
if (g_io_channel_set_flags(io, io_flags, NULL) !=
|
||||
G_IO_STATUS_NORMAL)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_io_channel_set_close_on_unref(io, TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
*
|
||||
* RIL library with GLib integration
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2012 Canonical Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __GRILUTIL_H
|
||||
#define __GRILUTIL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "gfunc.h"
|
||||
#include "parcel.h"
|
||||
#include "gril.h"
|
||||
|
||||
const char *ril_ofono_protocol_to_ril_string(guint protocol);
|
||||
int ril_protocol_string_to_ofono_protocol(gchar *protocol_str);
|
||||
const char *ril_appstate_to_string(int app_state);
|
||||
const char *ril_apptype_to_string(int app_type);
|
||||
const char *ril_authtype_to_string(int auth_type);
|
||||
const char *ril_cardstate_to_string(int card_state);
|
||||
const char *ril_error_to_string(int error);
|
||||
const char *ril_pinstate_to_string(int pin_state);
|
||||
const char *ril_radio_state_to_string(int radio_state);
|
||||
const char *ril_radio_tech_to_string(int radio_tech);
|
||||
const char *ril_request_id_to_string(int req);
|
||||
const char *ril_unsol_request_to_string(int request);
|
||||
const char *ril_pdp_fail_to_string(int status);
|
||||
|
||||
void g_ril_util_debug_chat(gboolean in, const char *str, gsize len,
|
||||
GRilDebugFunc debugf, gpointer user_data);
|
||||
|
||||
void g_ril_util_debug_dump(gboolean in, const unsigned char *buf, gsize len,
|
||||
GRilDebugFunc debugf, gpointer user_data);
|
||||
|
||||
void g_ril_util_debug_hexdump(gboolean in, const unsigned char *buf, gsize len,
|
||||
GRilDebugFunc debugf, gpointer user_data);
|
||||
|
||||
gboolean g_ril_util_setup_io(GIOChannel *io, GIOFlags flags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __GRILUTIL_H */
|
|
@ -0,0 +1,293 @@
|
|||
/*
|
||||
* Copyright (C) 2011 Joel Armstrong <jcarmst@sandia.gov>
|
||||
* Copyright (C) 2012 Canonical Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License (`GPL') as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* Based on parcel implementation from https://bitbucket.org/floren/inferno
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <ofono/log.h>
|
||||
|
||||
/* Parcel-handling code */
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <endian.h>
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "parcel.h"
|
||||
|
||||
#define PAD_SIZE(s) (((s)+3)&~3)
|
||||
|
||||
typedef uint16_t char16_t;
|
||||
|
||||
void parcel_init(struct parcel *p)
|
||||
{
|
||||
p->data = g_malloc0(sizeof(int32_t));
|
||||
p->size = 0;
|
||||
p->capacity = sizeof(int32_t);
|
||||
p->offset = 0;
|
||||
p->malformed = 0;
|
||||
}
|
||||
|
||||
void parcel_grow(struct parcel *p, size_t size)
|
||||
{
|
||||
char *new = g_realloc(p->data, p->capacity + size);
|
||||
p->data = new;
|
||||
p->capacity += size;
|
||||
}
|
||||
|
||||
void parcel_free(struct parcel *p)
|
||||
{
|
||||
g_free(p->data);
|
||||
p->size = 0;
|
||||
p->capacity = 0;
|
||||
p->offset = 0;
|
||||
}
|
||||
|
||||
int32_t parcel_r_int32(struct parcel *p)
|
||||
{
|
||||
int32_t ret;
|
||||
|
||||
if (p->malformed)
|
||||
return 0;
|
||||
|
||||
if (p->offset + sizeof(int32_t) > p->size) {
|
||||
ofono_error("%s: parcel is too small", __func__);
|
||||
p->malformed = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = *((int32_t *) (void *) (p->data + p->offset));
|
||||
p->offset += sizeof(int32_t);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int parcel_w_int32(struct parcel *p, int32_t val)
|
||||
{
|
||||
for (;;) {
|
||||
|
||||
if (p->offset + sizeof(int32_t) < p->capacity) {
|
||||
/* There's enough space */
|
||||
*((int32_t *) (void *) (p->data + p->offset)) = val;
|
||||
p->offset += sizeof(int32_t);
|
||||
p->size += sizeof(int32_t);
|
||||
break;
|
||||
} else {
|
||||
/* Grow data and retry */
|
||||
parcel_grow(p, sizeof(int32_t));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int parcel_w_string(struct parcel *p, const char *str)
|
||||
{
|
||||
gunichar2 *gs16;
|
||||
glong gs16_len;
|
||||
size_t len;
|
||||
size_t gs16_size;
|
||||
|
||||
if (str == NULL) {
|
||||
parcel_w_int32(p, -1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
gs16 = g_utf8_to_utf16(str, -1, NULL, &gs16_len, NULL);
|
||||
|
||||
if (parcel_w_int32(p, gs16_len) == -1)
|
||||
return -1;
|
||||
|
||||
gs16_size = gs16_len * sizeof(char16_t);
|
||||
len = gs16_size + sizeof(char16_t);
|
||||
for (;;) {
|
||||
size_t padded = PAD_SIZE(len);
|
||||
|
||||
if (p->offset + len < p->capacity) {
|
||||
/* There's enough space */
|
||||
memcpy(p->data + p->offset, gs16, gs16_size);
|
||||
*((char16_t *) (void *)
|
||||
(p->data + p->offset + gs16_size)) = 0;
|
||||
p->offset += padded;
|
||||
p->size += padded;
|
||||
if (padded != len) {
|
||||
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
static const uint32_t mask[4] = {
|
||||
0x00000000, 0xffffff00,
|
||||
0xffff0000, 0xff000000
|
||||
};
|
||||
#endif
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
static const uint32_t mask[4] = {
|
||||
0x00000000, 0x00ffffff,
|
||||
0x0000ffff, 0x000000ff
|
||||
};
|
||||
#endif
|
||||
|
||||
*((uint32_t *) (void *)
|
||||
(p->data + p->offset - 4)) &=
|
||||
mask[padded - len];
|
||||
}
|
||||
break;
|
||||
|
||||
} else {
|
||||
/* Grow data and retry */
|
||||
parcel_grow(p, padded);
|
||||
}
|
||||
}
|
||||
|
||||
g_free(gs16);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *parcel_r_string(struct parcel *p)
|
||||
{
|
||||
char *ret;
|
||||
int len16 = parcel_r_int32(p);
|
||||
int strbytes;
|
||||
|
||||
if (p->malformed)
|
||||
return NULL;
|
||||
|
||||
/* This is how a null string is sent */
|
||||
if (len16 < 0)
|
||||
return NULL;
|
||||
|
||||
strbytes = PAD_SIZE((len16 + 1) * sizeof(char16_t));
|
||||
if (p->offset + strbytes > p->size) {
|
||||
ofono_error("%s: parcel is too small", __func__);
|
||||
p->malformed = 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = g_utf16_to_utf8((gunichar2 *) (void *) (p->data + p->offset),
|
||||
len16, NULL, NULL, NULL);
|
||||
if (ret == NULL) {
|
||||
ofono_error("%s: wrong UTF16 coding", __func__);
|
||||
p->malformed = 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p->offset += strbytes;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int parcel_w_raw(struct parcel *p, const void *data, size_t len)
|
||||
{
|
||||
if (data == NULL) {
|
||||
parcel_w_int32(p, -1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
parcel_w_int32(p, len);
|
||||
|
||||
for (;;) {
|
||||
|
||||
if (p->offset + len < p->capacity) {
|
||||
/* There's enough space */
|
||||
memcpy(p->data + p->offset, data, len);
|
||||
p->offset += len;
|
||||
p->size += len;
|
||||
break;
|
||||
} else {
|
||||
/* Grow data and retry */
|
||||
parcel_grow(p, len);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *parcel_r_raw(struct parcel *p, int *len)
|
||||
{
|
||||
char *ret;
|
||||
|
||||
*len = parcel_r_int32(p);
|
||||
|
||||
if (p->malformed || *len <= 0)
|
||||
return NULL;
|
||||
|
||||
if (p->offset + *len > p->size) {
|
||||
ofono_error("%s: parcel is too small", __func__);
|
||||
p->malformed = 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = g_try_malloc0(*len);
|
||||
if (ret == NULL) {
|
||||
ofono_error("%s: out of memory (%d bytes)", __func__, *len);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(ret, p->data + p->offset, *len);
|
||||
p->offset += *len;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t parcel_data_avail(struct parcel *p)
|
||||
{
|
||||
return p->size - p->offset;
|
||||
}
|
||||
|
||||
struct parcel_str_array *parcel_r_str_array(struct parcel *p)
|
||||
{
|
||||
int i;
|
||||
struct parcel_str_array *str_arr;
|
||||
int num_str = parcel_r_int32(p);
|
||||
|
||||
if (p->malformed || num_str <= 0)
|
||||
return NULL;
|
||||
|
||||
str_arr = g_try_malloc0(sizeof(*str_arr) + num_str * sizeof(char *));
|
||||
if (str_arr == NULL)
|
||||
return NULL;
|
||||
|
||||
str_arr->num_str = num_str;
|
||||
for (i = 0; i < num_str; ++i)
|
||||
str_arr->str[i] = parcel_r_string(p);
|
||||
|
||||
if (p->malformed) {
|
||||
parcel_free_str_array(str_arr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return str_arr;
|
||||
}
|
||||
|
||||
void parcel_free_str_array(struct parcel_str_array *str_arr)
|
||||
{
|
||||
if (str_arr) {
|
||||
int i;
|
||||
for (i = 0; i < str_arr->num_str; ++i)
|
||||
g_free(str_arr->str[i]);
|
||||
g_free(str_arr);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright © 2011 Joel Armstrong <jcarmst@sandia.gov>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License (`GPL') as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* Based on parcel implementation from https://bitbucket.org/floren/inferno
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __PARCEL_H
|
||||
#define __PARCEL_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
struct parcel {
|
||||
char *data;
|
||||
size_t offset;
|
||||
size_t capacity;
|
||||
size_t size;
|
||||
int malformed;
|
||||
};
|
||||
|
||||
struct parcel_str_array {
|
||||
int num_str;
|
||||
char *str[];
|
||||
};
|
||||
|
||||
void parcel_init(struct parcel *p);
|
||||
void parcel_grow(struct parcel *p, size_t size);
|
||||
void parcel_free(struct parcel *p);
|
||||
int32_t parcel_r_int32(struct parcel *p);
|
||||
int parcel_w_int32(struct parcel *p, int32_t val);
|
||||
int parcel_w_string(struct parcel *p, const char *str);
|
||||
char *parcel_r_string(struct parcel *p);
|
||||
int parcel_w_raw(struct parcel *p, const void *data, size_t len);
|
||||
void *parcel_r_raw(struct parcel *p, int *len);
|
||||
size_t parcel_data_avail(struct parcel *p);
|
||||
struct parcel_str_array *parcel_r_str_array(struct parcel *p);
|
||||
void parcel_free_str_array(struct parcel_str_array *str_arr);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,429 @@
|
|||
/*
|
||||
*
|
||||
* RIL constants adopted from AOSP's header:
|
||||
*
|
||||
* /hardware/ril/reference_ril/ril.h
|
||||
*
|
||||
* Copyright (C) 2013 Canonical Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __RIL_CONSTANTS_H
|
||||
#define __RIL_CONSTANTS_H 1
|
||||
#define RIL_VERSION 7
|
||||
|
||||
/* Error Codes */
|
||||
#define RIL_E_SUCCESS 0
|
||||
#define RIL_E_RADIO_NOT_AVAILABLE 1
|
||||
#define RIL_E_GENERIC_FAILURE 2
|
||||
#define RIL_E_PASSWORD_INCORRECT 3
|
||||
#define RIL_E_SIM_PIN2 4
|
||||
#define RIL_E_SIM_PUK2 5
|
||||
#define RIL_E_REQUEST_NOT_SUPPORTED 6
|
||||
#define RIL_E_CANCELLED 7
|
||||
#define RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL 8
|
||||
#define RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW 9
|
||||
#define RIL_E_SMS_SEND_FAIL_RETRY 10
|
||||
#define RIL_E_SIM_ABSENT 11
|
||||
#define RIL_E_SUBSCRIPTION_NOT_AVAILABLE 12
|
||||
#define RIL_E_MODE_NOT_SUPPORTED 13
|
||||
#define RIL_E_FDN_CHECK_FAILURE 14
|
||||
#define RIL_E_ILLEGAL_SIM_OR_ME 15
|
||||
/*
|
||||
* Following error codes are actually Qualcomm-specific, but as they are used by
|
||||
* our reference platform, we consider them valid for vendor
|
||||
* OFONO_RIL_VENDOR_AOSP. The definition comes from cyanogenmod ril.h, which in
|
||||
* turn copied it from codeaurora.
|
||||
*/
|
||||
#define RIL_E_DIAL_MODIFIED_TO_USSD 17
|
||||
#define RIL_E_DIAL_MODIFIED_TO_SS 18
|
||||
#define RIL_E_DIAL_MODIFIED_TO_DIAL 19
|
||||
#define RIL_E_USSD_MODIFIED_TO_DIAL 20
|
||||
#define RIL_E_USSD_MODIFIED_TO_SS 21
|
||||
#define RIL_E_USSD_MODIFIED_TO_USSD 22
|
||||
#define RIL_E_SS_MODIFIED_TO_DIAL 23
|
||||
#define RIL_E_SS_MODIFIED_TO_USSD 24
|
||||
#define RIL_E_SS_MODIFIED_TO_SS 25
|
||||
#define RIL_E_SUBSCRIPTION_NOT_SUPPORTED 26
|
||||
|
||||
/* Preferred network types */
|
||||
#define PREF_NET_TYPE_GSM_WCDMA 0
|
||||
#define PREF_NET_TYPE_GSM_ONLY 1
|
||||
#define PREF_NET_TYPE_WCDMA 2
|
||||
#define PREF_NET_TYPE_GSM_WCDMA_AUTO 3
|
||||
#define PREF_NET_TYPE_CDMA_EVDO_AUTO 4
|
||||
#define PREF_NET_TYPE_CDMA_ONLY 5
|
||||
#define PREF_NET_TYPE_EVDO_ONLY 6
|
||||
#define PREF_NET_TYPE_GSM_WCDMA_CDMA_EVDO_AUTO 7
|
||||
#define PREF_NET_TYPE_LTE_CDMA_EVDO 8
|
||||
#define PREF_NET_TYPE_LTE_GSM_WCDMA 9
|
||||
#define PREF_NET_TYPE_LTE_CMDA_EVDO_GSM_WCDMA 10
|
||||
#define PREF_NET_TYPE_LTE_ONLY 11
|
||||
#define PREF_NET_TYPE_LTE_WCDMA 12
|
||||
/* MTK specific network types */
|
||||
#define MTK_PREF_NET_TYPE_BASE 30
|
||||
#define MTK_PREF_NET_TYPE_LTE_GSM_WCDMA (MTK_PREF_NET_TYPE_BASE + 1)
|
||||
#define MTK_PREF_NET_TYPE_LTE_GSM_WCDMA_MMDC (MTK_PREF_NET_TYPE_BASE + 2)
|
||||
#define MTK_PREF_NET_TYPE_GSM_WCDMA_LTE (MTK_PREF_NET_TYPE_BASE + 3)
|
||||
#define MTK_PREF_NET_TYPE_GSM_WCDMA_LTE_MMDC (MTK_PREF_NET_TYPE_BASE + 4)
|
||||
#define MTK_PREF_NET_TYPE_LTE_GSM_TYPE (MTK_PREF_NET_TYPE_BASE + 5)
|
||||
#define MTK_PREF_NET_TYPE_LTE_GSM_MMDC_TYPE (MTK_PREF_NET_TYPE_BASE + 6)
|
||||
|
||||
/*
|
||||
* Data Call Failure causes ( see TS 24.008 )
|
||||
* section 6.1.3.1.3 or TS 24.301 Release 8+ Annex B.
|
||||
*/
|
||||
#define PDP_FAIL_NONE 0
|
||||
#define PDP_FAIL_OPERATOR_BARRED 0x08
|
||||
#define PDP_FAIL_INSUFFICIENT_RESOURCES 0x1A
|
||||
#define PDP_FAIL_MISSING_UKNOWN_APN 0x1B
|
||||
#define PDP_FAIL_UNKNOWN_PDP_ADDRESS_TYPE 0x1C
|
||||
#define PDP_FAIL_USER_AUTHENTICATION 0x1D
|
||||
#define PDP_FAIL_ACTIVATION_REJECT_GGSN 0x1E
|
||||
#define PDP_FAIL_ACTIVATION_REJECT_UNSPECIFIED 0x1F
|
||||
#define PDP_FAIL_SERVICE_OPTION_NOT_SUPPORTED 0x20
|
||||
#define PDP_FAIL_SERVICE_OPTION_NOT_SUBSCRIBED 0x21
|
||||
#define PDP_FAIL_SERVICE_OPTION_OUT_OF_ORDER 0x22
|
||||
#define PDP_FAIL_NSAPI_IN_USE 0x23
|
||||
#define PDP_FAIL_REGULAR_DEACTIVATION 0x24 /* restart radio */
|
||||
#define PDP_FAIL_ONLY_IPV4_ALLOWED 0x32
|
||||
#define PDP_FAIL_ONLY_IPV6_ALLOWED 0x33
|
||||
#define PDP_FAIL_ONLY_SINGLE_BEARER_ALLOWED 0x34
|
||||
#define PDP_FAIL_PROTOCOL_ERRORS 0x6F
|
||||
#define PDP_FAIL_VOICE_REGISTRATION_FAIL -1
|
||||
#define PDP_FAIL_DATA_REGISTRATION_FAIL -2
|
||||
#define PDP_FAIL_SIGNAL_LOST -3
|
||||
#define PDP_FAIL_PREF_RADIO_TECH_CHANGED -4
|
||||
#define PDP_FAIL_RADIO_POWER_OFF -5
|
||||
#define PDP_FAIL_TETHERED_CALL_ACTIVE -6
|
||||
#define PDP_FAIL_ERROR_UNSPECIFIED 0xffff
|
||||
|
||||
/* Radio States */
|
||||
#define RADIO_STATE_OFF 0
|
||||
#define RADIO_STATE_UNAVAILABLE 1
|
||||
#define RADIO_STATE_ON 10
|
||||
|
||||
/* Deprecated, but still used by some modems */
|
||||
#define RADIO_STATE_SIM_NOT_READY 2
|
||||
#define RADIO_STATE_SIM_LOCKED_OR_ABSENT 3
|
||||
#define RADIO_STATE_SIM_READY 4
|
||||
|
||||
/* Radio technologies */
|
||||
#define RADIO_TECH_UNKNOWN 0
|
||||
#define RADIO_TECH_GPRS 1
|
||||
#define RADIO_TECH_EDGE 2
|
||||
#define RADIO_TECH_UMTS 3
|
||||
#define RADIO_TECH_IS95A 4
|
||||
#define RADIO_TECH_IS95B 5
|
||||
#define RADIO_TECH_1xRTT 6
|
||||
#define RADIO_TECH_EVDO_0 7
|
||||
#define RADIO_TECH_EVDO_A 8
|
||||
#define RADIO_TECH_HSDPA 9
|
||||
#define RADIO_TECH_HSUPA 10
|
||||
#define RADIO_TECH_HSPA 11
|
||||
#define RADIO_TECH_EVDO_B 12
|
||||
#define RADIO_TECH_EHRPD 13
|
||||
#define RADIO_TECH_LTE 14
|
||||
#define RADIO_TECH_HSPAP 15
|
||||
#define RADIO_TECH_GSM 16
|
||||
/* MTK specific values for radio technologies */
|
||||
#define MTK_RADIO_TECH_BASE 128
|
||||
#define MTK_RADIO_TECH_HSDPAP (MTK_RADIO_TECH_BASE + 1)
|
||||
#define MTK_RADIO_TECH_HSDPAP_UPA (MTK_RADIO_TECH_BASE + 2)
|
||||
#define MTK_RADIO_TECH_HSUPAP (MTK_RADIO_TECH_BASE + 3)
|
||||
#define MTK_RADIO_TECH_HSUPAP_DPA (MTK_RADIO_TECH_BASE + 4)
|
||||
#define MTK_RADIO_TECH_DC_DPA (MTK_RADIO_TECH_BASE + 5)
|
||||
#define MTK_RADIO_TECH_DC_UPA (MTK_RADIO_TECH_BASE + 6)
|
||||
#define MTK_RADIO_TECH_DC_HSDPAP (MTK_RADIO_TECH_BASE + 7)
|
||||
#define MTK_RADIO_TECH_DC_HSDPAP_UPA (MTK_RADIO_TECH_BASE + 8)
|
||||
#define MTK_RADIO_TECH_DC_HSDPAP_DPA (MTK_RADIO_TECH_BASE + 9)
|
||||
#define MTK_RADIO_TECH_DC_HSPAP (MTK_RADIO_TECH_BASE + 10)
|
||||
|
||||
/* See RIL_REQUEST_LAST_CALL_FAIL_CAUSE */
|
||||
#define CALL_FAIL_UNOBTAINABLE_NUMBER 1
|
||||
#define CALL_FAIL_NORMAL 16
|
||||
#define CALL_FAIL_BUSY 17
|
||||
#define CALL_FAIL_CONGESTION 34
|
||||
#define CALL_FAIL_ACM_LIMIT_EXCEEDED 68
|
||||
#define CALL_FAIL_CALL_BARRED 240
|
||||
#define CALL_FAIL_FDN_BLOCKED 241
|
||||
#define CALL_FAIL_IMSI_UNKNOWN_IN_VLR 242
|
||||
#define CALL_FAIL_IMEI_NOT_ACCEPTED 243
|
||||
#define CALL_FAIL_DIAL_MODIFIED_TO_USSD 244
|
||||
#define CALL_FAIL_DIAL_MODIFIED_TO_SS 245
|
||||
#define CALL_FAIL_DIAL_MODIFIED_TO_DIAL 246
|
||||
#define CALL_FAIL_CDMA_LOCKED_UNTIL_POWER_CYCLE 1000
|
||||
#define CALL_FAIL_CDMA_DROP 1001
|
||||
#define CALL_FAIL_CDMA_INTERCEPT 1002
|
||||
#define CALL_FAIL_CDMA_REORDER 1003
|
||||
#define CALL_FAIL_CDMA_SO_REJECT 1004
|
||||
#define CALL_FAIL_CDMA_RETRY_ORDER 1005
|
||||
#define CALL_FAIL_CDMA_ACCESS_FAILURE 1006
|
||||
#define CALL_FAIL_CDMA_PREEMPTED 1007
|
||||
#define CALL_FAIL_CDMA_NOT_EMERGENCY 1008
|
||||
#define CALL_FAIL_CDMA_ACCESS_BLOCKED 1009
|
||||
#define CALL_FAIL_ERROR_UNSPECIFIED 0xffff
|
||||
|
||||
/* see RIL_REQUEST_DEACTIVATE_DATA_CALL parameter*/
|
||||
#define RIL_DEACTIVATE_DATA_CALL_NO_REASON 0
|
||||
#define RIL_DEACTIVATE_DATA_CALL_RADIO_SHUTDOWN 1
|
||||
|
||||
/* See RIL_REQUEST_SETUP_DATA_CALL */
|
||||
|
||||
#define RIL_DATA_PROFILE_DEFAULT 0
|
||||
#define RIL_DATA_PROFILE_TETHERED 1
|
||||
#define RIL_DATA_PROFILE_IMS 2
|
||||
#define RIL_DATA_PROFILE_FOTA 3 /* FOTA = Firmware Over the Air */
|
||||
#define RIL_DATA_PROFILE_CBS 4
|
||||
#define RIL_DATA_PROFILE_OEM_BASE 1000 /* Start of OEM-specific profiles */
|
||||
/* MTK specific profile for MMS */
|
||||
#define RIL_DATA_PROFILE_MTK_MMS (RIL_DATA_PROFILE_OEM_BASE + 1)
|
||||
|
||||
/*
|
||||
* auth type -1 seems to mean 0 (RIL_AUTH_NONE) if no user/password is
|
||||
* specified or 3 (RIL_AUTH_BOTH) otherwise. See $ANDROID/packages/
|
||||
* providers/TelephonyProvider/src/com/android/providers/telephony/
|
||||
* TelephonyProvider.java.
|
||||
*/
|
||||
#define RIL_AUTH_ANY -1
|
||||
#define RIL_AUTH_NONE 0
|
||||
#define RIL_AUTH_PAP 1
|
||||
#define RIL_AUTH_CHAP 2
|
||||
#define RIL_AUTH_BOTH 3
|
||||
|
||||
/* SIM card states */
|
||||
#define RIL_CARDSTATE_ABSENT 0
|
||||
#define RIL_CARDSTATE_PRESENT 1
|
||||
#define RIL_CARDSTATE_ERROR 2
|
||||
|
||||
/* SIM - App states */
|
||||
#define RIL_APPSTATE_UNKNOWN 0
|
||||
#define RIL_APPSTATE_DETECTED 1
|
||||
#define RIL_APPSTATE_PIN 2
|
||||
#define RIL_APPSTATE_PUK 3
|
||||
#define RIL_APPSTATE_SUBSCRIPTION_PERSO 4
|
||||
#define RIL_APPSTATE_READY 5
|
||||
|
||||
/* SIM - PIN states */
|
||||
#define RIL_PINSTATE_UNKNOWN 0
|
||||
#define RIL_PINSTATE_ENABLED_NOT_VERIFIED 1
|
||||
#define RIL_PINSTATE_ENABLED_VERIFIED 2
|
||||
#define RIL_PINSTATE_DISABLED 3
|
||||
#define RIL_PINSTATE_ENABLED_BLOCKED 4
|
||||
#define RIL_PINSTATE_ENABLED_PERM_BLOCKED 5
|
||||
|
||||
/* SIM - App types */
|
||||
#define RIL_APPTYPE_UNKNOWN 0
|
||||
#define RIL_APPTYPE_SIM 1
|
||||
#define RIL_APPTYPE_USIM 2
|
||||
#define RIL_APPTYPE_RUIM 3
|
||||
#define RIL_APPTYPE_CSIM 4
|
||||
#define RIL_APPTYPE_ISIM 5
|
||||
|
||||
/* SIM - PersoSubstate */
|
||||
#define RIL_PERSOSUBSTATE_UNKNOWN 0
|
||||
#define RIL_PERSOSUBSTATE_IN_PROGRESS 1
|
||||
#define RIL_PERSOSUBSTATE_READY 2
|
||||
#define RIL_PERSOSUBSTATE_SIM_NETWORK 3
|
||||
#define RIL_PERSOSUBSTATE_SIM_NETWORK_SUBSET 4
|
||||
#define RIL_PERSOSUBSTATE_SIM_CORPORATE 5
|
||||
#define RIL_PERSOSUBSTATE_SIM_SERVICE_PROVIDER 6
|
||||
#define RIL_PERSOSUBSTATE_SIM_SIM 7
|
||||
#define RIL_PERSOSUBSTATE_SIM_NETWORK_PUK 8
|
||||
#define RIL_PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK 9
|
||||
#define RIL_PERSOSUBSTATE_SIM_CORPORATE_PUK 10
|
||||
#define RIL_PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK 11
|
||||
#define RIL_PERSOSUBSTATE_SIM_SIM_PUK 12
|
||||
#define RIL_PERSOSUBSTATE_RUIM_NETWORK1 13
|
||||
#define RIL_PERSOSUBSTATE_RUIM_NETWORK2 14
|
||||
#define RIL_PERSOSUBSTATE_RUIM_HRPD 15
|
||||
#define RIL_PERSOSUBSTATE_RUIM_CORPORATE 16
|
||||
#define RIL_PERSOSUBSTATE_RUIM_SERVICE_PROVIDER 17
|
||||
#define RIL_PERSOSUBSTATE_RUIM_RUIM 18
|
||||
#define RIL_PERSOSUBSTATE_RUIM_NETWORK1_PUK 19
|
||||
#define RIL_PERSOSUBSTATE_RUIM_NETWORK2_PUK 20
|
||||
#define RIL_PERSOSUBSTATE_RUIM_HRPD_PUK 21
|
||||
#define RIL_PERSOSUBSTATE_RUIM_CORPORATE_PUK 22
|
||||
#define RIL_PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_PUK 23
|
||||
#define RIL_PERSOSUBSTATE_RUIM_RUIM_PUK 24
|
||||
|
||||
/* RIL Request Messages */
|
||||
#define RIL_REQUEST_GET_SIM_STATUS 1
|
||||
#define RIL_REQUEST_ENTER_SIM_PIN 2
|
||||
#define RIL_REQUEST_ENTER_SIM_PUK 3
|
||||
#define RIL_REQUEST_ENTER_SIM_PIN2 4
|
||||
#define RIL_REQUEST_ENTER_SIM_PUK2 5
|
||||
#define RIL_REQUEST_CHANGE_SIM_PIN 6
|
||||
#define RIL_REQUEST_CHANGE_SIM_PIN2 7
|
||||
#define RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION 8
|
||||
#define RIL_REQUEST_GET_CURRENT_CALLS 9
|
||||
#define RIL_REQUEST_DIAL 10
|
||||
#define RIL_REQUEST_GET_IMSI 11
|
||||
#define RIL_REQUEST_HANGUP 12
|
||||
#define RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND 13
|
||||
#define RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND 14
|
||||
#define RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE 15
|
||||
#define RIL_REQUEST_SWITCH_HOLDING_AND_ACTIVE 15
|
||||
#define RIL_REQUEST_CONFERENCE 16
|
||||
#define RIL_REQUEST_UDUB 17
|
||||
#define RIL_REQUEST_LAST_CALL_FAIL_CAUSE 18
|
||||
#define RIL_REQUEST_SIGNAL_STRENGTH 19
|
||||
#define RIL_REQUEST_VOICE_REGISTRATION_STATE 20
|
||||
#define RIL_REQUEST_DATA_REGISTRATION_STATE 21
|
||||
#define RIL_REQUEST_OPERATOR 22
|
||||
#define RIL_REQUEST_RADIO_POWER 23
|
||||
#define RIL_REQUEST_DTMF 24
|
||||
#define RIL_REQUEST_SEND_SMS 25
|
||||
#define RIL_REQUEST_SEND_SMS_EXPECT_MORE 26
|
||||
#define RIL_REQUEST_SETUP_DATA_CALL 27
|
||||
#define RIL_REQUEST_SIM_IO 28
|
||||
#define RIL_REQUEST_SEND_USSD 29
|
||||
#define RIL_REQUEST_CANCEL_USSD 30
|
||||
#define RIL_REQUEST_GET_CLIR 31
|
||||
#define RIL_REQUEST_SET_CLIR 32
|
||||
#define RIL_REQUEST_QUERY_CALL_FORWARD_STATUS 33
|
||||
#define RIL_REQUEST_SET_CALL_FORWARD 34
|
||||
#define RIL_REQUEST_QUERY_CALL_WAITING 35
|
||||
#define RIL_REQUEST_SET_CALL_WAITING 36
|
||||
#define RIL_REQUEST_SMS_ACKNOWLEDGE 37
|
||||
#define RIL_REQUEST_GET_IMEI 38
|
||||
#define RIL_REQUEST_GET_IMEISV 39
|
||||
#define RIL_REQUEST_ANSWER 40
|
||||
#define RIL_REQUEST_DEACTIVATE_DATA_CALL 41
|
||||
#define RIL_REQUEST_QUERY_FACILITY_LOCK 42
|
||||
#define RIL_REQUEST_SET_FACILITY_LOCK 43
|
||||
#define RIL_REQUEST_CHANGE_BARRING_PASSWORD 44
|
||||
#define RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE 45
|
||||
#define RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC 46
|
||||
#define RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL 47
|
||||
#define RIL_REQUEST_QUERY_AVAILABLE_NETWORKS 48
|
||||
#define RIL_REQUEST_DTMF_START 49
|
||||
#define RIL_REQUEST_DTMF_STOP 50
|
||||
#define RIL_REQUEST_BASEBAND_VERSION 51
|
||||
#define RIL_REQUEST_SEPARATE_CONNECTION 52
|
||||
#define RIL_REQUEST_SET_MUTE 53
|
||||
#define RIL_REQUEST_GET_MUTE 54
|
||||
#define RIL_REQUEST_QUERY_CLIP 55
|
||||
#define RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE 56
|
||||
#define RIL_REQUEST_DATA_CALL_LIST 57
|
||||
#define RIL_REQUEST_RESET_RADIO 58
|
||||
#define RIL_REQUEST_OEM_HOOK_RAW 59
|
||||
#define RIL_REQUEST_OEM_HOOK_STRINGS 60
|
||||
#define RIL_REQUEST_SCREEN_STATE 61
|
||||
#define RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION 62
|
||||
#define RIL_REQUEST_WRITE_SMS_TO_SIM 63
|
||||
#define RIL_REQUEST_DELETE_SMS_ON_SIM 64
|
||||
#define RIL_REQUEST_SET_BAND_MODE 65
|
||||
#define RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE 66
|
||||
#define RIL_REQUEST_STK_GET_PROFILE 67
|
||||
#define RIL_REQUEST_STK_SET_PROFILE 68
|
||||
#define RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND 69
|
||||
#define RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE 70
|
||||
#define RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM 71
|
||||
#define RIL_REQUEST_EXPLICIT_CALL_TRANSFER 72
|
||||
#define RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE 73
|
||||
#define RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE 74
|
||||
#define RIL_REQUEST_GET_NEIGHBORING_CELL_IDS 75
|
||||
#define RIL_REQUEST_SET_LOCATION_UPDATES 76
|
||||
#define RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE 77
|
||||
#define RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE 78
|
||||
#define RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE 79
|
||||
#define RIL_REQUEST_SET_TTY_MODE 80
|
||||
#define RIL_REQUEST_QUERY_TTY_MODE 81
|
||||
#define RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE 82
|
||||
#define RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE 83
|
||||
#define RIL_REQUEST_CDMA_FLASH 84
|
||||
#define RIL_REQUEST_CDMA_BURST_DTMF 85
|
||||
#define RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY 86
|
||||
#define RIL_REQUEST_CDMA_SEND_SMS 87
|
||||
#define RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE 88
|
||||
#define RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG 89
|
||||
#define RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG 90
|
||||
#define RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION 91
|
||||
#define RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG 92
|
||||
#define RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG 93
|
||||
#define RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION 94
|
||||
#define RIL_REQUEST_CDMA_SUBSCRIPTION 95
|
||||
#define RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM 96
|
||||
#define RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM 97
|
||||
#define RIL_REQUEST_DEVICE_IDENTITY 98
|
||||
#define RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE 99
|
||||
#define RIL_REQUEST_GET_SMSC_ADDRESS 100
|
||||
#define RIL_REQUEST_SET_SMSC_ADDRESS 101
|
||||
#define RIL_REQUEST_REPORT_SMS_MEMORY_STATUS 102
|
||||
#define RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING 103
|
||||
#define RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE 104
|
||||
#define RIL_REQUEST_ISIM_AUTHENTICATION 105
|
||||
#define RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU 106
|
||||
#define RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS 107
|
||||
#define RIL_REQUEST_VOICE_RADIO_TECH 108
|
||||
#define RIL_REQUEST_SET_INITIAL_ATTACH_APN 111
|
||||
|
||||
/* RIL Unsolicited Messages */
|
||||
#define RIL_UNSOL_RESPONSE_BASE 1000
|
||||
#define RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED 1000
|
||||
#define RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED 1001
|
||||
#define RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED 1002
|
||||
#define RIL_UNSOL_RESPONSE_NEW_SMS 1003
|
||||
#define RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT 1004
|
||||
#define RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM 1005
|
||||
#define RIL_UNSOL_ON_USSD 1006
|
||||
#define RIL_UNSOL_ON_USSD_REQUEST 1007
|
||||
#define RIL_UNSOL_NITZ_TIME_RECEIVED 1008
|
||||
#define RIL_UNSOL_SIGNAL_STRENGTH 1009
|
||||
#define RIL_UNSOL_DATA_CALL_LIST_CHANGED 1010
|
||||
#define RIL_UNSOL_SUPP_SVC_NOTIFICATION 1011
|
||||
#define RIL_UNSOL_STK_SESSION_END 1012
|
||||
#define RIL_UNSOL_STK_PROACTIVE_COMMAND 1013
|
||||
#define RIL_UNSOL_STK_EVENT_NOTIFY 1014
|
||||
#define RIL_UNSOL_STK_CALL_SETUP 1015
|
||||
#define RIL_UNSOL_SIM_SMS_STORAGE_FULL 1016
|
||||
#define RIL_UNSOL_SIM_REFRESH 1017
|
||||
#define RIL_UNSOL_CALL_RING 1018
|
||||
#define RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED 1019
|
||||
#define RIL_UNSOL_RESPONSE_CDMA_NEW_SMS 1020
|
||||
#define RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS 1021
|
||||
#define RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL 1022
|
||||
#define RIL_UNSOL_RESTRICTED_STATE_CHANGED 1023
|
||||
#define RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE 1024
|
||||
#define RIL_UNSOL_CDMA_CALL_WAITING 1025
|
||||
#define RIL_UNSOL_CDMA_OTA_PROVISION_STATUS 1026
|
||||
#define RIL_UNSOL_CDMA_INFO_REC 1027
|
||||
#define RIL_UNSOL_OEM_HOOK_RAW 1028
|
||||
#define RIL_UNSOL_RINGBACK_TONE 1029
|
||||
#define RIL_UNSOL_RESEND_INCALL_MUTE 1030
|
||||
#define RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED 1031
|
||||
#define RIL_UNSOL_CDMA_PRL_CHANGED 1032
|
||||
#define RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE 1033
|
||||
#define RIL_UNSOL_RIL_CONNECTED 1034
|
||||
#define RIL_UNSOL_VOICE_RADIO_TECH_CHANGED 1035
|
||||
|
||||
/* Suplementary services Service class*/
|
||||
#define SERVICE_CLASS_NONE 0
|
||||
|
||||
/* Network registration states */
|
||||
#define RIL_REG_STATE_NOT_REGISTERED 0
|
||||
#define RIL_REG_STATE_REGISTERED 1
|
||||
#define RIL_REG_STATE_SEARCHING 2
|
||||
#define RIL_REG_STATE_DENIED 3
|
||||
#define RIL_REG_STATE_UNKNOWN 4
|
||||
#define RIL_REG_STATE_ROAMING 5
|
||||
#define RIL_REG_STATE_EMERGENCY_NOT_REGISTERED 10
|
||||
#define RIL_REG_STATE_EMERGENCY_SEARCHING 12
|
||||
#define RIL_REG_STATE_EMERGENCY_DENIED 13
|
||||
#define RIL_REG_STATE_EMERGENCY_UNKNOWN 14
|
||||
|
||||
#endif /*__RIL_CONSTANTS_H*/
|
Loading…
Reference in New Issue