From 8395da10102d4a249e67d3fc99ce50111eab24f8 Mon Sep 17 00:00:00 2001 From: Daniel Hillenbrand Date: Tue, 9 Apr 2013 00:17:00 +0000 Subject: i9300: add opensource libril, remove ril class - remove blob rild - remove blob libril.so Change-Id: Iced6c86e5af2a2d65076d12fc150ebc6c4d786a4 --- BoardConfig.mk | 4 + i9300.mk | 1 - include/hardware/gps.h | 686 +++++++ include/telephony/ril.h | 4069 +++++++++++++++++++++++++++++++++++++++++ libril/Android.mk | 47 + libril/MODULE_LICENSE_APACHE2 | 0 libril/NOTICE | 190 ++ libril/ril.cpp | 3591 ++++++++++++++++++++++++++++++++++++ libril/ril_commands.h | 125 ++ libril/ril_event.cpp | 385 ++++ libril/ril_event.h | 52 + libril/ril_unsol_commands.h | 52 + proprietary-files.txt | 2 - 13 files changed, 9201 insertions(+), 3 deletions(-) create mode 100644 include/hardware/gps.h create mode 100644 include/telephony/ril.h create mode 100644 libril/Android.mk create mode 100644 libril/MODULE_LICENSE_APACHE2 create mode 100644 libril/NOTICE create mode 100644 libril/ril.cpp create mode 100644 libril/ril_commands.h create mode 100644 libril/ril_event.cpp create mode 100644 libril/ril_event.h create mode 100644 libril/ril_unsol_commands.h diff --git a/BoardConfig.mk b/BoardConfig.mk index a382193..35d26e0 100644 --- a/BoardConfig.mk +++ b/BoardConfig.mk @@ -19,6 +19,10 @@ -include device/samsung/smdk4412-common/BoardCommonConfig.mk +# RIL +BOARD_PROVIDES_LIBRIL := true +TARGET_SPECIFIC_HEADER_PATH := device/samsung/i9300/include + # Bluetooth BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := device/samsung/i9300/bluetooth diff --git a/i9300.mk b/i9300.mk index 990c890..feaafb2 100644 --- a/i9300.mk +++ b/i9300.mk @@ -79,7 +79,6 @@ $(call inherit-product, vendor/cm/config/nfc_enhanced.mk) # RIL PRODUCT_PROPERTY_OVERRIDES += \ - ro.telephony.ril_class=SamsungExynos4RIL \ mobiledata.interfaces=pdp0,wlan0,gprs,ppp0 \ ro.ril.hsxpa=1 \ ro.ril.gprsclass=10 diff --git a/include/hardware/gps.h b/include/hardware/gps.h new file mode 100644 index 0000000..05b3b11 --- /dev/null +++ b/include/hardware/gps.h @@ -0,0 +1,686 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_INCLUDE_HARDWARE_GPS_H +#define ANDROID_INCLUDE_HARDWARE_GPS_H + +#include +#include +#include +#include + +#include + +__BEGIN_DECLS + +/** + * The id of this module + */ +#define GPS_HARDWARE_MODULE_ID "gps" + + +/** Milliseconds since January 1, 1970 */ +typedef int64_t GpsUtcTime; + +/** Maximum number of SVs for gps_sv_status_callback(). */ +#define GPS_MAX_SVS 32 + +/** Requested operational mode for GPS operation. */ +typedef uint32_t GpsPositionMode; +// IMPORTANT: Note that the following values must match +// constants in GpsLocationProvider.java. +/** Mode for running GPS standalone (no assistance). */ +#define GPS_POSITION_MODE_STANDALONE 0 +/** AGPS MS-Based mode. */ +#define GPS_POSITION_MODE_MS_BASED 1 +/** AGPS MS-Assisted mode. */ +#define GPS_POSITION_MODE_MS_ASSISTED 2 + +/** Requested recurrence mode for GPS operation. */ +typedef uint32_t GpsPositionRecurrence; +// IMPORTANT: Note that the following values must match +// constants in GpsLocationProvider.java. +/** Receive GPS fixes on a recurring basis at a specified period. */ +#define GPS_POSITION_RECURRENCE_PERIODIC 0 +/** Request a single shot GPS fix. */ +#define GPS_POSITION_RECURRENCE_SINGLE 1 + +/** GPS status event values. */ +typedef uint16_t GpsStatusValue; +// IMPORTANT: Note that the following values must match +// constants in GpsLocationProvider.java. +/** GPS status unknown. */ +#define GPS_STATUS_NONE 0 +/** GPS has begun navigating. */ +#define GPS_STATUS_SESSION_BEGIN 1 +/** GPS has stopped navigating. */ +#define GPS_STATUS_SESSION_END 2 +/** GPS has powered on but is not navigating. */ +#define GPS_STATUS_ENGINE_ON 3 +/** GPS is powered off. */ +#define GPS_STATUS_ENGINE_OFF 4 + +/** Flags to indicate which values are valid in a GpsLocation. */ +typedef uint16_t GpsLocationFlags; +// IMPORTANT: Note that the following values must match +// constants in GpsLocationProvider.java. +/** GpsLocation has valid latitude and longitude. */ +#define GPS_LOCATION_HAS_LAT_LONG 0x0001 +/** GpsLocation has valid altitude. */ +#define GPS_LOCATION_HAS_ALTITUDE 0x0002 +/** GpsLocation has valid speed. */ +#define GPS_LOCATION_HAS_SPEED 0x0004 +/** GpsLocation has valid bearing. */ +#define GPS_LOCATION_HAS_BEARING 0x0008 +/** GpsLocation has valid accuracy. */ +#define GPS_LOCATION_HAS_ACCURACY 0x0010 + +/** Flags for the gps_set_capabilities callback. */ + +/** GPS HAL schedules fixes for GPS_POSITION_RECURRENCE_PERIODIC mode. + If this is not set, then the framework will use 1000ms for min_interval + and will start and call start() and stop() to schedule the GPS. + */ +#define GPS_CAPABILITY_SCHEDULING 0x0000001 +/** GPS supports MS-Based AGPS mode */ +#define GPS_CAPABILITY_MSB 0x0000002 +/** GPS supports MS-Assisted AGPS mode */ +#define GPS_CAPABILITY_MSA 0x0000004 +/** GPS supports single-shot fixes */ +#define GPS_CAPABILITY_SINGLE_SHOT 0x0000008 +/** GPS supports on demand time injection */ +#define GPS_CAPABILITY_ON_DEMAND_TIME 0x0000010 + +/** Flags used to specify which aiding data to delete + when calling delete_aiding_data(). */ +typedef uint16_t GpsAidingData; +// IMPORTANT: Note that the following values must match +// constants in GpsLocationProvider.java. +#define GPS_DELETE_EPHEMERIS 0x0001 +#define GPS_DELETE_ALMANAC 0x0002 +#define GPS_DELETE_POSITION 0x0004 +#define GPS_DELETE_TIME 0x0008 +#define GPS_DELETE_IONO 0x0010 +#define GPS_DELETE_UTC 0x0020 +#define GPS_DELETE_HEALTH 0x0040 +#define GPS_DELETE_SVDIR 0x0080 +#define GPS_DELETE_SVSTEER 0x0100 +#define GPS_DELETE_SADATA 0x0200 +#define GPS_DELETE_RTI 0x0400 +#define GPS_DELETE_CELLDB_INFO 0x8000 +#define GPS_DELETE_ALL 0xFFFF + +/** AGPS type */ +typedef uint16_t AGpsType; +#define AGPS_TYPE_SUPL 1 +#define AGPS_TYPE_C2K 2 + +typedef uint16_t AGpsSetIDType; +#define AGPS_SETID_TYPE_NONE 0 +#define AGPS_SETID_TYPE_IMSI 1 +#define AGPS_SETID_TYPE_MSISDN 2 + +/** + * String length constants + */ +#define GPS_NI_SHORT_STRING_MAXLEN 256 +#define GPS_NI_LONG_STRING_MAXLEN 2048 + +/** + * GpsNiType constants + */ +typedef uint32_t GpsNiType; +#define GPS_NI_TYPE_VOICE 1 +#define GPS_NI_TYPE_UMTS_SUPL 2 +#define GPS_NI_TYPE_UMTS_CTRL_PLANE 3 + +/** + * GpsNiNotifyFlags constants + */ +typedef uint32_t GpsNiNotifyFlags; +/** NI requires notification */ +#define GPS_NI_NEED_NOTIFY 0x0001 +/** NI requires verification */ +#define GPS_NI_NEED_VERIFY 0x0002 +/** NI requires privacy override, no notification/minimal trace */ +#define GPS_NI_PRIVACY_OVERRIDE 0x0004 + +/** + * GPS NI responses, used to define the response in + * NI structures + */ +typedef int GpsUserResponseType; +#define GPS_NI_RESPONSE_ACCEPT 1 +#define GPS_NI_RESPONSE_DENY 2 +#define GPS_NI_RESPONSE_NORESP 3 + +/** + * NI data encoding scheme + */ +typedef int GpsNiEncodingType; +#define GPS_ENC_NONE 0 +#define GPS_ENC_SUPL_GSM_DEFAULT 1 +#define GPS_ENC_SUPL_UTF8 2 +#define GPS_ENC_SUPL_UCS2 3 +#define GPS_ENC_UNKNOWN -1 + +/** AGPS status event values. */ +typedef uint16_t AGpsStatusValue; +/** GPS requests data connection for AGPS. */ +#define GPS_REQUEST_AGPS_DATA_CONN 1 +/** GPS releases the AGPS data connection. */ +#define GPS_RELEASE_AGPS_DATA_CONN 2 +/** AGPS data connection initiated */ +#define GPS_AGPS_DATA_CONNECTED 3 +/** AGPS data connection completed */ +#define GPS_AGPS_DATA_CONN_DONE 4 +/** AGPS data connection failed */ +#define GPS_AGPS_DATA_CONN_FAILED 5 + +#define AGPS_REF_LOCATION_TYPE_GSM_CELLID 1 +#define AGPS_REF_LOCATION_TYPE_UMTS_CELLID 2 +#define AGPS_REG_LOCATION_TYPE_MAC 3 + +/** Network types for update_network_state "type" parameter */ +#define AGPS_RIL_NETWORK_TYPE_MOBILE 0 +#define AGPS_RIL_NETWORK_TYPE_WIFI 1 +#define AGPS_RIL_NETWORK_TYPE_MOBILE_MMS 2 +#define AGPS_RIL_NETWORK_TYPE_MOBILE_SUPL 3 +#define AGPS_RIL_NETWORK_TTYPE_MOBILE_DUN 4 +#define AGPS_RIL_NETWORK_TTYPE_MOBILE_HIPRI 5 +#define AGPS_RIL_NETWORK_TTYPE_WIMAX 6 + +/** + * Name for the GPS XTRA interface. + */ +#define GPS_XTRA_INTERFACE "gps-xtra" + +/** + * Name for the GPS DEBUG interface. + */ +#define GPS_DEBUG_INTERFACE "gps-debug" + +/** + * Name for the AGPS interface. + */ +#define AGPS_INTERFACE "agps" + +/** + * Name for NI interface + */ +#define GPS_NI_INTERFACE "gps-ni" + +/** + * Name for the AGPS-RIL interface. + */ +#define AGPS_RIL_INTERFACE "agps_ril" + +/** Represents a location. */ +typedef struct { + /** set to sizeof(GpsLocation) */ + size_t size; + /** Contains GpsLocationFlags bits. */ + uint16_t flags; + /** Represents latitude in degrees. */ + double latitude; + /** Represents longitude in degrees. */ + double longitude; + /** Represents altitude in meters above the WGS 84 reference + * ellipsoid. */ + double altitude; + /** Represents speed in meters per second. */ + float speed; + /** Represents heading in degrees. */ + float bearing; + /** Represents expected accuracy in meters. */ + float accuracy; + /** Timestamp for the location fix. */ + GpsUtcTime timestamp; +} GpsLocation; + +/** Represents the status. */ +typedef struct { + /** set to sizeof(GpsStatus) */ + size_t size; + GpsStatusValue status; +} GpsStatus; + +/** Represents SV information. */ +typedef struct { + /** set to sizeof(GpsSvInfo) */ + size_t size; + /** Pseudo-random number for the SV. */ + int prn; + /** Signal to noise ratio. */ + float snr; + /** Elevation of SV in degrees. */ + float elevation; + /** Azimuth of SV in degrees. */ + float azimuth; + /** Unknown field in Samsung I9100 libgps + May be an indicator for constellation type + (GPS, GLONASS, Galileo)? + Used on GT-I9100, likely also present on GT-N7000, + SGH-I717, SGH-I727 but this needs confirmation. + */ + int unknown_samsung_field; +} GpsSvInfo; + +/** Represents SV status. */ +typedef struct { + /** set to sizeof(GpsSvStatus) */ + size_t size; + + /** Number of SVs currently visible. */ + int num_svs; + + /** Contains an array of SV information. */ + GpsSvInfo sv_list[GPS_MAX_SVS]; + + /** Represents a bit mask indicating which SVs + * have ephemeris data. + */ + uint32_t ephemeris_mask; + + /** Represents a bit mask indicating which SVs + * have almanac data. + */ + uint32_t almanac_mask; + + /** + * Represents a bit mask indicating which SVs + * were used for computing the most recent position fix. + */ + uint32_t used_in_fix_mask; +} GpsSvStatus; + +/* 2G and 3G */ +/* In 3G lac is discarded */ +typedef struct { + uint16_t type; + uint16_t mcc; + uint16_t mnc; + uint16_t lac; + uint32_t cid; +} AGpsRefLocationCellID; + +typedef struct { + uint8_t mac[6]; +} AGpsRefLocationMac; + +/** Represents ref locations */ +typedef struct { + uint16_t type; + union { + AGpsRefLocationCellID cellID; + AGpsRefLocationMac mac; + } u; +} AGpsRefLocation; + +/** Callback with location information. + * Can only be called from a thread created by create_thread_cb. + */ +typedef void (* gps_location_callback)(GpsLocation* location); + +/** Callback with status information. + * Can only be called from a thread created by create_thread_cb. + */ +typedef void (* gps_status_callback)(GpsStatus* status); + +/** Callback with SV status information. + * Can only be called from a thread created by create_thread_cb. + */ +typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info); + +/** Callback for reporting NMEA sentences. + * Can only be called from a thread created by create_thread_cb. + */ +typedef void (* gps_nmea_callback)(GpsUtcTime timestamp, const char* nmea, int length); + +/** Callback to inform framework of the GPS engine's capabilities. + * Capability parameter is a bit field of GPS_CAPABILITY_* flags. + */ +typedef void (* gps_set_capabilities)(uint32_t capabilities); + +/** Callback utility for acquiring the GPS wakelock. + * This can be used to prevent the CPU from suspending while handling GPS events. + */ +typedef void (* gps_acquire_wakelock)(); + +/** Callback utility for releasing the GPS wakelock. */ +typedef void (* gps_release_wakelock)(); + +/** Callback for requesting NTP time */ +typedef void (* gps_request_utc_time)(); + +/** Callback for creating a thread that can call into the Java framework code. + * This must be used to create any threads that report events up to the framework. + */ +typedef pthread_t (* gps_create_thread)(const char* name, void (*start)(void *), void* arg); + +/** GPS callback structure. */ +typedef struct { + /** set to sizeof(GpsCallbacks) */ + size_t size; + gps_location_callback location_cb; + gps_status_callback status_cb; + gps_sv_status_callback sv_status_cb; + gps_nmea_callback nmea_cb; + gps_set_capabilities set_capabilities_cb; + gps_acquire_wakelock acquire_wakelock_cb; + gps_release_wakelock release_wakelock_cb; + gps_create_thread create_thread_cb; + gps_request_utc_time request_utc_time_cb; +} GpsCallbacks; + + +/** Represents the standard GPS interface. */ +typedef struct { + /** set to sizeof(GpsInterface) */ + size_t size; + /** + * Opens the interface and provides the callback routines + * to the implemenation of this interface. + */ + int (*init)( GpsCallbacks* callbacks ); + + /** Starts navigating. */ + int (*start)( void ); + + /** Stops navigating. */ + int (*stop)( void ); + + /** Closes the interface. */ + void (*cleanup)( void ); + + /** Injects the current time. */ + int (*inject_time)(GpsUtcTime time, int64_t timeReference, + int uncertainty); + + /** Injects current location from another location provider + * (typically cell ID). + * latitude and longitude are measured in degrees + * expected accuracy is measured in meters + */ + int (*inject_location)(double latitude, double longitude, float accuracy); + + /** + * Specifies that the next call to start will not use the + * information defined in the flags. GPS_DELETE_ALL is passed for + * a cold start. + */ + void (*delete_aiding_data)(GpsAidingData flags); + + /** + * min_interval represents the time between fixes in milliseconds. + * preferred_accuracy represents the requested fix accuracy in meters. + * preferred_time represents the requested time to first fix in milliseconds. + */ + int (*set_position_mode)(GpsPositionMode mode, GpsPositionRecurrence recurrence, + uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time); + + /** Get a pointer to extension information. */ + const void* (*get_extension)(const char* name); +} GpsInterface; + +/** Callback to request the client to download XTRA data. + * The client should download XTRA data and inject it by calling inject_xtra_data(). + * Can only be called from a thread created by create_thread_cb. + */ +typedef void (* gps_xtra_download_request)(); + +/** Callback structure for the XTRA interface. */ +typedef struct { + gps_xtra_download_request download_request_cb; + gps_create_thread create_thread_cb; +} GpsXtraCallbacks; + +/** Extended interface for XTRA support. */ +typedef struct { + /** set to sizeof(GpsXtraInterface) */ + size_t size; + /** + * Opens the XTRA interface and provides the callback routines + * to the implemenation of this interface. + */ + int (*init)( GpsXtraCallbacks* callbacks ); + /** Injects XTRA data into the GPS. */ + int (*inject_xtra_data)( char* data, int length ); +} GpsXtraInterface; + +/** Extended interface for DEBUG support. */ +typedef struct { + /** set to sizeof(GpsDebugInterface) */ + size_t size; + + /** + * This function should return any information that the native + * implementation wishes to include in a bugreport. + */ + size_t (*get_internal_state)(char* buffer, size_t bufferSize); +} GpsDebugInterface; + +/** Represents the status of AGPS. */ +typedef struct { + /** set to sizeof(AGpsStatus) */ + size_t size; + + AGpsType type; + AGpsStatusValue status; + uint32_t ipaddr; +} AGpsStatus; + +/** Callback with AGPS status information. + * Can only be called from a thread created by create_thread_cb. + */ +typedef void (* agps_status_callback)(AGpsStatus* status); + +/** Callback structure for the AGPS interface. */ +typedef struct { + agps_status_callback status_cb; + gps_create_thread create_thread_cb; +} AGpsCallbacks; + + +/** Extended interface for AGPS support. */ +typedef struct { + /** set to sizeof(AGpsInterface) */ + size_t size; + + /** + * Opens the AGPS interface and provides the callback routines + * to the implemenation of this interface. + */ + void (*init)( AGpsCallbacks* callbacks ); + /** + * Notifies that a data connection is available and sets + * the name of the APN to be used for SUPL. + */ + int (*data_conn_open)( const char* apn ); + /** + * Notifies that the AGPS data connection has been closed. + */ + int (*data_conn_closed)(); + /** + * Notifies that a data connection is not available for AGPS. + */ + int (*data_conn_failed)(); + /** + * Sets the hostname and port for the AGPS server. + */ + int (*set_server)( AGpsType type, const char* hostname, int port ); +} AGpsInterface; + + +/** Represents an NI request */ +typedef struct { + /** set to sizeof(GpsNiNotification) */ + size_t size; + + /** + * An ID generated by HAL to associate NI notifications and UI + * responses + */ + int notification_id; + + /** + * An NI type used to distinguish different categories of NI + * events, such as GPS_NI_TYPE_VOICE, GPS_NI_TYPE_UMTS_SUPL, ... + */ + GpsNiType ni_type; + + /** + * Notification/verification options, combinations of GpsNiNotifyFlags constants + */ + GpsNiNotifyFlags notify_flags; + + /** + * Timeout period to wait for user response. + * Set to 0 for no time out limit. + */ + int timeout; + + /** + * Default response when time out. + */ + GpsUserResponseType default_response; + + /** + * Requestor ID + */ + char requestor_id[GPS_NI_SHORT_STRING_MAXLEN]; + + /** + * Notification message. It can also be used to store client_id in some cases + */ + char text[GPS_NI_LONG_STRING_MAXLEN]; + + /** + * Client name decoding scheme + */ + GpsNiEncodingType requestor_id_encoding; + + /** + * Client name decoding scheme + */ + GpsNiEncodingType text_encoding; + + /** + * A pointer to extra data. Format: + * key_1 = value_1 + * key_2 = value_2 + */ + char extras[GPS_NI_LONG_STRING_MAXLEN]; + +} GpsNiNotification; + +/** Callback with NI notification. + * Can only be called from a thread created by create_thread_cb. + */ +typedef void (*gps_ni_notify_callback)(GpsNiNotification *notification); + +/** GPS NI callback structure. */ +typedef struct +{ + /** + * Sends the notification request from HAL to GPSLocationProvider. + */ + gps_ni_notify_callback notify_cb; + gps_create_thread create_thread_cb; +} GpsNiCallbacks; + +/** + * Extended interface for Network-initiated (NI) support. + */ +typedef struct +{ + /** set to sizeof(GpsNiInterface) */ + size_t size; + + /** Registers the callbacks for HAL to use. */ + void (*init) (GpsNiCallbacks *callbacks); + + /** Sends a response to HAL. */ + void (*respond) (int notif_id, GpsUserResponseType user_response); +} GpsNiInterface; + +struct gps_device_t { + struct hw_device_t common; + + /** + * Set the provided lights to the provided values. + * + * Returns: 0 on succes, error code on failure. + */ + const GpsInterface* (*get_gps_interface)(struct gps_device_t* dev); +}; + +#define AGPS_RIL_REQUEST_SETID_IMSI (1<<0L) +#define AGPS_RIL_REQUEST_SETID_MSISDN (1<<1L) + +#define AGPS_RIL_REQUEST_REFLOC_CELLID (1<<0L) +#define AGPS_RIL_REQUEST_REFLOC_MAC (1<<1L) + +typedef void (*agps_ril_request_set_id)(uint32_t flags); +typedef void (*agps_ril_request_ref_loc)(uint32_t flags); + +typedef struct { + agps_ril_request_set_id request_setid; + agps_ril_request_ref_loc request_refloc; + gps_create_thread create_thread_cb; +} AGpsRilCallbacks; + +/** Extended interface for AGPS_RIL support. */ +typedef struct { + /** set to sizeof(AGpsRilInterface) */ + size_t size; + /** + * Opens the AGPS interface and provides the callback routines + * to the implemenation of this interface. + */ + void (*init)( AGpsRilCallbacks* callbacks ); + + /** + * Sets the reference location. + */ + void (*set_ref_location) (const AGpsRefLocation *agps_reflocation, size_t sz_struct); + /** + * Sets the set ID. + */ + void (*set_set_id) (AGpsSetIDType type, const char* setid); + + /** + * Send network initiated message. + */ + void (*ni_message) (uint8_t *msg, size_t len); + + /** + * Notify GPS of network status changes. + * These parameters match values in the android.net.NetworkInfo class. + */ + void (*update_network_state) (int connected, int type, int roaming, const char* extra_info); + + /** + * Notify GPS of network status changes. + * These parameters match values in the android.net.NetworkInfo class. + */ + void (*update_network_availability) (int avaiable, const char* apn); +} AGpsRilInterface; + +__END_DECLS + +#endif /* ANDROID_INCLUDE_HARDWARE_GPS_H */ + diff --git a/include/telephony/ril.h b/include/telephony/ril.h new file mode 100644 index 0000000..670c1aa --- /dev/null +++ b/include/telephony/ril.h @@ -0,0 +1,4069 @@ +/* + * Copyright (C) 2006 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_RIL_H +#define ANDROID_RIL_H 1 + +#include +#ifndef FEATURE_UNIT_TEST +#include +#endif /* !FEATURE_UNIT_TEST */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define RIL_VERSION 7 /* Current version */ +#ifdef LEGACY_RIL +#define RIL_VERSION_MIN 2 /* Minimum RIL_VERSION supported */ +#else +#define RIL_VERSION_MIN 6 /* Minimum RIL_VERSION supported */ +#endif + +#define CDMA_ALPHA_INFO_BUFFER_LENGTH 64 +#define CDMA_NUMBER_INFO_BUFFER_LENGTH 81 + +typedef void * RIL_Token; + +typedef enum { + RIL_E_SUCCESS = 0, + RIL_E_RADIO_NOT_AVAILABLE = 1, /* If radio did not start or is resetting */ + RIL_E_GENERIC_FAILURE = 2, + RIL_E_PASSWORD_INCORRECT = 3, /* for PIN/PIN2 methods only! */ + RIL_E_SIM_PIN2 = 4, /* Operation requires SIM PIN2 to be entered */ + RIL_E_SIM_PUK2 = 5, /* Operation requires SIM PIN2 to be entered */ + RIL_E_REQUEST_NOT_SUPPORTED = 6, + RIL_E_CANCELLED = 7, + RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL = 8, /* data ops are not allowed during voice + call on a Class C GPRS device */ + RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW = 9, /* data ops are not allowed before device + registers in network */ + RIL_E_SMS_SEND_FAIL_RETRY = 10, /* fail to send sms and need retry */ + RIL_E_SIM_ABSENT = 11, /* fail to set the location where CDMA subscription + shall be retrieved because of SIM or RUIM + card absent */ + RIL_E_SUBSCRIPTION_NOT_AVAILABLE = 12, /* fail to find CDMA subscription from specified + location */ + RIL_E_MODE_NOT_SUPPORTED = 13, /* HW does not support preferred network type */ + RIL_E_FDN_CHECK_FAILURE = 14, /* command failed because recipient is not on FDN list */ + RIL_E_ILLEGAL_SIM_OR_ME = 15 /* network selection failed due to + illegal SIM or ME */ +} RIL_Errno; + +typedef enum { + RIL_CALL_ACTIVE = 0, + RIL_CALL_HOLDING = 1, + RIL_CALL_DIALING = 2, /* MO call only */ + RIL_CALL_ALERTING = 3, /* MO call only */ + RIL_CALL_INCOMING = 4, /* MT call only */ + RIL_CALL_WAITING = 5 /* MT call only */ +} RIL_CallState; + +typedef enum { + RADIO_STATE_OFF = 0, /* Radio explictly powered off (eg CFUN=0) */ + RADIO_STATE_UNAVAILABLE = 1, /* Radio unavailable (eg, resetting or not booted) */ + /* States 2-9 below are deprecated. Just leaving them here for backward compatibility. */ + RADIO_STATE_SIM_NOT_READY = 2, /* Radio is on, but the SIM interface is not ready */ + RADIO_STATE_SIM_LOCKED_OR_ABSENT = 3, /* SIM PIN locked, PUK required, network + personalization locked, or SIM absent */ + RADIO_STATE_SIM_READY = 4, /* Radio is on and SIM interface is available */ + RADIO_STATE_RUIM_NOT_READY = 5, /* Radio is on, but the RUIM interface is not ready */ + RADIO_STATE_RUIM_READY = 6, /* Radio is on and the RUIM interface is available */ + RADIO_STATE_RUIM_LOCKED_OR_ABSENT = 7, /* RUIM PIN locked, PUK required, network + personalization locked, or RUIM absent */ + RADIO_STATE_NV_NOT_READY = 8, /* Radio is on, but the NV interface is not available */ + RADIO_STATE_NV_READY = 9, /* Radio is on and the NV interface is available */ + RADIO_STATE_ON = 10 /* Radio is on */ +} RIL_RadioState; + +typedef enum { + RADIO_TECH_UNKNOWN = 0, + RADIO_TECH_GPRS = 1, + RADIO_TECH_EDGE = 2, + RADIO_TECH_UMTS = 3, + RADIO_TECH_IS95A = 4, + RADIO_TECH_IS95B = 5, + RADIO_TECH_1xRTT = 6, + RADIO_TECH_EVDO_0 = 7, + RADIO_TECH_EVDO_A = 8, + RADIO_TECH_HSDPA = 9, + RADIO_TECH_HSUPA = 10, + RADIO_TECH_HSPA = 11, + RADIO_TECH_EVDO_B = 12, + RADIO_TECH_EHRPD = 13, + RADIO_TECH_LTE = 14, + RADIO_TECH_HSPAP = 15, // HSPA+ + RADIO_TECH_GSM = 16 // Only supports voice +} RIL_RadioTechnology; + +// Do we want to split Data from Voice and the use +// RIL_RadioTechnology for get/setPreferredVoice/Data ? +typedef enum { + PREF_NET_TYPE_GSM_WCDMA = 0, /* GSM/WCDMA (WCDMA preferred) */ + PREF_NET_TYPE_GSM_ONLY = 1, /* GSM only */ + PREF_NET_TYPE_WCDMA = 2, /* WCDMA */ + PREF_NET_TYPE_GSM_WCDMA_AUTO = 3, /* GSM/WCDMA (auto mode, according to PRL) */ + PREF_NET_TYPE_CDMA_EVDO_AUTO = 4, /* CDMA and EvDo (auto mode, according to PRL) */ + PREF_NET_TYPE_CDMA_ONLY = 5, /* CDMA only */ + PREF_NET_TYPE_EVDO_ONLY = 6, /* EvDo only */ + PREF_NET_TYPE_GSM_WCDMA_CDMA_EVDO_AUTO = 7, /* GSM/WCDMA, CDMA, and EvDo (auto mode, according to PRL) */ + PREF_NET_TYPE_LTE_CDMA_EVDO = 8, /* LTE, CDMA and EvDo */ + PREF_NET_TYPE_LTE_GSM_WCDMA = 9, /* LTE, GSM/WCDMA */ + PREF_NET_TYPE_LTE_CMDA_EVDO_GSM_WCDMA = 10, /* LTE, CDMA, EvDo, GSM/WCDMA */ + PREF_NET_TYPE_LTE_ONLY = 11 /* LTE only */ +} RIL_PreferredNetworkType; + +/* Source for cdma subscription */ +typedef enum { + CDMA_SUBSCRIPTION_SOURCE_RUIM_SIM = 0, + CDMA_SUBSCRIPTION_SOURCE_NV = 1 +} RIL_CdmaSubscriptionSource; + +/* User-to-User signaling Info activation types derived from 3GPP 23.087 v8.0 */ +typedef enum { + RIL_UUS_TYPE1_IMPLICIT = 0, + RIL_UUS_TYPE1_REQUIRED = 1, + RIL_UUS_TYPE1_NOT_REQUIRED = 2, + RIL_UUS_TYPE2_REQUIRED = 3, + RIL_UUS_TYPE2_NOT_REQUIRED = 4, + RIL_UUS_TYPE3_REQUIRED = 5, + RIL_UUS_TYPE3_NOT_REQUIRED = 6 +} RIL_UUS_Type; + +/* User-to-User Signaling Information data coding schemes. Possible values for + * Octet 3 (Protocol Discriminator field) in the UUIE. The values have been + * specified in section 10.5.4.25 of 3GPP TS 24.008 */ +typedef enum { + RIL_UUS_DCS_USP = 0, /* User specified protocol */ + RIL_UUS_DCS_OSIHLP = 1, /* OSI higher layer protocol */ + RIL_UUS_DCS_X244 = 2, /* X.244 */ + RIL_UUS_DCS_RMCF = 3, /* Reserved for system mangement + convergence function */ + RIL_UUS_DCS_IA5c = 4 /* IA5 characters */ +} RIL_UUS_DCS; + +/* User-to-User Signaling Information defined in 3GPP 23.087 v8.0 + * This data is passed in RIL_ExtensionRecord and rec contains this + * structure when type is RIL_UUS_INFO_EXT_REC */ +typedef struct { + RIL_UUS_Type uusType; /* UUS Type */ + RIL_UUS_DCS uusDcs; /* UUS Data Coding Scheme */ + int uusLength; /* Length of UUS Data */ + char * uusData; /* UUS Data */ +} RIL_UUS_Info; + +/* CDMA Signal Information Record as defined in C.S0005 section 3.7.5.5 */ +typedef struct { + char isPresent; /* non-zero if signal information record is present */ + char signalType; /* as defined 3.7.5.5-1 */ + char alertPitch; /* as defined 3.7.5.5-2 */ + char signal; /* as defined 3.7.5.5-3, 3.7.5.5-4 or 3.7.5.5-5 */ +} RIL_CDMA_SignalInfoRecord; + +typedef struct { + RIL_CallState state; + int index; /* Connection Index for use with, eg, AT+CHLD */ + int toa; /* type of address, eg 145 = intl */ + char isMpty; /* nonzero if is mpty call */ + char isMT; /* nonzero if call is mobile terminated */ + char als; /* ALS line indicator if available + (0 = line 1) */ + char isVoice; /* nonzero if this is is a voice call */ + char isVoicePrivacy; /* nonzero if CDMA voice privacy mode is active */ + char * number; /* Remote party number */ + int numberPresentation; /* 0=Allowed, 1=Restricted, 2=Not Specified/Unknown 3=Payphone */ + char * name; /* Remote party name */ + int namePresentation; /* 0=Allowed, 1=Restricted, 2=Not Specified/Unknown 3=Payphone */ + RIL_UUS_Info * uusInfo; /* NULL or Pointer to User-User Signaling Information */ +} RIL_Call; + +/* Deprecated, use RIL_Data_Call_Response_v6 */ +typedef struct { + int cid; /* Context ID, uniquely identifies this call */ + int active; /* 0=inactive, 1=active/physical link down, 2=active/physical link up */ + char * type; /* One of the PDP_type values in TS 27.007 section 10.1.1. + For example, "IP", "IPV6", "IPV4V6", or "PPP". */ + char * apn; /* ignored */ + char * address; /* An address, e.g., "192.0.1.3" or "2001:db8::1". */ +} RIL_Data_Call_Response_v4; + +/* + * Returned by RIL_REQUEST_SETUP_DATA_CALL, RIL_REQUEST_DATA_CALL_LIST + * and RIL_UNSOL_DATA_CALL_LIST_CHANGED, on error status != 0. + */ +typedef struct { + int status; /* A RIL_DataCallFailCause, 0 which is PDP_FAIL_NONE if no error */ +#ifndef HCRADIO + int suggestedRetryTime; /* If status != 0, this fields indicates the suggested retry + back-off timer value RIL wants to override the one + pre-configured in FW. + The unit is miliseconds. + The value < 0 means no value is suggested. + The value 0 means retry should be done ASAP. + The value of MAX_INT(0x7fffffff) means no retry. */ +#endif + int cid; /* Context ID, uniquely identifies this call */ + int active; /* 0=inactive, 1=active/physical link down, 2=active/physical link up */ + char * type; /* One of the PDP_type values in TS 27.007 section 10.1.1. + For example, "IP", "IPV6", "IPV4V6", or "PPP". If status is + PDP_FAIL_ONLY_SINGLE_BEARER_ALLOWED this is the type supported + such as "IP" or "IPV6" */ + char * ifname; /* The network interface name */ + char * addresses; /* A space-delimited list of addresses with optional "/" prefix length, + e.g., "192.0.1.3" or "192.0.1.11/16 2001:db8::1/64". + May not be empty, typically 1 IPv4 or 1 IPv6 or + one of each. If the prefix length is absent the addresses + are assumed to be point to point with IPv4 having a prefix + length of 32 and IPv6 128. */ + char * dnses; /* A space-delimited list of DNS server addresses, + e.g., "192.0.1.3" or "192.0.1.11 2001:db8::1". + May be empty. */ + char * gateways; /* A space-delimited list of default gateway addresses, + e.g., "192.0.1.3" or "192.0.1.11 2001:db8::1". + May be empty in which case the addresses represent point + to point connections. */ +} RIL_Data_Call_Response_v6; + +typedef struct { + int messageRef; /* TP-Message-Reference for GSM, + and BearerData MessageId for CDMA + (See 3GPP2 C.S0015-B, v2.0, table 4.5-1). */ + char *ackPDU; /* or NULL if n/a */ + int errorCode; /* See 3GPP 27.005, 3.2.5 for GSM/UMTS, + 3GPP2 N.S0005 (IS-41C) Table 171 for CDMA, + -1 if unknown or not applicable*/ +} RIL_SMS_Response; + +/** Used by RIL_REQUEST_WRITE_SMS_TO_SIM */ +typedef struct { + int status; /* Status of message. See TS 27.005 3.1, "": */ + /* 0 = "REC UNREAD" */ + /* 1 = "REC READ" */ + /* 2 = "STO UNSENT" */ + /* 3 = "STO SENT" */ + char * pdu; /* PDU of message to write, as an ASCII hex string less the SMSC address, + the TP-layer length is "strlen(pdu)/2". */ + char * smsc; /* SMSC address in GSM BCD format prefixed by a length byte + (as expected by TS 27.005) or NULL for default SMSC */ +} RIL_SMS_WriteArgs; + +/** Used by RIL_REQUEST_DIAL */ +typedef struct { + char * address; + int clir; + /* (same as 'n' paremeter in TS 27.007 7.7 "+CLIR" + * clir == 0 on "use subscription default value" + * clir == 1 on "CLIR invocation" (restrict CLI presentation) + * clir == 2 on "CLIR suppression" (allow CLI presentation) + */ + RIL_UUS_Info * uusInfo; /* NULL or Pointer to User-User Signaling Information */ +} RIL_Dial; + +typedef struct { + int command; /* one of the commands listed for TS 27.007 +CRSM*/ + int fileid; /* EF id */ + char *path; /* "pathid" from TS 27.007 +CRSM command. + Path is in hex asciii format eg "7f205f70" + Path must always be provided. + */ + int p1; + int p2; + int p3; + char *data; /* May be NULL*/ + char *pin2; /* May be NULL*/ +} RIL_SIM_IO_v5; + +typedef struct { + int command; /* one of the commands listed for TS 27.007 +CRSM*/ + int fileid; /* EF id */ + char *path; /* "pathid" from TS 27.007 +CRSM command. + Path is in hex asciii format eg "7f205f70" + Path must always be provided. + */ + int p1; + int p2; + int p3; + char *data; /* May be NULL*/ + char *pin2; /* May be NULL*/ + char *aidPtr; /* AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value. */ +} RIL_SIM_IO_v6; + +typedef struct { + int sw1; + int sw2; + char *simResponse; /* In hex string format ([a-fA-F0-9]*). */ +} RIL_SIM_IO_Response; + +/* See also com.android.internal.telephony.gsm.CallForwardInfo */ + +typedef struct { + int status; /* + * For RIL_REQUEST_QUERY_CALL_FORWARD_STATUS + * status 1 = active, 0 = not active + * + * For RIL_REQUEST_SET_CALL_FORWARD: + * status is: + * 0 = disable + * 1 = enable + * 2 = interrogate + * 3 = registeration + * 4 = erasure + */ + + int reason; /* from TS 27.007 7.11 "reason" */ + int serviceClass;/* From 27.007 +CCFC/+CLCK "class" + See table for Android mapping from + MMI service code + 0 means user doesn't input class */ + int toa; /* "type" from TS 27.007 7.11 */ + char * number; /* "number" from TS 27.007 7.11. May be NULL */ + int timeSeconds; /* for CF no reply only */ +}RIL_CallForwardInfo; + +typedef struct { + char * cid; /* Combination of LAC and Cell Id in 32 bits in GSM. + * Upper 16 bits is LAC and lower 16 bits + * is CID (as described in TS 27.005) + * Primary Scrambling Code (as described in TS 25.331) + * in 9 bits in UMTS + * Valid values are hexadecimal 0x0000 - 0xffffffff. + */ + int rssi; /* Received RSSI in GSM, + * Level index of CPICH Received Signal Code Power in UMTS + */ +} RIL_NeighboringCell; + +/* See RIL_REQUEST_LAST_CALL_FAIL_CAUSE */ +typedef enum { + CALL_FAIL_UNOBTAINABLE_NUMBER = 1, + CALL_FAIL_NORMAL = 16, + CALL_FAIL_BUSY = 17, + CALL_FAIL_CONGESTION = 34, + CALL_FAIL_ACM_LIMIT_EXCEEDED = 68, + CALL_FAIL_CALL_BARRED = 240, + CALL_FAIL_FDN_BLOCKED = 241, + CALL_FAIL_IMSI_UNKNOWN_IN_VLR = 242, + CALL_FAIL_IMEI_NOT_ACCEPTED = 243, + CALL_FAIL_CDMA_LOCKED_UNTIL_POWER_CYCLE = 1000, + CALL_FAIL_CDMA_DROP = 1001, + CALL_FAIL_CDMA_INTERCEPT = 1002, + CALL_FAIL_CDMA_REORDER = 1003, + CALL_FAIL_CDMA_SO_REJECT = 1004, + CALL_FAIL_CDMA_RETRY_ORDER = 1005, + CALL_FAIL_CDMA_ACCESS_FAILURE = 1006, + CALL_FAIL_CDMA_PREEMPTED = 1007, + CALL_FAIL_CDMA_NOT_EMERGENCY = 1008, /* For non-emergency number dialed + during emergency callback mode */ + CALL_FAIL_CDMA_ACCESS_BLOCKED = 1009, /* CDMA network access probes blocked */ + CALL_FAIL_ERROR_UNSPECIFIED = 0xffff +} RIL_LastCallFailCause; + +/* See RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE */ +typedef enum { + PDP_FAIL_NONE = 0, /* No error, connection ok */ + + /* an integer cause code defined in TS 24.008 + section 6.1.3.1.3 or TS 24.301 Release 8+ Annex B. + If the implementation does not have access to the exact cause codes, + then it should return one of the following values, + as the UI layer needs to distinguish these + cases for error notification and potential retries. */ + PDP_FAIL_OPERATOR_BARRED = 0x08, /* no retry */ + PDP_FAIL_INSUFFICIENT_RESOURCES = 0x1A, + PDP_FAIL_MISSING_UKNOWN_APN = 0x1B, /* no retry */ + PDP_FAIL_UNKNOWN_PDP_ADDRESS_TYPE = 0x1C, /* no retry */ + PDP_FAIL_USER_AUTHENTICATION = 0x1D, /* no retry */ + PDP_FAIL_ACTIVATION_REJECT_GGSN = 0x1E, /* no retry */ + PDP_FAIL_ACTIVATION_REJECT_UNSPECIFIED = 0x1F, + PDP_FAIL_SERVICE_OPTION_NOT_SUPPORTED = 0x20, /* no retry */ + PDP_FAIL_SERVICE_OPTION_NOT_SUBSCRIBED = 0x21, /* no retry */ + PDP_FAIL_SERVICE_OPTION_OUT_OF_ORDER = 0x22, + PDP_FAIL_NSAPI_IN_USE = 0x23, /* no retry */ + PDP_FAIL_ONLY_IPV4_ALLOWED = 0x32, /* no retry */ + PDP_FAIL_ONLY_IPV6_ALLOWED = 0x33, /* no retry */ + PDP_FAIL_ONLY_SINGLE_BEARER_ALLOWED = 0x34, + PDP_FAIL_PROTOCOL_ERRORS = 0x6F, /* no retry */ + + /* Not mentioned in the specification */ + PDP_FAIL_VOICE_REGISTRATION_FAIL = -1, + PDP_FAIL_DATA_REGISTRATION_FAIL = -2, + + /* reasons for data call drop - network/modem disconnect */ + PDP_FAIL_SIGNAL_LOST = -3, /* no retry */ + PDP_FAIL_PREF_RADIO_TECH_CHANGED = -4,/* preferred technology has changed, should retry + with parameters appropriate for new technology */ + PDP_FAIL_RADIO_POWER_OFF = -5, /* data call was disconnected because radio was resetting, + powered off - no retry */ + PDP_FAIL_TETHERED_CALL_ACTIVE = -6, /* data call was disconnected by modem because tethered + mode was up on same APN/data profile - no retry until + tethered call is off */ + + PDP_FAIL_ERROR_UNSPECIFIED = 0xffff, /* retry silently */ +} RIL_DataCallFailCause; + +/* See RIL_REQUEST_SETUP_DATA_CALL */ +typedef enum { + RIL_DATA_PROFILE_DEFAULT = 0, + RIL_DATA_PROFILE_TETHERED = 1, + RIL_DATA_PROFILE_OEM_BASE = 1000 /* Start of OEM-specific profiles */ +} RIL_DataProfile; + +/* Used by RIL_UNSOL_SUPP_SVC_NOTIFICATION */ +typedef struct { + int notificationType; /* + * 0 = MO intermediate result code + * 1 = MT unsolicited result code + */ + int code; /* See 27.007 7.17 + "code1" for MO + "code2" for MT. */ + int index; /* CUG index. See 27.007 7.17. */ + int type; /* "type" from 27.007 7.17 (MT only). */ + char * number; /* "number" from 27.007 7.17 + (MT only, may be NULL). */ +} RIL_SuppSvcNotification; + +#define RIL_CARD_MAX_APPS 8 + +typedef enum { + RIL_CARDSTATE_ABSENT = 0, + RIL_CARDSTATE_PRESENT = 1, + RIL_CARDSTATE_ERROR = 2 +} RIL_CardState; + +typedef enum { + RIL_PERSOSUBSTATE_UNKNOWN = 0, /* initial state */ + RIL_PERSOSUBSTATE_IN_PROGRESS = 1, /* in between each lock transition */ + RIL_PERSOSUBSTATE_READY = 2, /* when either SIM or RUIM Perso is finished + since each app can only have 1 active perso + involved */ + RIL_PERSOSUBSTATE_SIM_NETWORK = 3, + RIL_PERSOSUBSTATE_SIM_NETWORK_SUBSET = 4, + RIL_PERSOSUBSTATE_SIM_CORPORATE = 5, + RIL_PERSOSUBSTATE_SIM_SERVICE_PROVIDER = 6, + RIL_PERSOSUBSTATE_SIM_SIM = 7, + RIL_PERSOSUBSTATE_SIM_NETWORK_PUK = 8, /* The corresponding perso lock is blocked */ + RIL_PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK = 9, + RIL_PERSOSUBSTATE_SIM_CORPORATE_PUK = 10, + RIL_PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK = 11, + RIL_PERSOSUBSTATE_SIM_SIM_PUK = 12, + RIL_PERSOSUBSTATE_RUIM_NETWORK1 = 13, + RIL_PERSOSUBSTATE_RUIM_NETWORK2 = 14, + RIL_PERSOSUBSTATE_RUIM_HRPD = 15, + RIL_PERSOSUBSTATE_RUIM_CORPORATE = 16, + RIL_PERSOSUBSTATE_RUIM_SERVICE_PROVIDER = 17, + RIL_PERSOSUBSTATE_RUIM_RUIM = 18, + RIL_PERSOSUBSTATE_RUIM_NETWORK1_PUK = 19, /* The corresponding perso lock is blocked */ + RIL_PERSOSUBSTATE_RUIM_NETWORK2_PUK = 20, + RIL_PERSOSUBSTATE_RUIM_HRPD_PUK = 21, + RIL_PERSOSUBSTATE_RUIM_CORPORATE_PUK = 22, + RIL_PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_PUK = 23, + RIL_PERSOSUBSTATE_RUIM_RUIM_PUK = 24 +} RIL_PersoSubstate; + +typedef enum { + RIL_APPSTATE_UNKNOWN = 0, + RIL_APPSTATE_DETECTED = 1, + RIL_APPSTATE_PIN = 2, /* If PIN1 or UPin is required */ + RIL_APPSTATE_PUK = 3, /* If PUK1 or Puk for UPin is required */ + RIL_APPSTATE_SUBSCRIPTION_PERSO = 4, /* perso_substate should be look at + when app_state is assigned to this value */ + RIL_APPSTATE_READY = 5 +} RIL_AppState; + +typedef enum { + RIL_PINSTATE_UNKNOWN = 0, + RIL_PINSTATE_ENABLED_NOT_VERIFIED = 1, + RIL_PINSTATE_ENABLED_VERIFIED = 2, + RIL_PINSTATE_DISABLED = 3, + RIL_PINSTATE_ENABLED_BLOCKED = 4, + RIL_PINSTATE_ENABLED_PERM_BLOCKED = 5 +} RIL_PinState; + +typedef enum { + RIL_APPTYPE_UNKNOWN = 0, + RIL_APPTYPE_SIM = 1, + RIL_APPTYPE_USIM = 2, + RIL_APPTYPE_RUIM = 3, + RIL_APPTYPE_CSIM = 4, + RIL_APPTYPE_ISIM = 5 +} RIL_AppType; + +typedef struct +{ + RIL_AppType app_type; + RIL_AppState app_state; + RIL_PersoSubstate perso_substate; /* applicable only if app_state == + RIL_APPSTATE_SUBSCRIPTION_PERSO */ + char *aid_ptr; /* null terminated string, e.g., from 0xA0, 0x00 -> 0x41, + 0x30, 0x30, 0x30 */ + char *app_label_ptr; /* null terminated string */ + int pin1_replaced; /* applicable to USIM, CSIM & ISIM */ + RIL_PinState pin1; + RIL_PinState pin2; + int foo1; /* Samsung */ + int foo2; /* Samsung */ + int foo3; /* Samsung */ + int foo4; /* Samsung */ + int foo5; /* Samsung */ +} RIL_AppStatus; + +/* Deprecated, use RIL_CardStatus_v6 */ +typedef struct +{ + RIL_CardState card_state; + RIL_PinState universal_pin_state; /* applicable to USIM and CSIM: RIL_PINSTATE_xxx */ + int gsm_umts_subscription_app_index; /* value < RIL_CARD_MAX_APPS, -1 if none */ + int cdma_subscription_app_index; /* value < RIL_CARD_MAX_APPS, -1 if none */ + int num_applications; /* value <= RIL_CARD_MAX_APPS */ + RIL_AppStatus applications[RIL_CARD_MAX_APPS]; +} RIL_CardStatus_v5; + +typedef struct +{ + RIL_CardState card_state; + RIL_PinState universal_pin_state; /* applicable to USIM and CSIM: RIL_PINSTATE_xxx */ + int gsm_umts_subscription_app_index; /* value < RIL_CARD_MAX_APPS, -1 if none */ + int cdma_subscription_app_index; /* value < RIL_CARD_MAX_APPS, -1 if none */ + int ims_subscription_app_index; /* value < RIL_CARD_MAX_APPS, -1 if none */ + int num_applications; /* value <= RIL_CARD_MAX_APPS */ + RIL_AppStatus applications[RIL_CARD_MAX_APPS]; +} RIL_CardStatus_v6; + +/** The result of a SIM refresh, returned in data[0] of RIL_UNSOL_SIM_REFRESH + * or as part of RIL_SimRefreshResponse_v7 + */ +typedef enum { + /* A file on SIM has been updated. data[1] contains the EFID. */ + SIM_FILE_UPDATE = 0, + /* SIM initialized. All files should be re-read. */ + SIM_INIT = 1, + /* SIM reset. SIM power required, SIM may be locked and all files should be re-read. */ + SIM_RESET = 2 +} RIL_SimRefreshResult; + +typedef struct { + RIL_SimRefreshResult result; + int ef_id; /* is the EFID of the updated file if the result is */ + /* SIM_FILE_UPDATE or 0 for any other result. */ + char * aid; /* is AID(application ID) of the card application */ + /* See ETSI 102.221 8.1 and 101.220 4 */ + /* For SIM_FILE_UPDATE result it can be set to AID of */ + /* application in which updated EF resides or it can be */ + /* NULL if EF is outside of an application. */ + /* For SIM_INIT result this field is set to AID of */ + /* application that caused REFRESH */ + /* For SIM_RESET result it is NULL. */ +} RIL_SimRefreshResponse_v7; + +/* Deprecated, use RIL_CDMA_CallWaiting_v6 */ +typedef struct { + char * number; /* Remote party number */ + int numberPresentation; /* 0=Allowed, 1=Restricted, 2=Not Specified/Unknown */ + char * name; /* Remote party name */ + RIL_CDMA_SignalInfoRecord signalInfoRecord; +} RIL_CDMA_CallWaiting_v5; + +typedef struct { + char * number; /* Remote party number */ + int numberPresentation; /* 0=Allowed, 1=Restricted, 2=Not Specified/Unknown */ + char * name; /* Remote party name */ + RIL_CDMA_SignalInfoRecord signalInfoRecord; + /* Number type/Number plan required to support International Call Waiting */ + int number_type; /* 0=Unknown, 1=International, 2=National, + 3=Network specific, 4=subscriber */ + int number_plan; /* 0=Unknown, 1=ISDN, 3=Data, 4=Telex, 8=Nat'l, 9=Private */ +} RIL_CDMA_CallWaiting_v6; + +/** + * Which types of Cell Broadcast Message (CBM) are to be received by the ME + * + * uFromServiceID - uToServiceID defines a range of CBM message identifiers + * whose value is 0x0000 - 0xFFFF as defined in TS 23.041 9.4.1.2.2 for GMS + * and 9.4.4.2.2 for UMTS. All other values can be treated as empty + * CBM message ID. + * + * uFromCodeScheme - uToCodeScheme defines a range of CBM data coding schemes + * whose value is 0x00 - 0xFF as defined in TS 23.041 9.4.1.2.3 for GMS + * and 9.4.4.2.3 for UMTS. + * All other values can be treated as empty CBM data coding scheme. + * + * selected 0 means message types specified in + * and are not accepted, while 1 means accepted. + * + * Used by RIL_REQUEST_GSM_GET_BROADCAST_CONFIG and + * RIL_REQUEST_GSM_SET_BROADCAST_CONFIG. + */ +typedef struct { + int fromServiceId; + int toServiceId; + int fromCodeScheme; + int toCodeScheme; + unsigned char selected; +} RIL_GSM_BroadcastSmsConfigInfo; + +/* No restriction at all including voice/SMS/USSD/SS/AV64 and packet data. */ +#define RIL_RESTRICTED_STATE_NONE 0x00 +/* Block emergency call due to restriction. But allow all normal voice/SMS/USSD/SS/AV64. */ +#define RIL_RESTRICTED_STATE_CS_EMERGENCY 0x01 +/* Block all normal voice/SMS/USSD/SS/AV64 due to restriction. Only Emergency call allowed. */ +#define RIL_RESTRICTED_STATE_CS_NORMAL 0x02 +/* Block all voice/SMS/USSD/SS/AV64 including emergency call due to restriction.*/ +#define RIL_RESTRICTED_STATE_CS_ALL 0x04 +/* Block packet data access due to restriction. */ +#define RIL_RESTRICTED_STATE_PS_ALL 0x10 + +/* The status for an OTASP/OTAPA session */ +typedef enum { + CDMA_OTA_PROVISION_STATUS_SPL_UNLOCKED, + CDMA_OTA_PROVISION_STATUS_SPC_RETRIES_EXCEEDED, + CDMA_OTA_PROVISION_STATUS_A_KEY_EXCHANGED, + CDMA_OTA_PROVISION_STATUS_SSD_UPDATED, + CDMA_OTA_PROVISION_STATUS_NAM_DOWNLOADED, + CDMA_OTA_PROVISION_STATUS_MDN_DOWNLOADED, + CDMA_OTA_PROVISION_STATUS_IMSI_DOWNLOADED, + CDMA_OTA_PROVISION_STATUS_PRL_DOWNLOADED, + CDMA_OTA_PROVISION_STATUS_COMMITTED, + CDMA_OTA_PROVISION_STATUS_OTAPA_STARTED, + CDMA_OTA_PROVISION_STATUS_OTAPA_STOPPED, + CDMA_OTA_PROVISION_STATUS_OTAPA_ABORTED +} RIL_CDMA_OTA_ProvisionStatus; + +typedef struct { + int signalStrength; /* Valid values are (0-31, 99) as defined in TS 27.007 8.5 */ + int bitErrorRate; /* bit error rate (0-7, 99) as defined in TS 27.007 8.5 */ +} RIL_GW_SignalStrength; + + +typedef struct { + int dbm; /* Valid values are positive integers. This value is the actual RSSI value + * multiplied by -1. Example: If the actual RSSI is -75, then this response + * value will be 75. + */ + int ecio; /* Valid values are positive integers. This value is the actual Ec/Io multiplied + * by -10. Example: If the actual Ec/Io is -12.5 dB, then this response value + * will be 125. + */ +} RIL_CDMA_SignalStrength; + + +typedef struct { + int dbm; /* Valid values are positive integers. This value is the actual RSSI value + * multiplied by -1. Example: If the actual RSSI is -75, then this response + * value will be 75. + */ + int ecio; /* Valid values are positive integers. This value is the actual Ec/Io multiplied + * by -10. Example: If the actual Ec/Io is -12.5 dB, then this response value + * will be 125. + */ + int signalNoiseRatio; /* Valid values are 0-8. 8 is the highest signal to noise ratio. */ +} RIL_EVDO_SignalStrength; + +typedef struct { + int signalStrength; /* Valid values are (0-31, 99) as defined in TS 27.007 8.5 */ + int rsrp; /* The current Reference Signal Receive Power in dBm multipled by -1. + * Range: 44 to 140 dBm + * INT_MAX: 0x7FFFFFFF denotes invalid value. + * Reference: 3GPP TS 36.133 9.1.4 */ + int rsrq; /* The current Reference Signal Receive Quality in dB multiplied by -1. + * Range: 20 to 3 dB. + * INT_MAX: 0x7FFFFFFF denotes invalid value. + * Reference: 3GPP TS 36.133 9.1.7 */ + int rssnr; /* The current reference signal signal-to-noise ratio in 0.1 dB units. + * Range: -200 to +300 (-200 = -20.0 dB, +300 = 30dB). + * INT_MAX : 0x7FFFFFFF denotes invalid value. + * Reference: 3GPP TS 36.101 8.1.1 */ + int cqi; /* The current Channel Quality Indicator. + * Range: 0 to 15. + * INT_MAX : 0x7FFFFFFF denotes invalid value. + * Reference: 3GPP TS 36.101 9.2, 9.3, A.4 */ +} RIL_LTE_SignalStrength; + +/* Deprecated, use RIL_SignalStrength_v6 */ +typedef struct { + RIL_GW_SignalStrength GW_SignalStrength; + RIL_CDMA_SignalStrength CDMA_SignalStrength; + RIL_EVDO_SignalStrength EVDO_SignalStrength; +} RIL_SignalStrength_v5; + +typedef struct { + RIL_GW_SignalStrength GW_SignalStrength; + RIL_CDMA_SignalStrength CDMA_SignalStrength; + RIL_EVDO_SignalStrength EVDO_SignalStrength; + RIL_LTE_SignalStrength LTE_SignalStrength; +} RIL_SignalStrength_v6; + +/* Names of the CDMA info records (C.S0005 section 3.7.5) */ +typedef enum { + RIL_CDMA_DISPLAY_INFO_REC, + RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC, + RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC, + RIL_CDMA_CONNECTED_NUMBER_INFO_REC, + RIL_CDMA_SIGNAL_INFO_REC, + RIL_CDMA_REDIRECTING_NUMBER_INFO_REC, + RIL_CDMA_LINE_CONTROL_INFO_REC, + RIL_CDMA_EXTENDED_DISPLAY_INFO_REC, + RIL_CDMA_T53_CLIR_INFO_REC, + RIL_CDMA_T53_RELEASE_INFO_REC, + RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC +} RIL_CDMA_InfoRecName; + +/* Display Info Rec as defined in C.S0005 section 3.7.5.1 + Extended Display Info Rec as defined in C.S0005 section 3.7.5.16 + Note: the Extended Display info rec contains multiple records of the + form: display_tag, display_len, and display_len occurrences of the + chari field if the display_tag is not 10000000 or 10000001. + To save space, the records are stored consecutively in a byte buffer. + The display_tag, display_len and chari fields are all 1 byte. +*/ + +typedef struct { + char alpha_len; + char alpha_buf[CDMA_ALPHA_INFO_BUFFER_LENGTH]; +} RIL_CDMA_DisplayInfoRecord; + +/* Called Party Number Info Rec as defined in C.S0005 section 3.7.5.2 + Calling Party Number Info Rec as defined in C.S0005 section 3.7.5.3 + Connected Number Info Rec as defined in C.S0005 section 3.7.5.4 +*/ + +typedef struct { + char len; + char buf[CDMA_NUMBER_INFO_BUFFER_LENGTH]; + char number_type; + char number_plan; + char pi; + char si; +} RIL_CDMA_NumberInfoRecord; + +/* Redirecting Number Information Record as defined in C.S0005 section 3.7.5.11 */ +typedef enum { + RIL_REDIRECTING_REASON_UNKNOWN = 0, + RIL_REDIRECTING_REASON_CALL_FORWARDING_BUSY = 1, + RIL_REDIRECTING_REASON_CALL_FORWARDING_NO_REPLY = 2, + RIL_REDIRECTING_REASON_CALLED_DTE_OUT_OF_ORDER = 9, + RIL_REDIRECTING_REASON_CALL_FORWARDING_BY_THE_CALLED_DTE = 10, + RIL_REDIRECTING_REASON_CALL_FORWARDING_UNCONDITIONAL = 15, + RIL_REDIRECTING_REASON_RESERVED +} RIL_CDMA_RedirectingReason; + +typedef struct { + RIL_CDMA_NumberInfoRecord redirectingNumber; + /* redirectingReason is set to RIL_REDIRECTING_REASON_UNKNOWN if not included */ + RIL_CDMA_RedirectingReason redirectingReason; +} RIL_CDMA_RedirectingNumberInfoRecord; + +/* Line Control Information Record as defined in C.S0005 section 3.7.5.15 */ +typedef struct { + char lineCtrlPolarityIncluded; + char lineCtrlToggle; + char lineCtrlReverse; + char lineCtrlPowerDenial; +} RIL_CDMA_LineControlInfoRecord; + +/* T53 CLIR Information Record */ +typedef struct { + char cause; +} RIL_CDMA_T53_CLIRInfoRecord; + +/* T53 Audio Control Information Record */ +typedef struct { + char upLink; + char downLink; +} RIL_CDMA_T53_AudioControlInfoRecord; + +typedef struct { + + RIL_CDMA_InfoRecName name; + + union { + /* Display and Extended Display Info Rec */ + RIL_CDMA_DisplayInfoRecord display; + + /* Called Party Number, Calling Party Number, Connected Number Info Rec */ + RIL_CDMA_NumberInfoRecord number; + + /* Signal Info Rec */ + RIL_CDMA_SignalInfoRecord signal; + + /* Redirecting Number Info Rec */ + RIL_CDMA_RedirectingNumberInfoRecord redir; + + /* Line Control Info Rec */ + RIL_CDMA_LineControlInfoRecord lineCtrl; + + /* T53 CLIR Info Rec */ + RIL_CDMA_T53_CLIRInfoRecord clir; + + /* T53 Audio Control Info Rec */ + RIL_CDMA_T53_AudioControlInfoRecord audioCtrl; + } rec; +} RIL_CDMA_InformationRecord; + +#define RIL_CDMA_MAX_NUMBER_OF_INFO_RECS 10 + +typedef struct { + char numberOfInfoRecs; + RIL_CDMA_InformationRecord infoRec[RIL_CDMA_MAX_NUMBER_OF_INFO_RECS]; +} RIL_CDMA_InformationRecords; + +/** + * RIL_REQUEST_GET_SIM_STATUS + * + * Requests status of the SIM interface and the SIM card + * + * "data" is NULL + * + * "response" is const RIL_CardStatus_v6 * + * + * Valid errors: + * Must never fail + */ +#define RIL_REQUEST_GET_SIM_STATUS 1 + +/** + * RIL_REQUEST_ENTER_SIM_PIN + * + * Supplies SIM PIN. Only called if RIL_CardStatus has RIL_APPSTATE_PIN state + * + * "data" is const char ** + * ((const char **)data)[0] is PIN value + * ((const char **)data)[1] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value. + * + * "response" is int * + * ((int *)response)[0] is the number of retries remaining, or -1 if unknown + * + * Valid errors: + * + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + * PASSWORD_INCORRECT + */ + +#define RIL_REQUEST_ENTER_SIM_PIN 2 + + +/** + * RIL_REQUEST_ENTER_SIM_PUK + * + * Supplies SIM PUK and new PIN. + * + * "data" is const char ** + * ((const char **)data)[0] is PUK value + * ((const char **)data)[1] is new PIN value + * ((const char **)data)[2] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value. + * + * "response" is int * + * ((int *)response)[0] is the number of retries remaining, or -1 if unknown + * + * Valid errors: + * + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + * PASSWORD_INCORRECT + * (PUK is invalid) + */ + +#define RIL_REQUEST_ENTER_SIM_PUK 3 + +/** + * RIL_REQUEST_ENTER_SIM_PIN2 + * + * Supplies SIM PIN2. Only called following operation where SIM_PIN2 was + * returned as a a failure from a previous operation. + * + * "data" is const char ** + * ((const char **)data)[0] is PIN2 value + * ((const char **)data)[1] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value. + * + * "response" is int * + * ((int *)response)[0] is the number of retries remaining, or -1 if unknown + * + * Valid errors: + * + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + * PASSWORD_INCORRECT + */ + +#define RIL_REQUEST_ENTER_SIM_PIN2 4 + +/** + * RIL_REQUEST_ENTER_SIM_PUK2 + * + * Supplies SIM PUK2 and new PIN2. + * + * "data" is const char ** + * ((const char **)data)[0] is PUK2 value + * ((const char **)data)[1] is new PIN2 value + * ((const char **)data)[2] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value. + * + * "response" is int * + * ((int *)response)[0] is the number of retries remaining, or -1 if unknown + * + * Valid errors: + * + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + * PASSWORD_INCORRECT + * (PUK2 is invalid) + */ + +#define RIL_REQUEST_ENTER_SIM_PUK2 5 + +/** + * RIL_REQUEST_CHANGE_SIM_PIN + * + * Supplies old SIM PIN and new PIN. + * + * "data" is const char ** + * ((const char **)data)[0] is old PIN value + * ((const char **)data)[1] is new PIN value + * ((const char **)data)[2] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value. + * + * "response" is int * + * ((int *)response)[0] is the number of retries remaining, or -1 if unknown + * + * Valid errors: + * + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + * PASSWORD_INCORRECT + * (old PIN is invalid) + * + */ + +#define RIL_REQUEST_CHANGE_SIM_PIN 6 + + +/** + * RIL_REQUEST_CHANGE_SIM_PIN2 + * + * Supplies old SIM PIN2 and new PIN2. + * + * "data" is const char ** + * ((const char **)data)[0] is old PIN2 value + * ((const char **)data)[1] is new PIN2 value + * ((const char **)data)[2] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value. + * + * "response" is int * + * ((int *)response)[0] is the number of retries remaining, or -1 if unknown + * + * Valid errors: + * + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + * PASSWORD_INCORRECT + * (old PIN2 is invalid) + * + */ + +#define RIL_REQUEST_CHANGE_SIM_PIN2 7 + +/** + * RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION + * + * Requests that network personlization be deactivated + * + * "data" is const char ** + * ((const char **)(data))[0]] is network depersonlization code + * + * "response" is int * + * ((int *)response)[0] is the number of retries remaining, or -1 if unknown + * + * Valid errors: + * + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + * PASSWORD_INCORRECT + * (code is invalid) + */ + +#define RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION 8 + +/** + * RIL_REQUEST_GET_CURRENT_CALLS + * + * Requests current call list + * + * "data" is NULL + * + * "response" must be a "const RIL_Call **" + * + * Valid errors: + * + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + * (request will be made again in a few hundred msec) + */ + +#define RIL_REQUEST_GET_CURRENT_CALLS 9 + + +/** + * RIL_REQUEST_DIAL + * + * Initiate voice call + * + * "data" is const RIL_Dial * + * "response" is NULL + * + * This method is never used for supplementary service codes + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + */ +#define RIL_REQUEST_DIAL 10 + +/** + * RIL_REQUEST_GET_IMSI + * + * Get the SIM IMSI + * + * Only valid when radio state is "RADIO_STATE_ON" + * + * "data" is const char ** + * ((const char **)data)[0] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value. + * "response" is a const char * containing the IMSI + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + */ + +#define RIL_REQUEST_GET_IMSI 11 + +/** + * RIL_REQUEST_HANGUP + * + * Hang up a specific line (like AT+CHLD=1x) + * + * After this HANGUP request returns, RIL should show the connection is NOT + * active anymore in next RIL_REQUEST_GET_CURRENT_CALLS query. + * + * "data" is an int * + * (int *)data)[0] contains Connection index (value of 'x' in CHLD above) + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + */ + +#define RIL_REQUEST_HANGUP 12 + +/** + * RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND + * + * Hang up waiting or held (like AT+CHLD=0) + * + * After this HANGUP request returns, RIL should show the connection is NOT + * active anymore in next RIL_REQUEST_GET_CURRENT_CALLS query. + * + * "data" is NULL + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + */ + +#define RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND 13 + +/** + * RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND + * + * Hang up waiting or held (like AT+CHLD=1) + * + * After this HANGUP request returns, RIL should show the connection is NOT + * active anymore in next RIL_REQUEST_GET_CURRENT_CALLS query. + * + * "data" is NULL + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + */ + +#define RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND 14 + +/** + * RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE + * + * Switch waiting or holding call and active call (like AT+CHLD=2) + * + * State transitions should be is follows: + * + * If call 1 is waiting and call 2 is active, then if this re + * + * BEFORE AFTER + * Call 1 Call 2 Call 1 Call 2 + * ACTIVE HOLDING HOLDING ACTIVE + * ACTIVE WAITING HOLDING ACTIVE + * HOLDING WAITING HOLDING ACTIVE + * ACTIVE IDLE HOLDING IDLE + * IDLE IDLE IDLE IDLE + * + * "data" is NULL + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + */ + +#define RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE 15 +#define RIL_REQUEST_SWITCH_HOLDING_AND_ACTIVE 15 + +/** + * RIL_REQUEST_CONFERENCE + * + * Conference holding and active (like AT+CHLD=3) + + * "data" is NULL + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + */ +#define RIL_REQUEST_CONFERENCE 16 + +/** + * RIL_REQUEST_UDUB + * + * Send UDUB (user determined used busy) to ringing or + * waiting call answer)(RIL_BasicRequest r); + * + * "data" is NULL + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + */ +#define RIL_REQUEST_UDUB 17 + +/** + * RIL_REQUEST_LAST_CALL_FAIL_CAUSE + * + * Requests the failure cause code for the most recently terminated call + * + * "data" is NULL + * "response" is a "int *" + * ((int *)response)[0] is RIL_LastCallFailCause. GSM failure reasons are + * mapped to cause codes defined in TS 24.008 Annex H where possible. CDMA + * failure reasons are derived from the possible call failure scenarios + * described in the "CDMA IS-2000 Release A (C.S0005-A v6.0)" standard. + * + * The implementation should return CALL_FAIL_ERROR_UNSPECIFIED for blocked + * MO calls by restricted state (See RIL_UNSOL_RESTRICTED_STATE_CHANGED) + * + * If the implementation does not have access to the exact cause codes, + * then it should return one of the values listed in RIL_LastCallFailCause, + * as the UI layer needs to distinguish these cases for tone generation or + * error notification. + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + * See also: RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE + */ +#define RIL_REQUEST_LAST_CALL_FAIL_CAUSE 18 + +/** + * RIL_REQUEST_SIGNAL_STRENGTH + * + * Requests current signal strength and associated information + * + * Must succeed if radio is on. + * + * "data" is NULL + * + * "response" is a const RIL_SignalStrength * + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + */ +#define RIL_REQUEST_SIGNAL_STRENGTH 19 + +/** + * RIL_REQUEST_VOICE_REGISTRATION_STATE + * + * Request current registration state + * + * "data" is NULL + * "response" is a "char **" + * ((const char **)response)[0] is registration state 0-6, + * 0 - Not registered, MT is not currently searching + * a new operator to register + * 1 - Registered, home network + * 2 - Not registered, but MT is currently searching + * a new operator to register + * 3 - Registration denied + * 4 - Unknown + * 5 - Registered, roaming + * 10 - Same as 0, but indicates that emergency calls + * are enabled. + * 12 - Same as 2, but indicates that emergency calls + * are enabled. + * 13 - Same as 3, but indicates that emergency calls + * are enabled. + * 14 - Same as 4, but indicates that emergency calls + * are enabled. + * + * ((const char **)response)[1] is LAC if registered on a GSM/WCDMA system or + * NULL if not.Valid LAC are 0x0000 - 0xffff + * ((const char **)response)[2] is CID if registered on a * GSM/WCDMA or + * NULL if not. + * Valid CID are 0x00000000 - 0xffffffff + * In GSM, CID is Cell ID (see TS 27.007) + * in 16 bits + * In UMTS, CID is UMTS Cell Identity + * (see TS 25.331) in 28 bits + * ((const char **)response)[3] indicates the available voice radio technology, + * valid values as defined by RIL_RadioTechnology. + * ((const char **)response)[4] is Base Station ID if registered on a CDMA + * system or NULL if not. Base Station ID in + * decimal format + * ((const char **)response)[5] is Base Station latitude if registered on a + * CDMA system or NULL if not. Base Station + * latitude is a decimal number as specified in + * 3GPP2 C.S0005-A v6.0. It is represented in + * units of 0.25 seconds and ranges from -1296000 + * to 1296000, both values inclusive (corresponding + * to a range of -90 to +90 degrees). + * ((const char **)response)[6] is Base Station longitude if registered on a + * CDMA system or NULL if not. Base Station + * longitude is a decimal number as specified in + * 3GPP2 C.S0005-A v6.0. It is represented in + * units of 0.25 seconds and ranges from -2592000 + * to 2592000, both values inclusive (corresponding + * to a range of -180 to +180 degrees). + * ((const char **)response)[7] is concurrent services support indicator if + * registered on a CDMA system 0-1. + * 0 - Concurrent services not supported, + * 1 - Concurrent services supported + * ((const char **)response)[8] is System ID if registered on a CDMA system or + * NULL if not. Valid System ID are 0 - 32767 + * ((const char **)response)[9] is Network ID if registered on a CDMA system or + * NULL if not. Valid System ID are 0 - 65535 + * ((const char **)response)[10] is the TSB-58 Roaming Indicator if registered + * on a CDMA or EVDO system or NULL if not. Valid values + * are 0-255. + * ((const char **)response)[11] indicates whether the current system is in the + * PRL if registered on a CDMA or EVDO system or NULL if + * not. 0=not in the PRL, 1=in the PRL + * ((const char **)response)[12] is the default Roaming Indicator from the PRL, + * if registered on a CDMA or EVDO system or NULL if not. + * Valid values are 0-255. + * ((const char **)response)[13] if registration state is 3 (Registration + * denied) this is an enumerated reason why + * registration was denied. See 3GPP TS 24.008, + * 10.5.3.6 and Annex G. + * 0 - General + * 1 - Authentication Failure + * 2 - IMSI unknown in HLR + * 3 - Illegal MS + * 4 - Illegal ME + * 5 - PLMN not allowed + * 6 - Location area not allowed + * 7 - Roaming not allowed + * 8 - No Suitable Cells in this Location Area + * 9 - Network failure + * 10 - Persistent location update reject + * 11 - PLMN not allowed + * 12 - Location area not allowed + * 13 - Roaming not allowed in this Location Area + * 15 - No Suitable Cells in this Location Area + * 17 - Network Failure + * 20 - MAC Failure + * 21 - Sync Failure + * 22 - Congestion + * 23 - GSM Authentication unacceptable + * 25 - Not Authorized for this CSG + * 32 - Service option not supported + * 33 - Requested service option not subscribed + * 34 - Service option temporarily out of order + * 38 - Call cannot be identified + * 48-63 - Retry upon entry into a new cell + * 95 - Semantically incorrect message + * 96 - Invalid mandatory information + * 97 - Message type non-existent or not implemented + * 98 - Message not compatible with protocol state + * 99 - Information element non-existent or not implemented + * 100 - Conditional IE error + * 101 - Message not compatible with protocol state + * 111 - Protocol error, unspecified + * ((const char **)response)[14] is the Primary Scrambling Code of the current + * cell as described in TS 25.331, in hexadecimal + * format, or NULL if unknown or not registered + * to a UMTS network. + * + * Please note that registration state 4 ("unknown") is treated + * as "out of service" in the Android telephony system + * + * Registration state 3 can be returned if Location Update Reject + * (with cause 17 - Network Failure) is received repeatedly from the network, + * to facilitate "managed roaming" + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + */ +#define RIL_REQUEST_VOICE_REGISTRATION_STATE 20 + +/** + * RIL_REQUEST_DATA_REGISTRATION_STATE + * + * Request current DATA registration state + * + * "data" is NULL + * "response" is a "char **" + * ((const char **)response)[0] is registration state 0-5 from TS 27.007 10.1.20 AT+CGREG + * ((const char **)response)[1] is LAC if registered or NULL if not + * ((const char **)response)[2] is CID if registered or NULL if not + * ((const char **)response)[3] indicates the available data radio technology, + * valid values as defined by RIL_RadioTechnology. + * ((const char **)response)[4] if registration state is 3 (Registration + * denied) this is an enumerated reason why + * registration was denied. See 3GPP TS 24.008, + * Annex G.6 "Additonal cause codes for GMM". + * 7 == GPRS services not allowed + * 8 == GPRS services and non-GPRS services not allowed + * 9 == MS identity cannot be derived by the network + * 10 == Implicitly detached + * 14 == GPRS services not allowed in this PLMN + * 16 == MSC temporarily not reachable + * 40 == No PDP context activated + * ((const char **)response)[5] The maximum number of simultaneous Data Calls that can be + * established using RIL_REQUEST_SETUP_DATA_CALL. + * + * The values at offsets 6..10 are optional LTE location information in decimal. + * If a value is unknown that value may be NULL. If all values are NULL, + * none need to be present. + * ((const char **)response)[6] is TAC, a 16-bit Tracking Area Code. + * ((const char **)response)[7] is CID, a 0-503 Physical Cell Identifier. + * ((const char **)response)[8] is ECI, a 28-bit E-UTRAN Cell Identifier. + * ((const char **)response)[9] is CSGID, a 27-bit Closed Subscriber Group Identity. + * ((const char **)response)[10] is TADV, a 6-bit timing advance value. + * + * LAC and CID are in hexadecimal format. + * valid LAC are 0x0000 - 0xffff + * valid CID are 0x00000000 - 0x0fffffff + * + * Please note that registration state 4 ("unknown") is treated + * as "out of service" in the Android telephony system + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + */ +#define RIL_REQUEST_DATA_REGISTRATION_STATE 21 + +/** + * RIL_REQUEST_OPERATOR + * + * Request current operator ONS or EONS + * + * "data" is NULL + * "response" is a "const char **" + * ((const char **)response)[0] is long alpha ONS or EONS + * or NULL if unregistered + * + * ((const char **)response)[1] is short alpha ONS or EONS + * or NULL if unregistered + * ((const char **)response)[2] is 5 or 6 digit numeric code (MCC + MNC) + * or NULL if unregistered + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + */ +#define RIL_REQUEST_OPERATOR 22 + +/** + * RIL_REQUEST_RADIO_POWER + * + * Toggle radio on and off (for "airplane" mode) + * If the radio is is turned off/on the radio modem subsystem + * is expected return to an initialized state. For instance, + * any voice and data calls will be terminated and all associated + * lists emptied. + * + * "data" is int * + * ((int *)data)[0] is > 0 for "Radio On" + * ((int *)data)[0] is == 0 for "Radio Off" + * + * "response" is NULL + * + * Turn radio on if "on" > 0 + * Turn radio off if "on" == 0 + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + */ +#define RIL_REQUEST_RADIO_POWER 23 + +/** + * RIL_REQUEST_DTMF + * + * Send a DTMF tone + * + * If the implementation is currently playing a tone requested via + * RIL_REQUEST_DTMF_START, that tone should be cancelled and the new tone + * should be played instead + * + * "data" is a char * containing a single character with one of 12 values: 0-9,*,# + * "response" is NULL + * + * FIXME should this block/mute microphone? + * How does this interact with local DTMF feedback? + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + * See also: RIL_REQUEST_DTMF_STOP, RIL_REQUEST_DTMF_START + * + */ +#define RIL_REQUEST_DTMF 24 + +/** + * RIL_REQUEST_SEND_SMS + * + * Send an SMS message + * + * "data" is const char ** + * ((const char **)data)[0] is SMSC address in GSM BCD format prefixed + * by a length byte (as expected by TS 27.005) or NULL for default SMSC + * ((const char **)data)[1] is SMS in PDU format as an ASCII hex string + * less the SMSC address + * TP-Layer-Length is be "strlen(((const char **)data)[1])/2" + * + * "response" is a const RIL_SMS_Response * + * + * Based on the return error, caller decides to resend if sending sms + * fails. SMS_SEND_FAIL_RETRY means retry (i.e. error cause is 332) + * and GENERIC_FAILURE means no retry (i.e. error cause is 500) + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * SMS_SEND_FAIL_RETRY + * FDN_CHECK_FAILURE + * GENERIC_FAILURE + * + * FIXME how do we specify TP-Message-Reference if we need to resend? + */ +#define RIL_REQUEST_SEND_SMS 25 + + +/** + * RIL_REQUEST_SEND_SMS_EXPECT_MORE + * + * Send an SMS message. Identical to RIL_REQUEST_SEND_SMS, + * except that more messages are expected to be sent soon. If possible, + * keep SMS relay protocol link open (eg TS 27.005 AT+CMMS command) + * + * "data" is const char ** + * ((const char **)data)[0] is SMSC address in GSM BCD format prefixed + * by a length byte (as expected by TS 27.005) or NULL for default SMSC + * ((const char **)data)[1] is SMS in PDU format as an ASCII hex string + * less the SMSC address + * TP-Layer-Length is be "strlen(((const char **)data)[1])/2" + * + * "response" is a const RIL_SMS_Response * + * + * Based on the return error, caller decides to resend if sending sms + * fails. SMS_SEND_FAIL_RETRY means retry (i.e. error cause is 332) + * and GENERIC_FAILURE means no retry (i.e. error cause is 500) + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * SMS_SEND_FAIL_RETRY + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_SEND_SMS_EXPECT_MORE 26 + + +/** + * RIL_REQUEST_SETUP_DATA_CALL + * + * Setup a packet data connection. If RIL_Data_Call_Response_v6.status + * return success it is added to the list of data calls and a + * RIL_UNSOL_DATA_CALL_LIST_CHANGED is sent. The call remains in the + * list until RIL_REQUEST_DEACTIVATE_DATA_CALL is issued or the + * radio is powered off/on. This list is returned by RIL_REQUEST_DATA_CALL_LIST + * and RIL_UNSOL_DATA_CALL_LIST_CHANGED. + * + * The RIL is expected to: + * - Create one data call context. + * - Create and configure a dedicated interface for the context + * - The interface must be point to point. + * - The interface is configured with one or more addresses and + * is capable of sending and receiving packets. The prefix length + * of the addresses must be /32 for IPv4 and /128 for IPv6. + * - Must NOT change the linux routing table. + * - Support up to RIL_REQUEST_DATA_REGISTRATION_STATE response[5] + * number of simultaneous data call contexts. + * + * "data" is a const char ** + * ((const char **)data)[0] Radio technology to use: 0-CDMA, 1-GSM/UMTS, 2... + * for values above 2 this is RIL_RadioTechnology + 2. + * ((const char **)data)[1] is a RIL_DataProfile (support is optional) + * ((const char **)data)[2] is the APN to connect to if radio technology is GSM/UMTS. This APN will + * override the one in the profile. NULL indicates no APN overrride. + * ((const char **)data)[3] is the username for APN, or NULL + * ((const char **)data)[4] is the password for APN, or NULL + * ((const char **)data)[5] is the PAP / CHAP auth type. Values: + * 0 => PAP and CHAP is never performed. + * 1 => PAP may be performed; CHAP is never performed. + * 2 => CHAP may be performed; PAP is never performed. + * 3 => PAP / CHAP may be performed - baseband dependent. + * ((const char **)data)[6] is the connection type to request must be one of the + * PDP_type values in TS 27.007 section 10.1.1. + * For example, "IP", "IPV6", "IPV4V6", or "PPP". + * ((const char **)data)[7] Optional connection property parameters, format to be defined. + * + * "response" is a RIL_Data_Call_Response_v6 + * + * FIXME may need way to configure QoS settings + * + * Valid errors: + * SUCCESS should be returned on both success and failure of setup with + * the RIL_Data_Call_Response_v6.status containing the actual status. + * For all other errors the RIL_Data_Call_Resonse_v6 is ignored. + * + * Other errors could include: + * RADIO_NOT_AVAILABLE, GENERIC_FAILURE, OP_NOT_ALLOWED_BEFORE_REG_TO_NW, + * OP_NOT_ALLOWED_DURING_VOICE_CALL and REQUEST_NOT_SUPPORTED. + * + * See also: RIL_REQUEST_DEACTIVATE_DATA_CALL + */ +#define RIL_REQUEST_SETUP_DATA_CALL 27 + + +/** + * RIL_REQUEST_SIM_IO + * + * Request SIM I/O operation. + * This is similar to the TS 27.007 "restricted SIM" operation + * where it assumes all of the EF selection will be done by the + * callee. + * + * "data" is a const RIL_SIM_IO_v6 * + * Please note that RIL_SIM_IO has a "PIN2" field which may be NULL, + * or may specify a PIN2 for operations that require a PIN2 (eg + * updating FDN records) + * + * "response" is a const RIL_SIM_IO_Response * + * + * Arguments and responses that are unused for certain + * values of "command" should be ignored or set to NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * SIM_PIN2 + * SIM_PUK2 + */ +#define RIL_REQUEST_SIM_IO 28 + +/** + * RIL_REQUEST_SEND_USSD + * + * Send a USSD message + * + * If a USSD session already exists, the message should be sent in the + * context of that session. Otherwise, a new session should be created. + * + * The network reply should be reported via RIL_UNSOL_ON_USSD + * + * Only one USSD session may exist at a time, and the session is assumed + * to exist until: + * a) The android system invokes RIL_REQUEST_CANCEL_USSD + * b) The implementation sends a RIL_UNSOL_ON_USSD with a type code + * of "0" (USSD-Notify/no further action) or "2" (session terminated) + * + * "data" is a const char * containing the USSD request in UTF-8 format + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * FDN_CHECK_FAILURE + * GENERIC_FAILURE + * + * See also: RIL_REQUEST_CANCEL_USSD, RIL_UNSOL_ON_USSD + */ + +#define RIL_REQUEST_SEND_USSD 29 + +/** + * RIL_REQUEST_CANCEL_USSD + * + * Cancel the current USSD session if one exists + * + * "data" is null + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + */ + +#define RIL_REQUEST_CANCEL_USSD 30 + +/** + * RIL_REQUEST_GET_CLIR + * + * Gets current CLIR status + * "data" is NULL + * "response" is int * + * ((int *)data)[0] is "n" parameter from TS 27.007 7.7 + * ((int *)data)[1] is "m" parameter from TS 27.007 7.7 + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + */ +#define RIL_REQUEST_GET_CLIR 31 + +/** + * RIL_REQUEST_SET_CLIR + * + * "data" is int * + * ((int *)data)[0] is "n" parameter from TS 27.007 7.7 + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + */ +#define RIL_REQUEST_SET_CLIR 32 + +/** + * RIL_REQUEST_QUERY_CALL_FORWARD_STATUS + * + * "data" is const RIL_CallForwardInfo * + * + * "response" is const RIL_CallForwardInfo ** + * "response" points to an array of RIL_CallForwardInfo *'s, one for + * each distinct registered phone number. + * + * For example, if data is forwarded to +18005551212 and voice is forwarded + * to +18005559999, then two separate RIL_CallForwardInfo's should be returned + * + * If, however, both data and voice are forwarded to +18005551212, then + * a single RIL_CallForwardInfo can be returned with the service class + * set to "data + voice = 3") + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + */ +#define RIL_REQUEST_QUERY_CALL_FORWARD_STATUS 33 + + +/** + * RIL_REQUEST_SET_CALL_FORWARD + * + * Configure call forward rule + * + * "data" is const RIL_CallForwardInfo * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + */ +#define RIL_REQUEST_SET_CALL_FORWARD 34 + + +/** + * RIL_REQUEST_QUERY_CALL_WAITING + * + * Query current call waiting state + * + * "data" is const int * + * ((const int *)data)[0] is the TS 27.007 service class to query. + * "response" is a const int * + * ((const int *)response)[0] is 0 for "disabled" and 1 for "enabled" + * + * If ((const int *)response)[0] is = 1, then ((const int *)response)[1] + * must follow, with the TS 27.007 service class bit vector of services + * for which call waiting is enabled. + * + * For example, if ((const int *)response)[0] is 1 and + * ((const int *)response)[1] is 3, then call waiting is enabled for data + * and voice and disabled for everything else + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + */ +#define RIL_REQUEST_QUERY_CALL_WAITING 35 + + +/** + * RIL_REQUEST_SET_CALL_WAITING + * + * Configure current call waiting state + * + * "data" is const int * + * ((const int *)data)[0] is 0 for "disabled" and 1 for "enabled" + * ((const int *)data)[1] is the TS 27.007 service class bit vector of + * services to modify + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + */ +#define RIL_REQUEST_SET_CALL_WAITING 36 + +/** + * RIL_REQUEST_SMS_ACKNOWLEDGE + * + * Acknowledge successful or failed receipt of SMS previously indicated + * via RIL_UNSOL_RESPONSE_NEW_SMS + * + * "data" is int * + * ((int *)data)[0] is 1 on successful receipt + * (basically, AT+CNMA=1 from TS 27.005 + * is 0 on failed receipt + * (basically, AT+CNMA=2 from TS 27.005) + * ((int *)data)[1] if data[0] is 0, this contains the failure cause as defined + * in TS 23.040, 9.2.3.22. Currently only 0xD3 (memory + * capacity exceeded) and 0xFF (unspecified error) are + * reported. + * + * "response" is NULL + * + * FIXME would like request that specified RP-ACK/RP-ERROR PDU + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + */ +#define RIL_REQUEST_SMS_ACKNOWLEDGE 37 + +/** + * RIL_REQUEST_GET_IMEI - DEPRECATED + * + * Get the device IMEI, including check digit + * + * The request is DEPRECATED, use RIL_REQUEST_DEVICE_IDENTITY + * Valid when RadioState is not RADIO_STATE_UNAVAILABLE + * + * "data" is NULL + * "response" is a const char * containing the IMEI + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + */ + +#define RIL_REQUEST_GET_IMEI 38 + +/** + * RIL_REQUEST_GET_IMEISV - DEPRECATED + * + * Get the device IMEISV, which should be two decimal digits + * + * The request is DEPRECATED, use RIL_REQUEST_DEVICE_IDENTITY + * Valid when RadioState is not RADIO_STATE_UNAVAILABLE + * + * "data" is NULL + * "response" is a const char * containing the IMEISV + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + */ + +#define RIL_REQUEST_GET_IMEISV 39 + + +/** + * RIL_REQUEST_ANSWER + * + * Answer incoming call + * + * Will not be called for WAITING calls. + * RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE will be used in this case + * instead + * + * "data" is NULL + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + */ + +#define RIL_REQUEST_ANSWER 40 + +/** + * RIL_REQUEST_DEACTIVATE_DATA_CALL + * + * Deactivate packet data connection and remove from the + * data call list if SUCCESS is returned. Any other return + * values should also try to remove the call from the list, + * but that may not be possible. In any event a + * RIL_REQUEST_RADIO_POWER off/on must clear the list. An + * RIL_UNSOL_DATA_CALL_LIST_CHANGED is not expected to be + * issued because of an RIL_REQUEST_DEACTIVATE_DATA_CALL. + * + * "data" is const char ** + * ((char**)data)[0] indicating CID + * ((char**)data)[1] indicating Disconnect Reason + * 0 => No specific reason specified + * 1 => Radio shutdown requested + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + * See also: RIL_REQUEST_SETUP_DATA_CALL + */ +#define RIL_REQUEST_DEACTIVATE_DATA_CALL 41 + +/** + * RIL_REQUEST_QUERY_FACILITY_LOCK + * + * Query the status of a facility lock state + * + * "data" is const char ** + * ((const char **)data)[0] is the facility string code from TS 27.007 7.4 + * (eg "AO" for BAOC, "SC" for SIM lock) + * ((const char **)data)[1] is the password, or "" if not required + * ((const char **)data)[2] is the TS 27.007 service class bit vector of + * services to query + * ((const char **)data)[3] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value. + * This is only applicable in the case of Fixed Dialing Numbers + * (FDN) requests. + * + * "response" is an int * + * ((const int *)response) 0 is the TS 27.007 service class bit vector of + * services for which the specified barring facility + * is active. "0" means "disabled for all" + * + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_QUERY_FACILITY_LOCK 42 + +/** + * RIL_REQUEST_SET_FACILITY_LOCK + * + * Enable/disable one facility lock + * + * "data" is const char ** + * + * ((const char **)data)[0] = facility string code from TS 27.007 7.4 + * (eg "AO" for BAOC) + * ((const char **)data)[1] = "0" for "unlock" and "1" for "lock" + * ((const char **)data)[2] = password + * ((const char **)data)[3] = string representation of decimal TS 27.007 + * service class bit vector. Eg, the string + * "1" means "set this facility for voice services" + * ((const char **)data)[4] = AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value. + * This is only applicable in the case of Fixed Dialing Numbers + * (FDN) requests. + * + * "response" is int * + * ((int *)response)[0] is the number of retries remaining, or -1 if unknown + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_SET_FACILITY_LOCK 43 + +/** + * RIL_REQUEST_CHANGE_BARRING_PASSWORD + * + * Change call barring facility password + * + * "data" is const char ** + * + * ((const char **)data)[0] = facility string code from TS 27.007 7.4 + * (eg "AO" for BAOC) + * ((const char **)data)[1] = old password + * ((const char **)data)[2] = new password + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_CHANGE_BARRING_PASSWORD 44 + +/** + * RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE + * + * Query current network selectin mode + * + * "data" is NULL + * + * "response" is int * + * ((const int *)response)[0] is + * 0 for automatic selection + * 1 for manual selection + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE 45 + +/** + * RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC + * + * Specify that the network should be selected automatically + * + * "data" is NULL + * "response" is NULL + * + * This request must not respond until the new operator is selected + * and registered + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * ILLEGAL_SIM_OR_ME + * GENERIC_FAILURE + * + * Note: Returns ILLEGAL_SIM_OR_ME when the failure is permanent and + * no retries needed, such as illegal SIM or ME. + * Returns GENERIC_FAILURE for all other causes that might be + * fixed by retries. + * + */ +#define RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC 46 + +/** + * RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL + * + * Manually select a specified network. + * + * "data" is const char * specifying MCCMNC of network to select (eg "310170") + * "response" is NULL + * + * This request must not respond until the new operator is selected + * and registered + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * ILLEGAL_SIM_OR_ME + * GENERIC_FAILURE + * + * Note: Returns ILLEGAL_SIM_OR_ME when the failure is permanent and + * no retries needed, such as illegal SIM or ME. + * Returns GENERIC_FAILURE for all other causes that might be + * fixed by retries. + * + */ +#define RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL 47 + +/** + * RIL_REQUEST_QUERY_AVAILABLE_NETWORKS + * + * Scans for available networks + * + * "data" is NULL + * "response" is const char ** that should be an array of n*4 strings, where + * n is the number of available networks + * For each available network: + * + * ((const char **)response)[n+0] is long alpha ONS or EONS + * ((const char **)response)[n+1] is short alpha ONS or EONS + * ((const char **)response)[n+2] is 5 or 6 digit numeric code (MCC + MNC) + * ((const char **)response)[n+3] is a string value of the status: + * "unknown" + * "available" + * "current" + * "forbidden" + * + * This request must not respond until the new operator is selected + * and registered + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_QUERY_AVAILABLE_NETWORKS 48 + +/** + * RIL_REQUEST_DTMF_START + * + * Start playing a DTMF tone. Continue playing DTMF tone until + * RIL_REQUEST_DTMF_STOP is received + * + * If a RIL_REQUEST_DTMF_START is received while a tone is currently playing, + * it should cancel the previous tone and play the new one. + * + * "data" is a char * + * ((char *)data)[0] is a single character with one of 12 values: 0-9,*,# + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + * See also: RIL_REQUEST_DTMF, RIL_REQUEST_DTMF_STOP + */ +#define RIL_REQUEST_DTMF_START 49 + +/** + * RIL_REQUEST_DTMF_STOP + * + * Stop playing a currently playing DTMF tone. + * + * "data" is NULL + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + * See also: RIL_REQUEST_DTMF, RIL_REQUEST_DTMF_START + */ +#define RIL_REQUEST_DTMF_STOP 50 + +/** + * RIL_REQUEST_BASEBAND_VERSION + * + * Return string value indicating baseband version, eg + * response from AT+CGMR + * + * "data" is NULL + * "response" is const char * containing version string for log reporting + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_BASEBAND_VERSION 51 + +/** + * RIL_REQUEST_SEPARATE_CONNECTION + * + * Separate a party from a multiparty call placing the multiparty call + * (less the specified party) on hold and leaving the specified party + * as the only other member of the current (active) call + * + * Like AT+CHLD=2x + * + * See TS 22.084 1.3.8.2 (iii) + * TS 22.030 6.5.5 "Entering "2X followed by send" + * TS 27.007 "AT+CHLD=2x" + * + * "data" is an int * + * (int *)data)[0] contains Connection index (value of 'x' in CHLD above) "response" is NULL + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + */ +#define RIL_REQUEST_SEPARATE_CONNECTION 52 + + +/** + * RIL_REQUEST_SET_MUTE + * + * Turn on or off uplink (microphone) mute. + * + * Will only be sent while voice call is active. + * Will always be reset to "disable mute" when a new voice call is initiated + * + * "data" is an int * + * (int *)data)[0] is 1 for "enable mute" and 0 for "disable mute" + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + */ + +#define RIL_REQUEST_SET_MUTE 53 + +/** + * RIL_REQUEST_GET_MUTE + * + * Queries the current state of the uplink mute setting + * + * "data" is NULL + * "response" is an int * + * (int *)response)[0] is 1 for "mute enabled" and 0 for "mute disabled" + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + */ + +#define RIL_REQUEST_GET_MUTE 54 + +/** + * RIL_REQUEST_QUERY_CLIP + * + * Queries the status of the CLIP supplementary service + * + * (for MMI code "*#30#") + * + * "data" is NULL + * "response" is an int * + * (int *)response)[0] is 1 for "CLIP provisioned" + * and 0 for "CLIP not provisioned" + * and 2 for "unknown, e.g. no network etc" + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + */ + +#define RIL_REQUEST_QUERY_CLIP 55 + +/** + * RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE - Deprecated use the status + * field in RIL_Data_Call_Response_v6. + * + * Requests the failure cause code for the most recently failed PDP + * context or CDMA data connection active + * replaces RIL_REQUEST_LAST_PDP_FAIL_CAUSE + * + * "data" is NULL + * + * "response" is a "int *" + * ((int *)response)[0] is an integer cause code defined in TS 24.008 + * section 6.1.3.1.3 or close approximation + * + * If the implementation does not have access to the exact cause codes, + * then it should return one of the values listed in + * RIL_DataCallFailCause, as the UI layer needs to distinguish these + * cases for error notification + * and potential retries. + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + * See also: RIL_REQUEST_LAST_CALL_FAIL_CAUSE + * + * Deprecated use the status field in RIL_Data_Call_Response_v6. + */ + +#define RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE 56 + +/** + * RIL_REQUEST_DATA_CALL_LIST + * + * Returns the data call list. An entry is added when a + * RIL_REQUEST_SETUP_DATA_CALL is issued and removed on a + * RIL_REQUEST_DEACTIVATE_DATA_CALL. The list is emptied + * when RIL_REQUEST_RADIO_POWER off/on is issued. + * + * "data" is NULL + * "response" is an array of RIL_Data_Call_Response_v6 + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + * + * See also: RIL_UNSOL_DATA_CALL_LIST_CHANGED + */ + +#define RIL_REQUEST_DATA_CALL_LIST 57 + +/** + * RIL_REQUEST_RESET_RADIO - DEPRECATED + * + * Request a radio reset. The RIL implementation may postpone + * the reset until after this request is responded to if the baseband + * is presently busy. + * + * The request is DEPRECATED, use RIL_REQUEST_RADIO_POWER + * + * "data" is NULL + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + * REQUEST_NOT_SUPPORTED + */ + +#define RIL_REQUEST_RESET_RADIO 58 + +/** + * RIL_REQUEST_OEM_HOOK_RAW + * + * This request reserved for OEM-specific uses. It passes raw byte arrays + * back and forth. + * + * It can be invoked on the Java side from + * com.android.internal.telephony.Phone.invokeOemRilRequestRaw() + * + * "data" is a char * of bytes copied from the byte[] data argument in java + * "response" is a char * of bytes that will returned via the + * caller's "response" Message here: + * (byte[])(((AsyncResult)response.obj).result) + * + * An error response here will result in + * (((AsyncResult)response.obj).result) == null and + * (((AsyncResult)response.obj).exception) being an instance of + * com.android.internal.telephony.gsm.CommandException + * + * Valid errors: + * All + */ + +#define RIL_REQUEST_OEM_HOOK_RAW 59 + +/** + * RIL_REQUEST_OEM_HOOK_STRINGS + * + * This request reserved for OEM-specific uses. It passes strings + * back and forth. + * + * It can be invoked on the Java side from + * com.android.internal.telephony.Phone.invokeOemRilRequestStrings() + * + * "data" is a const char **, representing an array of null-terminated UTF-8 + * strings copied from the "String[] strings" argument to + * invokeOemRilRequestStrings() + * + * "response" is a const char **, representing an array of null-terminated UTF-8 + * stings that will be returned via the caller's response message here: + * + * (String[])(((AsyncResult)response.obj).result) + * + * An error response here will result in + * (((AsyncResult)response.obj).result) == null and + * (((AsyncResult)response.obj).exception) being an instance of + * com.android.internal.telephony.gsm.CommandException + * + * Valid errors: + * All + */ + +#define RIL_REQUEST_OEM_HOOK_STRINGS 60 + +/** + * RIL_REQUEST_SCREEN_STATE + * + * Indicates the current state of the screen. When the screen is off, the + * RIL should notify the baseband to suppress certain notifications (eg, + * signal strength and changes in LAC/CID or BID/SID/NID/latitude/longitude) + * in an effort to conserve power. These notifications should resume when the + * screen is on. + * + * "data" is int * + * ((int *)data)[0] is == 1 for "Screen On" + * ((int *)data)[0] is == 0 for "Screen Off" + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * GENERIC_FAILURE + */ +#define RIL_REQUEST_SCREEN_STATE 61 + + +/** + * RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION + * + * Enables/disables supplementary service related notifications + * from the network. + * + * Notifications are reported via RIL_UNSOL_SUPP_SVC_NOTIFICATION. + * + * "data" is int * + * ((int *)data)[0] is == 1 for notifications enabled + * ((int *)data)[0] is == 0 for notifications disabled + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + * See also: RIL_UNSOL_SUPP_SVC_NOTIFICATION. + */ +#define RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION 62 + +/** + * RIL_REQUEST_WRITE_SMS_TO_SIM + * + * Stores a SMS message to SIM memory. + * + * "data" is RIL_SMS_WriteArgs * + * + * "response" is int * + * ((const int *)response)[0] is the record index where the message is stored. + * + * Valid errors: + * SUCCESS + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_WRITE_SMS_TO_SIM 63 + +/** + * RIL_REQUEST_DELETE_SMS_ON_SIM + * + * Deletes a SMS message from SIM memory. + * + * "data" is int * + * ((int *)data)[0] is the record index of the message to delete. + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_DELETE_SMS_ON_SIM 64 + +/** + * RIL_REQUEST_SET_BAND_MODE + * + * Assign a specified band for RF configuration. + * + * "data" is int * + * ((int *)data)[0] is == 0 for "unspecified" (selected by baseband automatically) + * ((int *)data)[0] is == 1 for "EURO band" (GSM-900 / DCS-1800 / WCDMA-IMT-2000) + * ((int *)data)[0] is == 2 for "US band" (GSM-850 / PCS-1900 / WCDMA-850 / WCDMA-PCS-1900) + * ((int *)data)[0] is == 3 for "JPN band" (WCDMA-800 / WCDMA-IMT-2000) + * ((int *)data)[0] is == 4 for "AUS band" (GSM-900 / DCS-1800 / WCDMA-850 / WCDMA-IMT-2000) + * ((int *)data)[0] is == 5 for "AUS band 2" (GSM-900 / DCS-1800 / WCDMA-850) + * ((int *)data)[0] is == 6 for "Cellular (800-MHz Band)" + * ((int *)data)[0] is == 7 for "PCS (1900-MHz Band)" + * ((int *)data)[0] is == 8 for "Band Class 3 (JTACS Band)" + * ((int *)data)[0] is == 9 for "Band Class 4 (Korean PCS Band)" + * ((int *)data)[0] is == 10 for "Band Class 5 (450-MHz Band)" + * ((int *)data)[0] is == 11 for "Band Class 6 (2-GMHz IMT2000 Band)" + * ((int *)data)[0] is == 12 for "Band Class 7 (Upper 700-MHz Band)" + * ((int *)data)[0] is == 13 for "Band Class 8 (1800-MHz Band)" + * ((int *)data)[0] is == 14 for "Band Class 9 (900-MHz Band)" + * ((int *)data)[0] is == 15 for "Band Class 10 (Secondary 800-MHz Band)" + * ((int *)data)[0] is == 16 for "Band Class 11 (400-MHz European PAMR Band)" + * ((int *)data)[0] is == 17 for "Band Class 15 (AWS Band)" + * ((int *)data)[0] is == 18 for "Band Class 16 (US 2.5-GHz Band)" + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + */ +#define RIL_REQUEST_SET_BAND_MODE 65 + +/** + * RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE + * + * Query the list of band mode supported by RF. + * + * "data" is NULL + * + * "response" is int * + * "response" points to an array of int's, the int[0] is the size of array, reset is one for + * each available band mode. + * + * 0 for "unspecified" (selected by baseband automatically) + * 1 for "EURO band" (GSM-900 / DCS-1800 / WCDMA-IMT-2000) + * 2 for "US band" (GSM-850 / PCS-1900 / WCDMA-850 / WCDMA-PCS-1900) + * 3 for "JPN band" (WCDMA-800 / WCDMA-IMT-2000) + * 4 for "AUS band" (GSM-900 / DCS-1800 / WCDMA-850 / WCDMA-IMT-2000) + * 5 for "AUS band 2" (GSM-900 / DCS-1800 / WCDMA-850) + * 6 for "Cellular (800-MHz Band)" + * 7 for "PCS (1900-MHz Band)" + * 8 for "Band Class 3 (JTACS Band)" + * 9 for "Band Class 4 (Korean PCS Band)" + * 10 for "Band Class 5 (450-MHz Band)" + * 11 for "Band Class 6 (2-GMHz IMT2000 Band)" + * 12 for "Band Class 7 (Upper 700-MHz Band)" + * 13 for "Band Class 8 (1800-MHz Band)" + * 14 for "Band Class 9 (900-MHz Band)" + * 15 for "Band Class 10 (Secondary 800-MHz Band)" + * 16 for "Band Class 11 (400-MHz European PAMR Band)" + * 17 for "Band Class 15 (AWS Band)" + * 18 for "Band Class 16 (US 2.5-GHz Band)" + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + * See also: RIL_REQUEST_SET_BAND_MODE + */ +#define RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE 66 + +/** + * RIL_REQUEST_STK_GET_PROFILE + * + * Requests the profile of SIM tool kit. + * The profile indicates the SAT/USAT features supported by ME. + * The SAT/USAT features refer to 3GPP TS 11.14 and 3GPP TS 31.111 + * + * "data" is NULL + * + * "response" is a const char * containing SAT/USAT profile + * in hexadecimal format string starting with first byte of terminal profile + * + * Valid errors: + * RIL_E_SUCCESS + * RIL_E_RADIO_NOT_AVAILABLE (radio resetting) + * RIL_E_GENERIC_FAILURE + */ +#define RIL_REQUEST_STK_GET_PROFILE 67 + +/** + * RIL_REQUEST_STK_SET_PROFILE + * + * Download the STK terminal profile as part of SIM initialization + * procedure + * + * "data" is a const char * containing SAT/USAT profile + * in hexadecimal format string starting with first byte of terminal profile + * + * "response" is NULL + * + * Valid errors: + * RIL_E_SUCCESS + * RIL_E_RADIO_NOT_AVAILABLE (radio resetting) + * RIL_E_GENERIC_FAILURE + */ +#define RIL_REQUEST_STK_SET_PROFILE 68 + +/** + * RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND + * + * Requests to send a SAT/USAT envelope command to SIM. + * The SAT/USAT envelope command refers to 3GPP TS 11.14 and 3GPP TS 31.111 + * + * "data" is a const char * containing SAT/USAT command + * in hexadecimal format string starting with command tag + * + * "response" is a const char * containing SAT/USAT response + * in hexadecimal format string starting with first byte of response + * (May be NULL) + * + * Valid errors: + * RIL_E_SUCCESS + * RIL_E_RADIO_NOT_AVAILABLE (radio resetting) + * RIL_E_GENERIC_FAILURE + */ +#define RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND 69 + +/** + * RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE + * + * Requests to send a terminal response to SIM for a received + * proactive command + * + * "data" is a const char * containing SAT/USAT response + * in hexadecimal format string starting with first byte of response data + * + * "response" is NULL + * + * Valid errors: + * RIL_E_SUCCESS + * RIL_E_RADIO_NOT_AVAILABLE (radio resetting) + * RIL_E_GENERIC_FAILURE + */ +#define RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE 70 + +/** + * RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM + * + * When STK application gets RIL_UNSOL_STK_CALL_SETUP, the call actually has + * been initialized by ME already. (We could see the call has been in the 'call + * list') So, STK application needs to accept/reject the call according as user + * operations. + * + * "data" is int * + * ((int *)data)[0] is > 0 for "accept" the call setup + * ((int *)data)[0] is == 0 for "reject" the call setup + * + * "response" is NULL + * + * Valid errors: + * RIL_E_SUCCESS + * RIL_E_RADIO_NOT_AVAILABLE (radio resetting) + * RIL_E_GENERIC_FAILURE + */ +#define RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM 71 + +/** + * RIL_REQUEST_EXPLICIT_CALL_TRANSFER + * + * Connects the two calls and disconnects the subscriber from both calls. + * + * "data" is NULL + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + */ +#define RIL_REQUEST_EXPLICIT_CALL_TRANSFER 72 + +/** + * RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE + * + * Requests to set the preferred network type for searching and registering + * (CS/PS domain, RAT, and operation mode) + * + * "data" is int * which is RIL_PreferredNetworkType + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * GENERIC_FAILURE + * MODE_NOT_SUPPORTED + */ +#define RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE 73 + +/** + * RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE + * + * Query the preferred network type (CS/PS domain, RAT, and operation mode) + * for searching and registering + * + * "data" is NULL + * + * "response" is int * + * ((int *)reponse)[0] is == RIL_PreferredNetworkType + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + * See also: RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE + */ +#define RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE 74 + +/** + * RIL_REQUEST_NEIGHBORING_CELL_IDS + * + * Request neighboring cell id in GSM network + * + * "data" is NULL + * "response" must be a " const RIL_NeighboringCell** " + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + */ +#define RIL_REQUEST_GET_NEIGHBORING_CELL_IDS 75 + +/** + * RIL_REQUEST_SET_LOCATION_UPDATES + * + * Enables/disables network state change notifications due to changes in + * LAC and/or CID (for GSM) or BID/SID/NID/latitude/longitude (for CDMA). + * Basically +CREG=2 vs. +CREG=1 (TS 27.007). + * + * Note: The RIL implementation should default to "updates enabled" + * when the screen is on and "updates disabled" when the screen is off. + * + * "data" is int * + * ((int *)data)[0] is == 1 for updates enabled (+CREG=2) + * ((int *)data)[0] is == 0 for updates disabled (+CREG=1) + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + * See also: RIL_REQUEST_SCREEN_STATE, RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED + */ +#define RIL_REQUEST_SET_LOCATION_UPDATES 76 + +/** + * RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE + * + * Request to set the location where the CDMA subscription shall + * be retrieved + * + * "data" is int * + * ((int *)data)[0] is == RIL_CdmaSubscriptionSource + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * SIM_ABSENT + * SUBSCRIPTION_NOT_AVAILABLE + * + * See also: RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE + */ +#define RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE 77 + +/** + * RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE + * + * Request to set the roaming preferences in CDMA + * + * "data" is int * + * ((int *)data)[0] is == 0 for Home Networks only, as defined in PRL + * ((int *)data)[0] is == 1 for Roaming on Affiliated networks, as defined in PRL + * ((int *)data)[0] is == 2 for Roaming on Any Network, as defined in the PRL + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + */ +#define RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE 78 + +/** + * RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE + * + * Request the actual setting of the roaming preferences in CDMA in the modem + * + * "data" is NULL + * + * "response" is int * + * ((int *)response)[0] is == 0 for Home Networks only, as defined in PRL + * ((int *)response)[0] is == 1 for Roaming on Affiliated networks, as defined in PRL + * ((int *)response)[0] is == 2 for Roaming on Any Network, as defined in the PRL + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + */ +#define RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE 79 + +/** + * RIL_REQUEST_SET_TTY_MODE + * + * Request to set the TTY mode + * + * "data" is int * + * ((int *)data)[0] is == 0 for TTY off + * ((int *)data)[0] is == 1 for TTY Full + * ((int *)data)[0] is == 2 for TTY HCO (hearing carryover) + * ((int *)data)[0] is == 3 for TTY VCO (voice carryover) + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + */ +#define RIL_REQUEST_SET_TTY_MODE 80 + +/** + * RIL_REQUEST_QUERY_TTY_MODE + * + * Request the setting of TTY mode + * + * "data" is NULL + * + * "response" is int * + * ((int *)response)[0] is == 0 for TTY off + * ((int *)response)[0] is == 1 for TTY Full + * ((int *)response)[0] is == 2 for TTY HCO (hearing carryover) + * ((int *)response)[0] is == 3 for TTY VCO (voice carryover) + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + */ +#define RIL_REQUEST_QUERY_TTY_MODE 81 + +/** + * RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE + * + * Request to set the preferred voice privacy mode used in voice + * scrambling + * + * "data" is int * + * ((int *)data)[0] is == 0 for Standard Privacy Mode (Public Long Code Mask) + * ((int *)data)[0] is == 1 for Enhanced Privacy Mode (Private Long Code Mask) + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + */ +#define RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE 82 + +/** + * RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE + * + * Request the setting of preferred voice privacy mode + * + * "data" is NULL + * + * "response" is int * + * ((int *)response)[0] is == 0 for Standard Privacy Mode (Public Long Code Mask) + * ((int *)response)[0] is == 1 for Enhanced Privacy Mode (Private Long Code Mask) + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + */ +#define RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE 83 + +/** + * RIL_REQUEST_CDMA_FLASH + * + * Send FLASH + * + * "data" is const char * + * ((const char *)data)[0] is a FLASH string + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_CDMA_FLASH 84 + +/** + * RIL_REQUEST_CDMA_BURST_DTMF + * + * Send DTMF string + * + * "data" is const char ** + * ((const char **)data)[0] is a DTMF string + * ((const char **)data)[1] is the DTMF ON length in milliseconds, or 0 to use + * default + * ((const char **)data)[2] is the DTMF OFF length in milliseconds, or 0 to use + * default + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_CDMA_BURST_DTMF 85 + +/** + * RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY + * + * Takes a 26 digit string (20 digit AKEY + 6 digit checksum). + * If the checksum is valid the 20 digit AKEY is written to NV, + * replacing the existing AKEY no matter what it was before. + * + * "data" is const char * + * ((const char *)data)[0] is a 26 digit string (ASCII digits '0'-'9') + * where the last 6 digits are a checksum of the + * first 20, as specified in TR45.AHAG + * "Common Cryptographic Algorithms, Revision D.1 + * Section 2.2" + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY 86 + +/** + * RIL_REQUEST_CDMA_SEND_SMS + * + * Send a CDMA SMS message + * + * "data" is const RIL_CDMA_SMS_Message * + * + * "response" is a const RIL_SMS_Response * + * + * Based on the return error, caller decides to resend if sending sms + * fails. The CDMA error class is derived as follows, + * SUCCESS is error class 0 (no error) + * SMS_SEND_FAIL_RETRY is error class 2 (temporary failure) + * and GENERIC_FAILURE is error class 3 (permanent and no retry) + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * SMS_SEND_FAIL_RETRY + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_CDMA_SEND_SMS 87 + +/** + * RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE + * + * Acknowledge the success or failure in the receipt of SMS + * previously indicated via RIL_UNSOL_RESPONSE_CDMA_NEW_SMS + * + * "data" is const RIL_CDMA_SMS_Ack * + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE 88 + +/** + * RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG + * + * Request the setting of GSM/WCDMA Cell Broadcast SMS config. + * + * "data" is NULL + * + * "response" is a const RIL_GSM_BroadcastSmsConfigInfo ** + * "responselen" is count * sizeof (RIL_GSM_BroadcastSmsConfigInfo *) + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG 89 + +/** + * RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG + * + * Set GSM/WCDMA Cell Broadcast SMS config + * + * "data" is a const RIL_GSM_BroadcastSmsConfigInfo ** + * "datalen" is count * sizeof(RIL_GSM_BroadcastSmsConfigInfo *) + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG 90 + +/** + * RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION + * +* Enable or disable the reception of GSM/WCDMA Cell Broadcast SMS + * + * "data" is const int * + * (const int *)data[0] indicates to activate or turn off the + * reception of GSM/WCDMA Cell Broadcast SMS, 0-1, + * 0 - Activate, 1 - Turn off + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION 91 + +/** + * RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG + * + * Request the setting of CDMA Broadcast SMS config + * + * "data" is NULL + * + * "response" is a const RIL_CDMA_BroadcastSmsConfigInfo ** + * "responselen" is count * sizeof (RIL_CDMA_BroadcastSmsConfigInfo *) + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG 92 + +/** + * RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG + * + * Set CDMA Broadcast SMS config + * + * "data" is an const RIL_CDMA_BroadcastSmsConfigInfo ** + * "datalen" is count * sizeof(const RIL_CDMA_BroadcastSmsConfigInfo *) + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG 93 + +/** + * RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION + * + * Enable or disable the reception of CDMA Broadcast SMS + * + * "data" is const int * + * (const int *)data[0] indicates to activate or turn off the + * reception of CDMA Broadcast SMS, 0-1, + * 0 - Activate, 1 - Turn off + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION 94 + +/** + * RIL_REQUEST_CDMA_SUBSCRIPTION + * + * Request the device MDN / H_SID / H_NID. + * + * The request is only allowed when CDMA subscription is available. When CDMA + * subscription is changed, application layer should re-issue the request to + * update the subscription information. + * + * If a NULL value is returned for any of the device id, it means that error + * accessing the device. + * + * "response" is const char ** + * ((const char **)response)[0] is MDN if CDMA subscription is available + * ((const char **)response)[1] is a comma separated list of H_SID (Home SID) if + * CDMA subscription is available, in decimal format + * ((const char **)response)[2] is a comma separated list of H_NID (Home NID) if + * CDMA subscription is available, in decimal format + * ((const char **)response)[3] is MIN (10 digits, MIN2+MIN1) if CDMA subscription is available + * ((const char **)response)[4] is PRL version if CDMA subscription is available + * + * Valid errors: + * SUCCESS + * RIL_E_SUBSCRIPTION_NOT_AVAILABLE + */ + +#define RIL_REQUEST_CDMA_SUBSCRIPTION 95 + +/** + * RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM + * + * Stores a CDMA SMS message to RUIM memory. + * + * "data" is RIL_CDMA_SMS_WriteArgs * + * + * "response" is int * + * ((const int *)response)[0] is the record index where the message is stored. + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM 96 + +/** + * RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM + * + * Deletes a CDMA SMS message from RUIM memory. + * + * "data" is int * + * ((int *)data)[0] is the record index of the message to delete. + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM 97 + +/** + * RIL_REQUEST_DEVICE_IDENTITY + * + * Request the device ESN / MEID / IMEI / IMEISV. + * + * The request is always allowed and contains GSM and CDMA device identity; + * it substitutes the deprecated requests RIL_REQUEST_GET_IMEI and + * RIL_REQUEST_GET_IMEISV. + * + * If a NULL value is returned for any of the device id, it means that error + * accessing the device. + * + * When CDMA subscription is changed the ESN/MEID may change. The application + * layer should re-issue the request to update the device identity in this case. + * + * "response" is const char ** + * ((const char **)response)[0] is IMEI if GSM subscription is available + * ((const char **)response)[1] is IMEISV if GSM subscription is available + * ((const char **)response)[2] is ESN if CDMA subscription is available + * ((const char **)response)[3] is MEID if CDMA subscription is available + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + */ +#define RIL_REQUEST_DEVICE_IDENTITY 98 + +/** + * RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE + * + * Request the radio's system selection module to exit emergency + * callback mode. RIL will not respond with SUCCESS until the modem has + * completely exited from Emergency Callback Mode. + * + * "data" is NULL + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE 99 + +/** + * RIL_REQUEST_GET_SMSC_ADDRESS + * + * Queries the default Short Message Service Center address on the device. + * + * "data" is NULL + * + * "response" is const char * containing the SMSC address. + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_GET_SMSC_ADDRESS 100 + +/** + * RIL_REQUEST_SET_SMSC_ADDRESS + * + * Sets the default Short Message Service Center address on the device. + * + * "data" is const char * containing the SMSC address. + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_SET_SMSC_ADDRESS 101 + +/** + * RIL_REQUEST_REPORT_SMS_MEMORY_STATUS + * + * Indicates whether there is storage available for new SMS messages. + * + * "data" is int * + * ((int *)data)[0] is 1 if memory is available for storing new messages + * is 0 if memory capacity is exceeded + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_REPORT_SMS_MEMORY_STATUS 102 + +/** + * RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING + * + * Indicates that the StkSerivce is running and is + * ready to receive RIL_UNSOL_STK_XXXXX commands. + * + * "data" is NULL + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * + */ +#define RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING 103 + +/** + * RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE + * + * Request to query the location where the CDMA subscription shall + * be retrieved + * + * "data" is NULL + * + * "response" is int * + * ((int *)data)[0] is == RIL_CdmaSubscriptionSource + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + * SUBSCRIPTION_NOT_AVAILABLE + * + * See also: RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE + */ +#define RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE 104 + +/** + * RIL_REQUEST_ISIM_AUTHENTICATION + * + * Request the ISIM application on the UICC to perform AKA + * challenge/response algorithm for IMS authentication + * + * "data" is a const char * containing the challenge string in Base64 format + * "response" is a const char * containing the response in Base64 format + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + */ +#define RIL_REQUEST_ISIM_AUTHENTICATION 105 + +/** + * RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU + * + * Acknowledge successful or failed receipt of SMS previously indicated + * via RIL_UNSOL_RESPONSE_NEW_SMS, including acknowledgement TPDU to send + * as the RP-User-Data element of the RP-ACK or RP-ERROR PDU. + * + * "data" is const char ** + * ((const char **)data)[0] is "1" on successful receipt (send RP-ACK) + * is "0" on failed receipt (send RP-ERROR) + * ((const char **)data)[1] is the acknowledgement TPDU in hexadecimal format + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + */ +#define RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU 106 + +/** + * RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS + * + * Requests to send a SAT/USAT envelope command to SIM. + * The SAT/USAT envelope command refers to 3GPP TS 11.14 and 3GPP TS 31.111. + * + * This request has one difference from RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: + * the SW1 and SW2 status bytes from the UICC response are returned along with + * the response data, using the same structure as RIL_REQUEST_SIM_IO. + * + * The RIL implementation shall perform the normal processing of a '91XX' + * response in SW1/SW2 to retrieve the pending proactive command and send it + * as an unsolicited response, as RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND does. + * + * "data" is a const char * containing the SAT/USAT command + * in hexadecimal format starting with command tag + * + * "response" is a const RIL_SIM_IO_Response * + * + * Valid errors: + * RIL_E_SUCCESS + * RIL_E_RADIO_NOT_AVAILABLE (radio resetting) + * RIL_E_GENERIC_FAILURE + */ +#define RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS 107 + +/** + * RIL_REQUEST_VOICE_RADIO_TECH + * + * Query the radio technology type (3GPP/3GPP2) used for voice. Query is valid only + * when radio state is RADIO_STATE_ON + * + * "data" is NULL + * "response" is int * + * ((int *) response)[0] is of type const RIL_RadioTechnology + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * GENERIC_FAILURE + */ +#define RIL_REQUEST_VOICE_RADIO_TECH 108 + +/* SAMSUNG REQUESTS */ +#define RIL_REQUEST_GET_CELL_BROADCAST_CONFIG 10002 + +#define RIL_REQUEST_SEND_ENCODED_USSD 10005 +#define RIL_REQUEST_SET_PDA_MEMORY_STATUS 10006 +#define RIL_REQUEST_GET_PHONEBOOK_STORAGE_INFO 10007 +#define RIL_REQUEST_GET_PHONEBOOK_ENTRY 10008 +#define RIL_REQUEST_ACCESS_PHONEBOOK_ENTRY 10009 +#define RIL_REQUEST_DIAL_VIDEO_CALL 10010 +#define RIL_REQUEST_CALL_DEFLECTION 10011 +#define RIL_REQUEST_READ_SMS_FROM_SIM 10012 +#define RIL_REQUEST_USIM_PB_CAPA 10013 +#define RIL_REQUEST_LOCK_INFO 10014 + +#define RIL_REQUEST_DIAL_EMERGENCY 10016 +#define RIL_REQUEST_GET_STOREAD_MSG_COUNT 10017 +#define RIL_REQUEST_STK_SIM_INIT_EVENT 10018 +#define RIL_REQUEST_GET_LINE_ID 10019 +#define RIL_REQUEST_SET_LINE_ID 10020 +#define RIL_REQUEST_GET_SERIAL_NUMBER 10021 +#define RIL_REQUEST_GET_MANUFACTURE_DATE_NUMBER 10022 +#define RIL_REQUEST_GET_BARCODE_NUMBER 10023 +#define RIL_REQUEST_UICC_GBA_AUTHENTICATE_BOOTSTRAP 10024 +#define RIL_REQUEST_UICC_GBA_AUTHENTICATE_NAF 10025 +#define RIL_REQUEST_SIM_TRANSMIT_BASIC 10026 +#define RIL_REQUEST_SIM_OPEN_CHANNEL 10027 +#define RIL_REQUEST_SIM_CLOSE_CHANNEL 10028 +#define RIL_REQUEST_SIM_TRANSMIT_CHANNEL 10029 +#define RIL_REQUEST_SIM_AUTH 10030 +#define RIL_REQUEST_PS_ATTACH 10031 +#define RIL_REQUEST_PS_DETACH 10032 +#define RIL_REQUEST_ACTIVATE_DATA_CALL 10033 +#define RIL_REQUEST_CHANGE_SIM_PERSO 10034 +#define RIL_REQUEST_ENTER_SIM_PERSO 10035 +#define RIL_REQUEST_GET_TIME_INFO 10036 +#define RIL_REQUEST_OMADM_SETUP_SESSION 10037 +#define RIL_REQUEST_OMADM_SERVER_START_SESSION 10038 +#define RIL_REQUEST_OMADM_CLIENT_START_SESSION 10039 +#define RIL_REQUEST_OMADM_SEND_DATA 10040 +#define RIL_REQUEST_CDMA_GET_DATAPROFILE 10041 +#define RIL_REQUEST_CDMA_SET_DATAPROFILE 10042 +#define RIL_REQUEST_CDMA_GET_SYSTEMPROPERTIES 10043 +#define RIL_REQUEST_CDMA_SET_SYSTEMPROPERTIES 10044 +#define RIL_REQUEST_SEND_SMS_COUNT 10045 +#define RIL_REQUEST_SEND_SMS_MSG 10046 +#define RIL_REQUEST_SEND_SMS_MSG_READ_STATUS 10047 +#define RIL_REQUEST_MODEM_HANGUP 10048 +#define RIL_REQUEST_SET_SIM_POWER 10049 +#define RIL_REQUEST_SET_PREFERRED_NETWORK_LIST 10050 +#define RIL_REQUEST_GET_PREFERRED_NETWORK_LIST 10051 +#define RIL_REQUEST_HANGUP_VT 10052 + +/***********************************************************************/ + + +#define RIL_UNSOL_RESPONSE_BASE 1000 + +/** + * RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED + * + * Indicate when value of RIL_RadioState has changed. + * + * Callee will invoke RIL_RadioStateRequest method on main thread + * + * "data" is NULL + */ + +#define RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED 1000 + + +/** + * RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED + * + * Indicate when call state has changed + * + * Callee will invoke RIL_REQUEST_GET_CURRENT_CALLS on main thread + * + * "data" is NULL + * + * Response should be invoked on, for example, + * "RING", "BUSY", "NO CARRIER", and also call state + * transitions (DIALING->ALERTING ALERTING->ACTIVE) + * + * Redundent or extraneous invocations are tolerated + */ +#define RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED 1001 + + +/** + * RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED + * + * Called when the voice network state changed + * + * Callee will invoke the following requests on main thread: + * + * RIL_REQUEST_VOICE_REGISTRATION_STATE + * RIL_REQUEST_OPERATOR + * + * "data" is NULL + * + * FIXME should this happen when SIM records are loaded? (eg, for + * EONS) + */ +#define RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED 1002 + +/** + * RIL_UNSOL_RESPONSE_NEW_SMS + * + * Called when new SMS is received. + * + * "data" is const char * + * This is a pointer to a string containing the PDU of an SMS-DELIVER + * as an ascii string of hex digits. The PDU starts with the SMSC address + * per TS 27.005 (+CMT:) + * + * Callee will subsequently confirm the receipt of thei SMS with a + * RIL_REQUEST_SMS_ACKNOWLEDGE + * + * No new RIL_UNSOL_RESPONSE_NEW_SMS + * or RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT messages should be sent until a + * RIL_REQUEST_SMS_ACKNOWLEDGE has been received + */ + +#define RIL_UNSOL_RESPONSE_NEW_SMS 1003 + +/** + * RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT + * + * Called when new SMS Status Report is received. + * + * "data" is const char * + * This is a pointer to a string containing the PDU of an SMS-STATUS-REPORT + * as an ascii string of hex digits. The PDU starts with the SMSC address + * per TS 27.005 (+CDS:). + * + * Callee will subsequently confirm the receipt of the SMS with a + * RIL_REQUEST_SMS_ACKNOWLEDGE + * + * No new RIL_UNSOL_RESPONSE_NEW_SMS + * or RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT messages should be sent until a + * RIL_REQUEST_SMS_ACKNOWLEDGE has been received + */ + +#define RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT 1004 + +/** + * RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM + * + * Called when new SMS has been stored on SIM card + * + * "data" is const int * + * ((const int *)data)[0] contains the slot index on the SIM that contains + * the new message + */ + +#define RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM 1005 + +/** + * RIL_UNSOL_ON_USSD + * + * Called when a new USSD message is received. + * + * "data" is const char ** + * ((const char **)data)[0] points to a type code, which is + * one of these string values: + * "0" USSD-Notify -- text in ((const char **)data)[1] + * "1" USSD-Request -- text in ((const char **)data)[1] + * "2" Session terminated by network + * "3" other local client (eg, SIM Toolkit) has responded + * "4" Operation not supported + * "5" Network timeout + * + * The USSD session is assumed to persist if the type code is "1", otherwise + * the current session (if any) is assumed to have terminated. + * + * ((const char **)data)[1] points to a message string if applicable, which + * should always be in UTF-8. + */ +#define RIL_UNSOL_ON_USSD 1006 +/* Previously #define RIL_UNSOL_ON_USSD_NOTIFY 1006 */ + +/** + * RIL_UNSOL_ON_USSD_REQUEST + * + * Obsolete. Send via RIL_UNSOL_ON_USSD + */ +#define RIL_UNSOL_ON_USSD_REQUEST 1007 + + +/** + * RIL_UNSOL_NITZ_TIME_RECEIVED + * + * Called when radio has received a NITZ time message + * + * "data" is const char * pointing to NITZ time string + * in the form "yy/mm/dd,hh:mm:ss(+/-)tz,dt" + */ +#define RIL_UNSOL_NITZ_TIME_RECEIVED 1008 + +/** + * RIL_UNSOL_SIGNAL_STRENGTH + * + * Radio may report signal strength rather han have it polled. + * + * "data" is a const RIL_SignalStrength * + */ +#define RIL_UNSOL_SIGNAL_STRENGTH 1009 + + +/** + * RIL_UNSOL_DATA_CALL_LIST_CHANGED + * + * "data" is an array of RIL_Data_Call_Response_v6 identical to that + * returned by RIL_REQUEST_DATA_CALL_LIST. It is the complete list + * of current data contexts including new contexts that have been + * activated. A data call is only removed from this list when the + * framework sends a RIL_REQUEST_DEACTIVATE_DATA_CALL or the radio + * is powered off/on. + * + * See also: RIL_REQUEST_DATA_CALL_LIST + */ + +#define RIL_UNSOL_DATA_CALL_LIST_CHANGED 1010 + +/** + * RIL_UNSOL_SUPP_SVC_NOTIFICATION + * + * Reports supplementary service related notification from the network. + * + * "data" is a const RIL_SuppSvcNotification * + * + */ + +#define RIL_UNSOL_SUPP_SVC_NOTIFICATION 1011 + +/** + * RIL_UNSOL_STK_SESSION_END + * + * Indicate when STK session is terminated by SIM. + * + * "data" is NULL + */ +#define RIL_UNSOL_STK_SESSION_END 1012 + +/** + * RIL_UNSOL_STK_PROACTIVE_COMMAND + * + * Indicate when SIM issue a STK proactive command to applications + * + * "data" is a const char * containing SAT/USAT proactive command + * in hexadecimal format string starting with command tag + * + */ +#define RIL_UNSOL_STK_PROACTIVE_COMMAND 1013 + +/** + * RIL_UNSOL_STK_EVENT_NOTIFY + * + * Indicate when SIM notifies applcations some event happens. + * Generally, application does not need to have any feedback to + * SIM but shall be able to indicate appropriate messages to users. + * + * "data" is a const char * containing SAT/USAT commands or responses + * sent by ME to SIM or commands handled by ME, in hexadecimal format string + * starting with first byte of response data or command tag + * + */ +#define RIL_UNSOL_STK_EVENT_NOTIFY 1014 + +/** + * RIL_UNSOL_STK_CALL_SETUP + * + * Indicate when SIM wants application to setup a voice call. + * + * "data" is const int * + * ((const int *)data)[0] contains timeout value (in milliseconds) + */ +#define RIL_UNSOL_STK_CALL_SETUP 1015 + +/** + * RIL_UNSOL_SIM_SMS_STORAGE_FULL + * + * Indicates that SMS storage on the SIM is full. Sent when the network + * attempts to deliver a new SMS message. Messages cannot be saved on the + * SIM until space is freed. In particular, incoming Class 2 messages + * cannot be stored. + * + * "data" is null + * + */ +#define RIL_UNSOL_SIM_SMS_STORAGE_FULL 1016 + +/** + * RIL_UNSOL_SIM_REFRESH + * + * Indicates that file(s) on the SIM have been updated, or the SIM + * has been reinitialized. + * + * In the case where RIL is version 6 or older: + * "data" is an int * + * ((int *)data)[0] is a RIL_SimRefreshResult. + * ((int *)data)[1] is the EFID of the updated file if the result is + * SIM_FILE_UPDATE or NULL for any other result. + * + * In the case where RIL is version 7: + * "data" is a RIL_SimRefreshResponse_v7 * + * + * Note: If the SIM state changes as a result of the SIM refresh (eg, + * SIM_READY -> SIM_LOCKED_OR_ABSENT), RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED + * should be sent. + */ +#define RIL_UNSOL_SIM_REFRESH 1017 + +/** + * RIL_UNSOL_CALL_RING + * + * Ring indication for an incoming call (eg, RING or CRING event). + * There must be at least one RIL_UNSOL_CALL_RING at the beginning + * of a call and sending multiple is optional. If the system property + * ro.telephony.call_ring.multiple is false then the upper layers + * will generate the multiple events internally. Otherwise the vendor + * ril must generate multiple RIL_UNSOL_CALL_RING if + * ro.telephony.call_ring.multiple is true or if it is absent. + * + * The rate of these events is controlled by ro.telephony.call_ring.delay + * and has a default value of 3000 (3 seconds) if absent. + * + * "data" is null for GSM + * "data" is const RIL_CDMA_SignalInfoRecord * if CDMA + */ +#define RIL_UNSOL_CALL_RING 1018 + +/** + * RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED + * + * Indicates that SIM state changes. + * + * Callee will invoke RIL_REQUEST_GET_SIM_STATUS on main thread + + * "data" is null + */ +#define RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED 1019 + +/** + * RIL_UNSOL_RESPONSE_CDMA_NEW_SMS + * + * Called when new CDMA SMS is received + * + * "data" is const RIL_CDMA_SMS_Message * + * + * Callee will subsequently confirm the receipt of the SMS with + * a RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE + * + * No new RIL_UNSOL_RESPONSE_CDMA_NEW_SMS should be sent until + * RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE has been received + * + */ +#define RIL_UNSOL_RESPONSE_CDMA_NEW_SMS 1020 + +/** + * RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS + * + * Called when new Broadcast SMS is received + * + * "data" can be one of the following: + * If received from GSM network, "data" is const char of 88 bytes + * which indicates each page of a CBS Message sent to the MS by the + * BTS as coded in 3GPP 23.041 Section 9.4.1.2. + * If received from UMTS network, "data" is const char of 90 up to 1252 + * bytes which contain between 1 and 15 CBS Message pages sent as one + * packet to the MS by the BTS as coded in 3GPP 23.041 Section 9.4.2.2. + * + */ +#define RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS 1021 + +/** + * RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL + * + * Indicates that SMS storage on the RUIM is full. Messages + * cannot be saved on the RUIM until space is freed. + * + * "data" is null + * + */ +#define RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL 1022 + +/** + * RIL_UNSOL_RESTRICTED_STATE_CHANGED + * + * Indicates a restricted state change (eg, for Domain Specific Access Control). + * + * Radio need send this msg after radio off/on cycle no matter it is changed or not. + * + * "data" is an int * + * ((int *)data)[0] contains a bitmask of RIL_RESTRICTED_STATE_* values. + */ +#define RIL_UNSOL_RESTRICTED_STATE_CHANGED 1023 + +/** + * RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE + * + * Indicates that the radio system selection module has + * autonomously entered emergency callback mode. + * + * "data" is null + * + */ +#define RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE 1024 + +/** + * RIL_UNSOL_CDMA_CALL_WAITING + * + * Called when CDMA radio receives a call waiting indication. + * + * "data" is const RIL_CDMA_CallWaiting * + * + */ +#define RIL_UNSOL_CDMA_CALL_WAITING 1025 + +/** + * RIL_UNSOL_CDMA_OTA_PROVISION_STATUS + * + * Called when CDMA radio receives an update of the progress of an + * OTASP/OTAPA call. + * + * "data" is const int * + * For CDMA this is an integer OTASP/OTAPA status listed in + * RIL_CDMA_OTA_ProvisionStatus. + * + */ +#define RIL_UNSOL_CDMA_OTA_PROVISION_STATUS 1026 + +/** + * RIL_UNSOL_CDMA_INFO_REC + * + * Called when CDMA radio receives one or more info recs. + * + * "data" is const RIL_CDMA_InformationRecords * + * + */ +#define RIL_UNSOL_CDMA_INFO_REC 1027 + +/** + * RIL_UNSOL_OEM_HOOK_RAW + * + * This is for OEM specific use. + * + * "data" is a byte[] + */ +#define RIL_UNSOL_OEM_HOOK_RAW 1028 + +/** + * RIL_UNSOL_RINGBACK_TONE + * + * Indicates that nework doesn't have in-band information, need to + * play out-band tone. + * + * "data" is an int * + * ((int *)data)[0] == 0 for stop play ringback tone. + * ((int *)data)[0] == 1 for start play ringback tone. + */ +#define RIL_UNSOL_RINGBACK_TONE 1029 + +/** + * RIL_UNSOL_RESEND_INCALL_MUTE + * + * Indicates that framework/application need reset the uplink mute state. + * + * There may be situations where the mute state becomes out of sync + * between the application and device in some GSM infrastructures. + * + * "data" is null + */ +#define RIL_UNSOL_RESEND_INCALL_MUTE 1030 + +/** + * RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED + * + * Called when CDMA subscription source changed. + * + * "data" is int * + * ((int *)data)[0] is == RIL_CdmaSubscriptionSource + */ +#define RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED 1031 + +/** + * RIL_UNSOL_CDMA_PRL_CHANGED + * + * Called when PRL (preferred roaming list) changes. + * + * "data" is int * + * ((int *)data)[0] is PRL_VERSION as would be returned by RIL_REQUEST_CDMA_SUBSCRIPTION + */ +#define RIL_UNSOL_CDMA_PRL_CHANGED 1032 + +/** + * RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE + * + * Called when Emergency Callback Mode Ends + * + * Indicates that the radio system selection module has + * proactively exited emergency callback mode. + * + * "data" is NULL + * + */ +#define RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE 1033 + +/** + * RIL_UNSOL_RIL_CONNECTED + * + * Called the ril connects and returns the version + * + * "data" is int * + * ((int *)data)[0] is RIL_VERSION + */ +#define RIL_UNSOL_RIL_CONNECTED 1034 + +/** + * RIL_UNSOL_VOICE_RADIO_TECH_CHANGED + * + * Indicates that voice technology has changed. Contains new radio technology + * as a data in the message. + * + * "data" is int * + * ((int *)data)[0] is of type const RIL_RadioTechnology + * + */ +#define RIL_UNSOL_VOICE_RADIO_TECH_CHANGED 1035 + +/* SAMSUNG RESPONSE */ +#define SAMSUNG_UNSOL_RESPONSE_BASE 11000 + +#define RIL_UNSOL_RELEASE_COMPLETE_MESSAGE 11001 +#define RIL_UNSOL_STK_SEND_SMS_RESULT 11002 +#define RIL_UNSOL_STK_CALL_CONTROL_RESULT 11003 +#define RIL_UNSOL_DUN_CALL_STATUS 11004 + +#define RIL_UNSOL_O2_HOME_ZONE_INFO 11007 +#define RIL_UNSOL_DEVICE_READY_NOTI 11008 +#define RIL_UNSOL_GPS_NOTI 11009 +#define RIL_UNSOL_AM 11010 +#define RIL_UNSOL_DUN_PIN_CONTROL_SIGNAL 11011 +#define RIL_UNSOL_DATA_SUSPEND_RESUME 11012 +#define RIL_UNSOL_SAP 11013 + +#define RIL_UNSOL_SIM_SMS_STORAGE_AVAILALE 11015 +#define RIL_UNSOL_HSDPA_STATE_CHANGED 11016 +#define RIL_UNSOL_WB_AMR_STATE 11017 +#define RIL_UNSOL_TWO_MIC_STATE 11018 +#define RIL_UNSOL_DHA_STATE 11019 +#define RIL_UNSOL_UART 11020 +#define RIL_UNSOL_RESPONSE_HANDOVER 11021 +#define RIL_UNSOL_IPV6_ADDR 11022 +#define RIL_UNSOL_NWK_INIT_DISC_REQUEST 11023 +#define RIL_UNSOL_RTS_INDICATION 11024 +#define RIL_UNSOL_OMADM_SEND_DATA 11025 +#define RIL_UNSOL_DUN 11026 +#define RIL_UNSOL_SYSTEM_REBOOT 11027 +#define RIL_UNSOL_VOICE_PRIVACY_CHANGED 11028 +#define RIL_UNSOL_UTS_GETSMSCOUNT 11029 +#define RIL_UNSOL_UTS_GETSMSMSG 11030 +#define RIL_UNSOL_UTS_GET_UNREAD_SMS_STATUS 11031 +#define RIL_UNSOL_MIP_CONNECT_STATUS 11032 + +/***********************************************************************/ + + +/** + * RIL_Request Function pointer + * + * @param request is one of RIL_REQUEST_* + * @param data is pointer to data defined for that RIL_REQUEST_* + * data is owned by caller, and should not be modified or freed by callee + * @param t should be used in subsequent call to RIL_onResponse + * @param datalen the length of data + * + */ +typedef void (*RIL_RequestFunc) (int request, void *data, + size_t datalen, RIL_Token t); + +/** + * This function should return the current radio state synchronously + */ +typedef RIL_RadioState (*RIL_RadioStateRequest)(); + +/** + * This function returns "1" if the specified RIL_REQUEST code is + * supported and 0 if it is not + * + * @param requestCode is one of RIL_REQUEST codes + */ + +typedef int (*RIL_Supports)(int requestCode); + +/** + * This function is called from a separate thread--not the + * thread that calls RIL_RequestFunc--and indicates that a pending + * request should be cancelled. + * + * On cancel, the callee should do its best to abandon the request and + * call RIL_onRequestComplete with RIL_Errno CANCELLED at some later point. + * + * Subsequent calls to RIL_onRequestComplete for this request with + * other results will be tolerated but ignored. (That is, it is valid + * to ignore the cancellation request) + * + * RIL_Cancel calls should return immediately, and not wait for cancellation + * + * Please see ITU v.250 5.6.1 for how one might implement this on a TS 27.007 + * interface + * + * @param t token wants to be canceled + */ + +typedef void (*RIL_Cancel)(RIL_Token t); + +typedef void (*RIL_TimedCallback) (void *param); + +/** + * Return a version string for your RIL implementation + */ +typedef const char * (*RIL_GetVersion) (void); + +typedef struct { + int version; /* set to RIL_VERSION */ + RIL_RequestFunc onRequest; + RIL_RadioStateRequest onStateRequest; + RIL_Supports supports; + RIL_Cancel onCancel; + RIL_GetVersion getVersion; +} RIL_RadioFunctions; + +#ifdef RIL_SHLIB +struct RIL_Env { + /** + * "t" is parameter passed in on previous call to RIL_Notification + * routine. + * + * If "e" != SUCCESS, then response can be null/is ignored + * + * "response" is owned by caller, and should not be modified or + * freed by callee + * + * RIL_onRequestComplete will return as soon as possible + */ + void (*OnRequestComplete)(RIL_Token t, RIL_Errno e, + void *response, size_t responselen); + + /** + * "unsolResponse" is one of RIL_UNSOL_RESPONSE_* + * "data" is pointer to data defined for that RIL_UNSOL_RESPONSE_* + * + * "data" is owned by caller, and should not be modified or freed by callee + */ + + void (*OnUnsolicitedResponse)(int unsolResponse, const void *data, + size_t datalen); + + /** + * Call user-specifed "callback" function on on the same thread that + * RIL_RequestFunc is called. If "relativeTime" is specified, then it specifies + * a relative time value at which the callback is invoked. If relativeTime is + * NULL or points to a 0-filled structure, the callback will be invoked as + * soon as possible + */ + + void (*RequestTimedCallback) (RIL_TimedCallback callback, + void *param, const struct timeval *relativeTime); +}; + + +/** + * RIL implementations must defined RIL_Init + * argc and argv will be command line arguments intended for the RIL implementation + * Return NULL on error + * + * @param env is environment point defined as RIL_Env + * @param argc number of arguments + * @param argv list fo arguments + * + */ +const RIL_RadioFunctions *RIL_Init(const struct RIL_Env *env, int argc, char **argv); + +#else /* RIL_SHLIB */ + +/** + * Call this once at startup to register notification routine + * + * @param callbacks user-specifed callback function + */ +void RIL_register (const RIL_RadioFunctions *callbacks); + + +/** + * + * RIL_onRequestComplete will return as soon as possible + * + * @param t is parameter passed in on previous call to RIL_Notification + * routine. + * @param e error code + * if "e" != SUCCESS, then response can be null/is ignored + * @param response is owned by caller, and should not be modified or + * freed by callee + * @param responselen the length of response in byte + */ +void RIL_onRequestComplete(RIL_Token t, RIL_Errno e, + void *response, size_t responselen); + +/** + * @param unsolResponse is one of RIL_UNSOL_RESPONSE_* + * @param data is pointer to data defined for that RIL_UNSOL_RESPONSE_* + * "data" is owned by caller, and should not be modified or freed by callee + * @param datalen the length of data in byte + */ + +void RIL_onUnsolicitedResponse(int unsolResponse, const void *data, + size_t datalen); + + +/** + * Call user-specifed "callback" function on on the same thread that + * RIL_RequestFunc is called. If "relativeTime" is specified, then it specifies + * a relative time value at which the callback is invoked. If relativeTime is + * NULL or points to a 0-filled structure, the callback will be invoked as + * soon as possible + * + * @param callback user-specifed callback function + * @param param parameter list + * @param relativeTime a relative time value at which the callback is invoked + */ + +void RIL_requestTimedCallback (RIL_TimedCallback callback, + void *param, const struct timeval *relativeTime); + + +#endif /* RIL_SHLIB */ + +#ifdef __cplusplus +} +#endif + +#endif /*ANDROID_RIL_H*/ diff --git a/libril/Android.mk b/libril/Android.mk new file mode 100644 index 0000000..7a1131b --- /dev/null +++ b/libril/Android.mk @@ -0,0 +1,47 @@ +# Copyright 2006 The Android Open Source Project + +ifeq ($(BOARD_PROVIDES_LIBRIL),true) + +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES:= \ + ril.cpp \ + ril_event.cpp + +LOCAL_SHARED_LIBRARIES := \ + libutils \ + libbinder \ + libcutils \ + libhardware_legacy + +LOCAL_CFLAGS := + +LOCAL_MODULE:= libril + +LOCAL_LDLIBS += -lpthread + +include $(BUILD_SHARED_LIBRARY) + + +# For RdoServD which needs a static library +# ========================================= +ifneq ($(ANDROID_BIONIC_TRANSITION),) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES:= \ + ril.cpp + +LOCAL_STATIC_LIBRARIES := \ + libutils_static \ + libcutils + +LOCAL_CFLAGS := + +LOCAL_MODULE:= libril_static + +LOCAL_LDLIBS += -lpthread + +include $(BUILD_STATIC_LIBRARY) +endif # ANDROID_BIONIC_TRANSITION +endif # BOARD_PROVIDES_LIBRIL diff --git a/libril/MODULE_LICENSE_APACHE2 b/libril/MODULE_LICENSE_APACHE2 new file mode 100644 index 0000000..e69de29 diff --git a/libril/NOTICE b/libril/NOTICE new file mode 100644 index 0000000..c5b1efa --- /dev/null +++ b/libril/NOTICE @@ -0,0 +1,190 @@ + + Copyright (c) 2005-2008, The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + diff --git a/libril/ril.cpp b/libril/ril.cpp new file mode 100644 index 0000000..199d9ed --- /dev/null +++ b/libril/ril.cpp @@ -0,0 +1,3591 @@ +/* //device/libs/telephony/ril.cpp +** +** Copyright 2006, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +#define LOG_TAG "RILC" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace android { + +#define PHONE_PROCESS "radio" + +#define SOCKET_NAME_RIL "rild" +#define SOCKET_NAME_RIL_DEBUG "rild-debug" + +#define ANDROID_WAKE_LOCK_NAME "radio-interface" + + +#define PROPERTY_RIL_IMPL "gsm.version.ril-impl" + +// match with constant in RIL.java +#define MAX_COMMAND_BYTES (8 * 1024) + +// Basically: memset buffers that the client library +// shouldn't be using anymore in an attempt to find +// memory usage issues sooner. +#define MEMSET_FREED 1 + +#define NUM_ELEMS(a) (sizeof (a) / sizeof (a)[0]) + +#define MIN(a,b) ((a)<(b) ? (a) : (b)) + +/* Constants for response types */ +#define RESPONSE_SOLICITED 0 +#define RESPONSE_UNSOLICITED 1 + +/* Negative values for private RIL errno's */ +#define RIL_ERRNO_INVALID_RESPONSE -1 + +// request, response, and unsolicited msg print macro +#define PRINTBUF_SIZE 8096 + +// Enable RILC log +#define RILC_LOG 0 + +#if RILC_LOG + #define startRequest sprintf(printBuf, "(") + #define closeRequest sprintf(printBuf, "%s)", printBuf) + #define printRequest(token, req) \ + ALOGD("[%04d]> %s %s", token, requestToString(req), printBuf) + + #define startResponse sprintf(printBuf, "%s {", printBuf) + #define closeResponse sprintf(printBuf, "%s}", printBuf) + #define printResponse ALOGD("%s", printBuf) + + #define clearPrintBuf printBuf[0] = 0 + #define removeLastChar printBuf[strlen(printBuf)-1] = 0 + #define appendPrintBuf(x...) sprintf(printBuf, x) +#else + #define startRequest + #define closeRequest + #define printRequest(token, req) + #define startResponse + #define closeResponse + #define printResponse + #define clearPrintBuf + #define removeLastChar + #define appendPrintBuf(x...) +#endif + +enum WakeType {DONT_WAKE, WAKE_PARTIAL}; + +typedef struct { + int requestNumber; + void (*dispatchFunction) (Parcel &p, struct RequestInfo *pRI); + int(*responseFunction) (Parcel &p, void *response, size_t responselen); +} CommandInfo; + +typedef struct { + int requestNumber; + int (*responseFunction) (Parcel &p, void *response, size_t responselen); + WakeType wakeType; +} UnsolResponseInfo; + +typedef struct RequestInfo { + int32_t token; //this is not RIL_Token + CommandInfo *pCI; + struct RequestInfo *p_next; + char cancelled; + char local; // responses to local commands do not go back to command process +} RequestInfo; + +typedef struct UserCallbackInfo { + RIL_TimedCallback p_callback; + void *userParam; + struct ril_event event; + struct UserCallbackInfo *p_next; +} UserCallbackInfo; + + +/*******************************************************************/ + +RIL_RadioFunctions s_callbacks = {0, NULL, NULL, NULL, NULL, NULL}; +static int s_registerCalled = 0; + +static pthread_t s_tid_dispatch; +static pthread_t s_tid_reader; +static int s_started = 0; + +static int s_fdListen = -1; +static int s_fdCommand = -1; +static int s_fdDebug = -1; + +static int s_fdWakeupRead; +static int s_fdWakeupWrite; + +static struct ril_event s_commands_event; +static struct ril_event s_wakeupfd_event; +static struct ril_event s_listen_event; +static struct ril_event s_wake_timeout_event; +static struct ril_event s_debug_event; + + +static const struct timeval TIMEVAL_WAKE_TIMEOUT = {1,0}; + +static pthread_mutex_t s_pendingRequestsMutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t s_writeMutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t s_startupMutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_cond_t s_startupCond = PTHREAD_COND_INITIALIZER; + +static pthread_mutex_t s_dispatchMutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_cond_t s_dispatchCond = PTHREAD_COND_INITIALIZER; + +static RequestInfo *s_pendingRequests = NULL; + +static RequestInfo *s_toDispatchHead = NULL; +static RequestInfo *s_toDispatchTail = NULL; + +static UserCallbackInfo *s_last_wake_timeout_info = NULL; + +static void *s_lastNITZTimeData = NULL; +static size_t s_lastNITZTimeDataSize; + +#if RILC_LOG + static char printBuf[PRINTBUF_SIZE]; +#endif + +/*******************************************************************/ + +static void dispatchVoid (Parcel& p, RequestInfo *pRI); +static void dispatchString (Parcel& p, RequestInfo *pRI); +static void dispatchStrings (Parcel& p, RequestInfo *pRI); +static void dispatchInts (Parcel& p, RequestInfo *pRI); +static void dispatchDial (Parcel& p, RequestInfo *pRI); +static void dispatchSIM_IO (Parcel& p, RequestInfo *pRI); +static void dispatchCallForward(Parcel& p, RequestInfo *pRI); +static void dispatchRaw(Parcel& p, RequestInfo *pRI); +static void dispatchSmsWrite (Parcel &p, RequestInfo *pRI); +static void dispatchDataCall (Parcel& p, RequestInfo *pRI); +static void dispatchVoiceRadioTech (Parcel& p, RequestInfo *pRI); +static void dispatchCdmaSubscriptionSource (Parcel& p, RequestInfo *pRI); + +static void dispatchCdmaSms(Parcel &p, RequestInfo *pRI); +static void dispatchCdmaSmsAck(Parcel &p, RequestInfo *pRI); +static void dispatchGsmBrSmsCnf(Parcel &p, RequestInfo *pRI); +static void dispatchCdmaBrSmsCnf(Parcel &p, RequestInfo *pRI); +static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI); +static int responseInts(Parcel &p, void *response, size_t responselen); +static int responseStrings(Parcel &p, void *response, size_t responselen); +static int responseStringsNetworks(Parcel &p, void *response, size_t responselen); +static int responseStrings(Parcel &p, void *response, size_t responselen, bool network_search); +static int responseString(Parcel &p, void *response, size_t responselen); +static int responseVoid(Parcel &p, void *response, size_t responselen); +static int responseCallList(Parcel &p, void *response, size_t responselen); +static int responseSMS(Parcel &p, void *response, size_t responselen); +static int responseSIM_IO(Parcel &p, void *response, size_t responselen); +static int responseCallForwards(Parcel &p, void *response, size_t responselen); +static int responseDataCallList(Parcel &p, void *response, size_t responselen); +static int responseSetupDataCall(Parcel &p, void *response, size_t responselen); +static int responseRaw(Parcel &p, void *response, size_t responselen); +static int responseSsn(Parcel &p, void *response, size_t responselen); +static int responseSimStatus(Parcel &p, void *response, size_t responselen); +static int responseGsmBrSmsCnf(Parcel &p, void *response, size_t responselen); +static int responseCdmaBrSmsCnf(Parcel &p, void *response, size_t responselen); +static int responseCdmaSms(Parcel &p, void *response, size_t responselen); +static int responseCellList(Parcel &p, void *response, size_t responselen); +static int responseCdmaInformationRecords(Parcel &p,void *response, size_t responselen); +static int responseRilSignalStrength(Parcel &p,void *response, size_t responselen); +static int responseCallRing(Parcel &p, void *response, size_t responselen); +static int responseCdmaSignalInfoRecord(Parcel &p,void *response, size_t responselen); +static int responseCdmaCallWaiting(Parcel &p,void *response, size_t responselen); +static int responseSimRefresh(Parcel &p, void *response, size_t responselen); + +static int decodeVoiceRadioTechnology (RIL_RadioState radioState); +static int decodeCdmaSubscriptionSource (RIL_RadioState radioState); +static RIL_RadioState processRadioState(RIL_RadioState newRadioState); + +extern "C" const char * requestToString(int request); +extern "C" const char * failCauseToString(RIL_Errno); +extern "C" const char * callStateToString(RIL_CallState); +extern "C" const char * radioStateToString(RIL_RadioState); + +#ifdef RIL_SHLIB +extern "C" void RIL_onUnsolicitedResponse(int unsolResponse, void *data, + size_t datalen); +#endif + +static UserCallbackInfo * internalRequestTimedCallback + (RIL_TimedCallback callback, void *param, + const struct timeval *relativeTime); + +/** Index == requestNumber */ +static CommandInfo s_commands[] = { +#include "ril_commands.h" +}; + +static UnsolResponseInfo s_unsolResponses[] = { +#include "ril_unsol_commands.h" +}; + +/* For older RILs that do not support new commands RIL_REQUEST_VOICE_RADIO_TECH and + RIL_UNSOL_VOICE_RADIO_TECH_CHANGED messages, decode the voice radio tech from + radio state message and store it. Every time there is a change in Radio State + check to see if voice radio tech changes and notify telephony + */ +int voiceRadioTech = -1; + +/* For older RILs that do not support new commands RIL_REQUEST_GET_CDMA_SUBSCRIPTION_SOURCE + and RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED messages, decode the subscription + source from radio state and store it. Every time there is a change in Radio State + check to see if subscription source changed and notify telephony + */ +int cdmaSubscriptionSource = -1; + +/* For older RILs that do not send RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, decode the + SIM/RUIM state from radio state and store it. Every time there is a change in Radio State, + check to see if SIM/RUIM status changed and notify telephony + */ +int simRuimStatus = -1; + +static char * +strdupReadString(Parcel &p) { + size_t stringlen; + const char16_t *s16; + + s16 = p.readString16Inplace(&stringlen); + + return strndup16to8(s16, stringlen); +} + +static void writeStringToParcel(Parcel &p, const char *s) { + char16_t *s16; + size_t s16_len; + s16 = strdup8to16(s, &s16_len); + p.writeString16(s16, s16_len); + free(s16); +} + + +static void +memsetString (char *s) { + if (s != NULL) { + memset (s, 0, strlen(s)); + } +} + +void nullParcelReleaseFunction (const uint8_t* data, size_t dataSize, + const size_t* objects, size_t objectsSize, + void* cookie) { + // do nothing -- the data reference lives longer than the Parcel object +} + +/** + * To be called from dispatch thread + * Issue a single local request, ensuring that the response + * is not sent back up to the command process + */ +static void +issueLocalRequest(int request, void *data, int len) { + RequestInfo *pRI; + int ret; + + pRI = (RequestInfo *)calloc(1, sizeof(RequestInfo)); + + pRI->local = 1; + pRI->token = 0xffffffff; // token is not used in this context + pRI->pCI = &(s_commands[request]); + + ret = pthread_mutex_lock(&s_pendingRequestsMutex); + assert (ret == 0); + + pRI->p_next = s_pendingRequests; + s_pendingRequests = pRI; + + ret = pthread_mutex_unlock(&s_pendingRequestsMutex); + assert (ret == 0); + + ALOGD("C[locl]> %s", requestToString(request)); + + s_callbacks.onRequest(request, data, len, pRI); +} + + + +static int +processCommandBuffer(void *buffer, size_t buflen) { + Parcel p; + status_t status; + int32_t request; + int32_t token; + RequestInfo *pRI; + int ret; + + p.setData((uint8_t *) buffer, buflen); + + // status checked at end + status = p.readInt32(&request); + status = p.readInt32 (&token); + + if (status != NO_ERROR) { + ALOGE("invalid request block"); + return 0; + } + + if (request < 1 || request >= (int32_t)NUM_ELEMS(s_commands)) { + ALOGE("unsupported request code %d token %d", request, token); + // FIXME this should perhaps return a response + return 0; + } + + + pRI = (RequestInfo *)calloc(1, sizeof(RequestInfo)); + + pRI->token = token; + pRI->pCI = &(s_commands[request]); + + ret = pthread_mutex_lock(&s_pendingRequestsMutex); + assert (ret == 0); + + pRI->p_next = s_pendingRequests; + s_pendingRequests = pRI; + + ret = pthread_mutex_unlock(&s_pendingRequestsMutex); + assert (ret == 0); + +/* sLastDispatchedToken = token; */ + + pRI->pCI->dispatchFunction(p, pRI); + + return 0; +} + +static void +invalidCommandBlock (RequestInfo *pRI) { + ALOGE("invalid command block for token %d request %s", + pRI->token, requestToString(pRI->pCI->requestNumber)); +} + +/** Callee expects NULL */ +static void +dispatchVoid (Parcel& p, RequestInfo *pRI) { + clearPrintBuf; + printRequest(pRI->token, pRI->pCI->requestNumber); + s_callbacks.onRequest(pRI->pCI->requestNumber, NULL, 0, pRI); +} + +/** Callee expects const char * */ +static void +dispatchString (Parcel& p, RequestInfo *pRI) { + status_t status; + size_t datalen; + size_t stringlen; + char *string8 = NULL; + + string8 = strdupReadString(p); + + startRequest; + appendPrintBuf("%s%s", printBuf, string8); + closeRequest; + printRequest(pRI->token, pRI->pCI->requestNumber); + + s_callbacks.onRequest(pRI->pCI->requestNumber, string8, + sizeof(char *), pRI); + +#ifdef MEMSET_FREED + memsetString(string8); +#endif + + free(string8); + return; +invalid: + invalidCommandBlock(pRI); + return; +} + +/** Callee expects const char ** */ +static void +dispatchStrings (Parcel &p, RequestInfo *pRI) { + int32_t countStrings; + status_t status; + size_t datalen; + char **pStrings; + + status = p.readInt32 (&countStrings); + + if (status != NO_ERROR) { + goto invalid; + } + + startRequest; + if (countStrings == 0) { + // just some non-null pointer + pStrings = (char **)alloca(sizeof(char *)); + datalen = 0; + } else if (((int)countStrings) == -1) { + pStrings = NULL; + datalen = 0; + } else { + datalen = sizeof(char *) * countStrings; + + pStrings = (char **)alloca(datalen); + + for (int i = 0 ; i < countStrings ; i++) { + pStrings[i] = strdupReadString(p); + appendPrintBuf("%s%s,", printBuf, pStrings[i]); + } + } + removeLastChar; + closeRequest; + printRequest(pRI->token, pRI->pCI->requestNumber); + + s_callbacks.onRequest(pRI->pCI->requestNumber, pStrings, datalen, pRI); + + if (pStrings != NULL) { + for (int i = 0 ; i < countStrings ; i++) { +#ifdef MEMSET_FREED + memsetString (pStrings[i]); +#endif + free(pStrings[i]); + } + +#ifdef MEMSET_FREED + memset(pStrings, 0, datalen); +#endif + } + + return; +invalid: + invalidCommandBlock(pRI); + return; +} + +/** Callee expects const int * */ +static void +dispatchInts (Parcel &p, RequestInfo *pRI) { + int32_t count; + status_t status; + size_t datalen; + int *pInts; + + status = p.readInt32 (&count); + + if (status != NO_ERROR || count == 0) { + goto invalid; + } + + datalen = sizeof(int) * count; + pInts = (int *)alloca(datalen); + + startRequest; + for (int i = 0 ; i < count ; i++) { + int32_t t; + + status = p.readInt32(&t); + pInts[i] = (int)t; + appendPrintBuf("%s%d,", printBuf, t); + + if (status != NO_ERROR) { + goto invalid; + } + } + removeLastChar; + closeRequest; + printRequest(pRI->token, pRI->pCI->requestNumber); + + s_callbacks.onRequest(pRI->pCI->requestNumber, const_cast(pInts), + datalen, pRI); + +#ifdef MEMSET_FREED + memset(pInts, 0, datalen); +#endif + + return; +invalid: + invalidCommandBlock(pRI); + return; +} + + +/** + * Callee expects const RIL_SMS_WriteArgs * + * Payload is: + * int32_t status + * String pdu + */ +static void +dispatchSmsWrite (Parcel &p, RequestInfo *pRI) { + RIL_SMS_WriteArgs args; + int32_t t; + status_t status; + + memset (&args, 0, sizeof(args)); + + status = p.readInt32(&t); + args.status = (int)t; + + args.pdu = strdupReadString(p); + + if (status != NO_ERROR || args.pdu == NULL) { + goto invalid; + } + + args.smsc = strdupReadString(p); + + startRequest; + appendPrintBuf("%s%d,%s,smsc=%s", printBuf, args.status, + (char*)args.pdu, (char*)args.smsc); + closeRequest; + printRequest(pRI->token, pRI->pCI->requestNumber); + + s_callbacks.onRequest(pRI->pCI->requestNumber, &args, sizeof(args), pRI); + +#ifdef MEMSET_FREED + memsetString (args.pdu); +#endif + + free (args.pdu); + +#ifdef MEMSET_FREED + memset(&args, 0, sizeof(args)); +#endif + + return; +invalid: + invalidCommandBlock(pRI); + return; +} + +/** + * Callee expects const RIL_Dial * + * Payload is: + * String address + * int32_t clir + */ +static void +dispatchDial (Parcel &p, RequestInfo *pRI) { + RIL_Dial dial; + RIL_UUS_Info uusInfo; + int32_t sizeOfDial; + int32_t t; + int32_t uusPresent; + status_t status; + + memset (&dial, 0, sizeof(dial)); + + dial.address = strdupReadString(p); + + status = p.readInt32(&t); + dial.clir = (int)t; + + if (status != NO_ERROR || dial.address == NULL) { + goto invalid; + } + + if (s_callbacks.version < 3) { // Remove when partners upgrade to version 3 + uusPresent = 0; + sizeOfDial = sizeof(dial) - sizeof(RIL_UUS_Info *); + } else { + status = p.readInt32(&uusPresent); + + if (status != NO_ERROR) { + goto invalid; + } + + if (uusPresent == 0) { + dial.uusInfo = NULL; + } else { + int32_t len; + + memset(&uusInfo, 0, sizeof(RIL_UUS_Info)); + + status = p.readInt32(&t); + uusInfo.uusType = (RIL_UUS_Type) t; + + status = p.readInt32(&t); + uusInfo.uusDcs = (RIL_UUS_DCS) t; + + status = p.readInt32(&len); + if (status != NO_ERROR) { + goto invalid; + } + + // The java code writes -1 for null arrays + if (((int) len) == -1) { + uusInfo.uusData = NULL; + len = 0; + } else { + uusInfo.uusData = (char*) p.readInplace(len); + } + + uusInfo.uusLength = len; + dial.uusInfo = &uusInfo; + } + sizeOfDial = sizeof(dial); + } + + startRequest; + appendPrintBuf("%snum=%s,clir=%d", printBuf, dial.address, dial.clir); + if (uusPresent) { + appendPrintBuf("%s,uusType=%d,uusDcs=%d,uusLen=%d", printBuf, + dial.uusInfo->uusType, dial.uusInfo->uusDcs, + dial.uusInfo->uusLength); + } + closeRequest; + printRequest(pRI->token, pRI->pCI->requestNumber); + + s_callbacks.onRequest(pRI->pCI->requestNumber, &dial, sizeOfDial, pRI); + +#ifdef MEMSET_FREED + memsetString (dial.address); +#endif + + free (dial.address); + +#ifdef MEMSET_FREED + memset(&uusInfo, 0, sizeof(RIL_UUS_Info)); + memset(&dial, 0, sizeof(dial)); +#endif + + return; +invalid: + invalidCommandBlock(pRI); + return; +} + +/** + * Callee expects const RIL_SIM_IO * + * Payload is: + * int32_t command + * int32_t fileid + * String path + * int32_t p1, p2, p3 + * String data + * String pin2 + * String aidPtr + */ +static void +dispatchSIM_IO (Parcel &p, RequestInfo *pRI) { + union RIL_SIM_IO { + RIL_SIM_IO_v6 v6; + RIL_SIM_IO_v5 v5; + } simIO; + + int32_t t; + int size; + status_t status; + + memset (&simIO, 0, sizeof(simIO)); + + // note we only check status at the end + + status = p.readInt32(&t); + simIO.v6.command = (int)t; + + status = p.readInt32(&t); + simIO.v6.fileid = (int)t; + + simIO.v6.path = strdupReadString(p); + + status = p.readInt32(&t); + simIO.v6.p1 = (int)t; + + status = p.readInt32(&t); + simIO.v6.p2 = (int)t; + + status = p.readInt32(&t); + simIO.v6.p3 = (int)t; + + simIO.v6.data = strdupReadString(p); + simIO.v6.pin2 = strdupReadString(p); + simIO.v6.aidPtr = strdupReadString(p); + + startRequest; + appendPrintBuf("%scmd=0x%X,efid=0x%X,path=%s,%d,%d,%d,%s,pin2=%s,aid=%s", printBuf, + simIO.v6.command, simIO.v6.fileid, (char*)simIO.v6.path, + simIO.v6.p1, simIO.v6.p2, simIO.v6.p3, + (char*)simIO.v6.data, (char*)simIO.v6.pin2, simIO.v6.aidPtr); + closeRequest; + printRequest(pRI->token, pRI->pCI->requestNumber); + + if (status != NO_ERROR) { + goto invalid; + } + + size = (s_callbacks.version < 6) ? sizeof(simIO.v5) : sizeof(simIO.v6); + s_callbacks.onRequest(pRI->pCI->requestNumber, &simIO, size, pRI); + +#ifdef MEMSET_FREED + memsetString (simIO.v6.path); + memsetString (simIO.v6.data); + memsetString (simIO.v6.pin2); + memsetString (simIO.v6.aidPtr); +#endif + + free (simIO.v6.path); + free (simIO.v6.data); + free (simIO.v6.pin2); + free (simIO.v6.aidPtr); + +#ifdef MEMSET_FREED + memset(&simIO, 0, sizeof(simIO)); +#endif + + return; +invalid: + invalidCommandBlock(pRI); + return; +} + +/** + * Callee expects const RIL_CallForwardInfo * + * Payload is: + * int32_t status/action + * int32_t reason + * int32_t serviceCode + * int32_t toa + * String number (0 length -> null) + * int32_t timeSeconds + */ +static void +dispatchCallForward(Parcel &p, RequestInfo *pRI) { + RIL_CallForwardInfo cff; + int32_t t; + status_t status; + + memset (&cff, 0, sizeof(cff)); + + // note we only check status at the end + + status = p.readInt32(&t); + cff.status = (int)t; + + status = p.readInt32(&t); + cff.reason = (int)t; + + status = p.readInt32(&t); + cff.serviceClass = (int)t; + + status = p.readInt32(&t); + cff.toa = (int)t; + + cff.number = strdupReadString(p); + + status = p.readInt32(&t); + cff.timeSeconds = (int)t; + + if (status != NO_ERROR) { + goto invalid; + } + + // special case: number 0-length fields is null + + if (cff.number != NULL && strlen (cff.number) == 0) { + cff.number = NULL; + } + + startRequest; + appendPrintBuf("%sstat=%d,reason=%d,serv=%d,toa=%d,%s,tout=%d", printBuf, + cff.status, cff.reason, cff.serviceClass, cff.toa, + (char*)cff.number, cff.timeSeconds); + closeRequest; + printRequest(pRI->token, pRI->pCI->requestNumber); + + s_callbacks.onRequest(pRI->pCI->requestNumber, &cff, sizeof(cff), pRI); + +#ifdef MEMSET_FREED + memsetString(cff.number); +#endif + + free (cff.number); + +#ifdef MEMSET_FREED + memset(&cff, 0, sizeof(cff)); +#endif + + return; +invalid: + invalidCommandBlock(pRI); + return; +} + + +static void +dispatchRaw(Parcel &p, RequestInfo *pRI) { + int32_t len; + status_t status; + const void *data; + + status = p.readInt32(&len); + + if (status != NO_ERROR) { + goto invalid; + } + + // The java code writes -1 for null arrays + if (((int)len) == -1) { + data = NULL; + len = 0; + } + + data = p.readInplace(len); + + startRequest; + appendPrintBuf("%sraw_size=%d", printBuf, len); + closeRequest; + printRequest(pRI->token, pRI->pCI->requestNumber); + + s_callbacks.onRequest(pRI->pCI->requestNumber, const_cast(data), len, pRI); + + return; +invalid: + invalidCommandBlock(pRI); + return; +} + +static void +dispatchCdmaSms(Parcel &p, RequestInfo *pRI) { + RIL_CDMA_SMS_Message rcsm; + int32_t t; + uint8_t ut; + status_t status; + int32_t digitCount; + int digitLimit; + + memset(&rcsm, 0, sizeof(rcsm)); + + status = p.readInt32(&t); + rcsm.uTeleserviceID = (int) t; + + status = p.read(&ut,sizeof(ut)); + rcsm.bIsServicePresent = (uint8_t) ut; + + status = p.readInt32(&t); + rcsm.uServicecategory = (int) t; + + status = p.readInt32(&t); + rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) t; + + status = p.readInt32(&t); + rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) t; + + status = p.readInt32(&t); + rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) t; + + status = p.readInt32(&t); + rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) t; + + status = p.read(&ut,sizeof(ut)); + rcsm.sAddress.number_of_digits= (uint8_t) ut; + + digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX); + for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { + status = p.read(&ut,sizeof(ut)); + rcsm.sAddress.digits[digitCount] = (uint8_t) ut; + } + + status = p.readInt32(&t); + rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) t; + + status = p.read(&ut,sizeof(ut)); + rcsm.sSubAddress.odd = (uint8_t) ut; + + status = p.read(&ut,sizeof(ut)); + rcsm.sSubAddress.number_of_digits = (uint8_t) ut; + + digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX); + for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { + status = p.read(&ut,sizeof(ut)); + rcsm.sSubAddress.digits[digitCount] = (uint8_t) ut; + } + + status = p.readInt32(&t); + rcsm.uBearerDataLen = (int) t; + + digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX); + for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { + status = p.read(&ut, sizeof(ut)); + rcsm.aBearerData[digitCount] = (uint8_t) ut; + } + + if (status != NO_ERROR) { + goto invalid; + } + + startRequest; + appendPrintBuf("%suTeleserviceID=%d, bIsServicePresent=%d, uServicecategory=%d, \ + sAddress.digit_mode=%d, sAddress.Number_mode=%d, sAddress.number_type=%d, ", + printBuf, rcsm.uTeleserviceID,rcsm.bIsServicePresent,rcsm.uServicecategory, + rcsm.sAddress.digit_mode, rcsm.sAddress.number_mode,rcsm.sAddress.number_type); + closeRequest; + + printRequest(pRI->token, pRI->pCI->requestNumber); + + s_callbacks.onRequest(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm),pRI); + +#ifdef MEMSET_FREED + memset(&rcsm, 0, sizeof(rcsm)); +#endif + + return; + +invalid: + invalidCommandBlock(pRI); + return; +} + +static void +dispatchCdmaSmsAck(Parcel &p, RequestInfo *pRI) { + RIL_CDMA_SMS_Ack rcsa; + int32_t t; + status_t status; + int32_t digitCount; + + memset(&rcsa, 0, sizeof(rcsa)); + + status = p.readInt32(&t); + rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) t; + + status = p.readInt32(&t); + rcsa.uSMSCauseCode = (int) t; + + if (status != NO_ERROR) { + goto invalid; + } + + startRequest; + appendPrintBuf("%suErrorClass=%d, uTLStatus=%d, ", + printBuf, rcsa.uErrorClass, rcsa.uSMSCauseCode); + closeRequest; + + printRequest(pRI->token, pRI->pCI->requestNumber); + + s_callbacks.onRequest(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa),pRI); + +#ifdef MEMSET_FREED + memset(&rcsa, 0, sizeof(rcsa)); +#endif + + return; + +invalid: + invalidCommandBlock(pRI); + return; +} + +static void +dispatchGsmBrSmsCnf(Parcel &p, RequestInfo *pRI) { + int32_t t; + status_t status; + int32_t num; + + status = p.readInt32(&num); + if (status != NO_ERROR) { + goto invalid; + } + + { + RIL_GSM_BroadcastSmsConfigInfo gsmBci[num]; + RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num]; + + startRequest; + for (int i = 0 ; i < num ; i++ ) { + gsmBciPtrs[i] = &gsmBci[i]; + + status = p.readInt32(&t); + gsmBci[i].fromServiceId = (int) t; + + status = p.readInt32(&t); + gsmBci[i].toServiceId = (int) t; + + status = p.readInt32(&t); + gsmBci[i].fromCodeScheme = (int) t; + + status = p.readInt32(&t); + gsmBci[i].toCodeScheme = (int) t; + + status = p.readInt32(&t); + gsmBci[i].selected = (uint8_t) t; + + appendPrintBuf("%s [%d: fromServiceId=%d, toServiceId =%d, \ + fromCodeScheme=%d, toCodeScheme=%d, selected =%d]", printBuf, i, + gsmBci[i].fromServiceId, gsmBci[i].toServiceId, + gsmBci[i].fromCodeScheme, gsmBci[i].toCodeScheme, + gsmBci[i].selected); + } + closeRequest; + + if (status != NO_ERROR) { + goto invalid; + } + + s_callbacks.onRequest(pRI->pCI->requestNumber, + gsmBciPtrs, + num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), + pRI); + +#ifdef MEMSET_FREED + memset(gsmBci, 0, num * sizeof(RIL_GSM_BroadcastSmsConfigInfo)); + memset(gsmBciPtrs, 0, num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *)); +#endif + } + + return; + +invalid: + invalidCommandBlock(pRI); + return; +} + +static void +dispatchCdmaBrSmsCnf(Parcel &p, RequestInfo *pRI) { + int32_t t; + status_t status; + int32_t num; + + status = p.readInt32(&num); + if (status != NO_ERROR) { + goto invalid; + } + + { + RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num]; + RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num]; + + startRequest; + for (int i = 0 ; i < num ; i++ ) { + cdmaBciPtrs[i] = &cdmaBci[i]; + + status = p.readInt32(&t); + cdmaBci[i].service_category = (int) t; + + status = p.readInt32(&t); + cdmaBci[i].language = (int) t; + + status = p.readInt32(&t); + cdmaBci[i].selected = (uint8_t) t; + + appendPrintBuf("%s [%d: service_category=%d, language =%d, \ + entries.bSelected =%d]", printBuf, i, cdmaBci[i].service_category, + cdmaBci[i].language, cdmaBci[i].selected); + } + closeRequest; + + if (status != NO_ERROR) { + goto invalid; + } + + s_callbacks.onRequest(pRI->pCI->requestNumber, + cdmaBciPtrs, + num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), + pRI); + +#ifdef MEMSET_FREED + memset(cdmaBci, 0, num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo)); + memset(cdmaBciPtrs, 0, num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *)); +#endif + } + + return; + +invalid: + invalidCommandBlock(pRI); + return; +} + +static void dispatchRilCdmaSmsWriteArgs(Parcel &p, RequestInfo *pRI) { + RIL_CDMA_SMS_WriteArgs rcsw; + int32_t t; + uint32_t ut; + uint8_t uct; + status_t status; + int32_t digitCount; + + memset(&rcsw, 0, sizeof(rcsw)); + + status = p.readInt32(&t); + rcsw.status = t; + + status = p.readInt32(&t); + rcsw.message.uTeleserviceID = (int) t; + + status = p.read(&uct,sizeof(uct)); + rcsw.message.bIsServicePresent = (uint8_t) uct; + + status = p.readInt32(&t); + rcsw.message.uServicecategory = (int) t; + + status = p.readInt32(&t); + rcsw.message.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) t; + + status = p.readInt32(&t); + rcsw.message.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) t; + + status = p.readInt32(&t); + rcsw.message.sAddress.number_type = (RIL_CDMA_SMS_NumberType) t; + + status = p.readInt32(&t); + rcsw.message.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) t; + + status = p.read(&uct,sizeof(uct)); + rcsw.message.sAddress.number_of_digits = (uint8_t) uct; + + for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_ADDRESS_MAX; digitCount ++) { + status = p.read(&uct,sizeof(uct)); + rcsw.message.sAddress.digits[digitCount] = (uint8_t) uct; + } + + status = p.readInt32(&t); + rcsw.message.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) t; + + status = p.read(&uct,sizeof(uct)); + rcsw.message.sSubAddress.odd = (uint8_t) uct; + + status = p.read(&uct,sizeof(uct)); + rcsw.message.sSubAddress.number_of_digits = (uint8_t) uct; + + for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_SUBADDRESS_MAX; digitCount ++) { + status = p.read(&uct,sizeof(uct)); + rcsw.message.sSubAddress.digits[digitCount] = (uint8_t) uct; + } + + status = p.readInt32(&t); + rcsw.message.uBearerDataLen = (int) t; + + for(digitCount = 0 ; digitCount < RIL_CDMA_SMS_BEARER_DATA_MAX; digitCount ++) { + status = p.read(&uct, sizeof(uct)); + rcsw.message.aBearerData[digitCount] = (uint8_t) uct; + } + + if (status != NO_ERROR) { + goto invalid; + } + + startRequest; + appendPrintBuf("%sstatus=%d, message.uTeleserviceID=%d, message.bIsServicePresent=%d, \ + message.uServicecategory=%d, message.sAddress.digit_mode=%d, \ + message.sAddress.number_mode=%d, \ + message.sAddress.number_type=%d, ", + printBuf, rcsw.status, rcsw.message.uTeleserviceID, rcsw.message.bIsServicePresent, + rcsw.message.uServicecategory, rcsw.message.sAddress.digit_mode, + rcsw.message.sAddress.number_mode, + rcsw.message.sAddress.number_type); + closeRequest; + + printRequest(pRI->token, pRI->pCI->requestNumber); + + s_callbacks.onRequest(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw),pRI); + +#ifdef MEMSET_FREED + memset(&rcsw, 0, sizeof(rcsw)); +#endif + + return; + +invalid: + invalidCommandBlock(pRI); + return; + +} + +// For backwards compatibility in RIL_REQUEST_SETUP_DATA_CALL. +// Version 4 of the RIL interface adds a new PDP type parameter to support +// IPv6 and dual-stack PDP contexts. When dealing with a previous version of +// RIL, remove the parameter from the request. +static void dispatchDataCall(Parcel& p, RequestInfo *pRI) { + // In RIL v3, REQUEST_SETUP_DATA_CALL takes 6 parameters. + const int numParamsRilV3 = 6; + + // The first bytes of the RIL parcel contain the request number and the + // serial number - see processCommandBuffer(). Copy them over too. + int pos = p.dataPosition(); + + int numParams = p.readInt32(); + if (s_callbacks.version < 4 && numParams > numParamsRilV3) { + Parcel p2; + p2.appendFrom(&p, 0, pos); + p2.writeInt32(numParamsRilV3); + for(int i = 0; i < numParamsRilV3; i++) { + p2.writeString16(p.readString16()); + } + p2.setDataPosition(pos); + dispatchStrings(p2, pRI); + } else { + p.setDataPosition(pos); + dispatchStrings(p, pRI); + } +} + +// For backwards compatibility with RILs that dont support RIL_REQUEST_VOICE_RADIO_TECH. +// When all RILs handle this request, this function can be removed and +// the request can be sent directly to the RIL using dispatchVoid. +static void dispatchVoiceRadioTech(Parcel& p, RequestInfo *pRI) { + RIL_RadioState state = s_callbacks.onStateRequest(); + + if ((RADIO_STATE_UNAVAILABLE == state) || (RADIO_STATE_OFF == state)) { + RIL_onRequestComplete(pRI, RIL_E_RADIO_NOT_AVAILABLE, NULL, 0); + } + + // RILs that support RADIO_STATE_ON should support this request. + if (RADIO_STATE_ON == state) { + dispatchVoid(p, pRI); + return; + } + + // For Older RILs, that do not support RADIO_STATE_ON, assume that they + // will not support this new request either and decode Voice Radio Technology + // from Radio State + voiceRadioTech = decodeVoiceRadioTechnology(state); + + if (voiceRadioTech < 0) + RIL_onRequestComplete(pRI, RIL_E_GENERIC_FAILURE, NULL, 0); + else + RIL_onRequestComplete(pRI, RIL_E_SUCCESS, &voiceRadioTech, sizeof(int)); +} + +// For backwards compatibility in RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE:. +// When all RILs handle this request, this function can be removed and +// the request can be sent directly to the RIL using dispatchVoid. +static void dispatchCdmaSubscriptionSource(Parcel& p, RequestInfo *pRI) { + RIL_RadioState state = s_callbacks.onStateRequest(); + + if ((RADIO_STATE_UNAVAILABLE == state) || (RADIO_STATE_OFF == state)) { + RIL_onRequestComplete(pRI, RIL_E_RADIO_NOT_AVAILABLE, NULL, 0); + } + + // RILs that support RADIO_STATE_ON should support this request. + if (RADIO_STATE_ON == state) { + dispatchVoid(p, pRI); + return; + } + + // For Older RILs, that do not support RADIO_STATE_ON, assume that they + // will not support this new request either and decode CDMA Subscription Source + // from Radio State + cdmaSubscriptionSource = decodeCdmaSubscriptionSource(state); + + if (cdmaSubscriptionSource < 0) + RIL_onRequestComplete(pRI, RIL_E_GENERIC_FAILURE, NULL, 0); + else + RIL_onRequestComplete(pRI, RIL_E_SUCCESS, &cdmaSubscriptionSource, sizeof(int)); +} + +static int +blockingWrite(int fd, const void *buffer, size_t len) { + size_t writeOffset = 0; + const uint8_t *toWrite; + + toWrite = (const uint8_t *)buffer; + + while (writeOffset < len) { + ssize_t written; + do { + written = write (fd, toWrite + writeOffset, + len - writeOffset); + } while (written < 0 && errno == EINTR); + + if (written >= 0) { + writeOffset += written; + } else { // written < 0 + ALOGE ("RIL Response: unexpected error on write errno:%d", errno); + close(fd); + return -1; + } + } + + return 0; +} + +static int +sendResponseRaw (const void *data, size_t dataSize) { + int fd = s_fdCommand; + int ret; + uint32_t header; + + if (s_fdCommand < 0) { + return -1; + } + + if (dataSize > MAX_COMMAND_BYTES) { + ALOGE("RIL: packet larger than %u (%u)", + MAX_COMMAND_BYTES, (unsigned int )dataSize); + + return -1; + } + + pthread_mutex_lock(&s_writeMutex); + + header = htonl(dataSize); + + ret = blockingWrite(fd, (void *)&header, sizeof(header)); + + if (ret < 0) { + pthread_mutex_unlock(&s_writeMutex); + return ret; + } + + ret = blockingWrite(fd, data, dataSize); + + if (ret < 0) { + pthread_mutex_unlock(&s_writeMutex); + return ret; + } + + pthread_mutex_unlock(&s_writeMutex); + + return 0; +} + +static int +sendResponse (Parcel &p) { + printResponse; + return sendResponseRaw(p.data(), p.dataSize()); +} + +/** response is an int* pointing to an array of ints*/ + +static int +responseInts(Parcel &p, void *response, size_t responselen) { + int numInts; + + if (response == NULL && responselen != 0) { + ALOGE("invalid response: NULL"); + return RIL_ERRNO_INVALID_RESPONSE; + } + if (responselen % sizeof(int) != 0) { + ALOGE("invalid response length %d expected multiple of %d\n", + (int)responselen, (int)sizeof(int)); + return RIL_ERRNO_INVALID_RESPONSE; + } + + int *p_int = (int *) response; + + numInts = responselen / sizeof(int *); + p.writeInt32 (numInts); + + /* each int*/ + startResponse; + for (int i = 0 ; i < numInts ; i++) { + appendPrintBuf("%s%d,", printBuf, p_int[i]); + p.writeInt32(p_int[i]); + } + removeLastChar; + closeResponse; + + return 0; +} + +/** response is a char **, pointing to an array of char *'s + The parcel will begin with the version */ +static int responseStringsWithVersion(int version, Parcel &p, void *response, size_t responselen) { + p.writeInt32(version); + return responseStrings(p, response, responselen); +} + +/** response is a char **, pointing to an array of char *'s */ +static int responseStrings(Parcel &p, void *response, size_t responselen) { + return responseStrings(p, response, responselen, false); +} + +static int responseStringsNetworks(Parcel &p, void *response, size_t responselen) { + int numStrings; + int inQANElements = 5; + int outQANElements = 4; + + if (response == NULL && responselen != 0) { + ALOGE("invalid response: NULL"); + return RIL_ERRNO_INVALID_RESPONSE; + } + if (responselen % sizeof(char *) != 0) { + ALOGE("invalid response length %d expected multiple of %d\n", + (int)responselen, (int)sizeof(char *)); + return RIL_ERRNO_INVALID_RESPONSE; + } + + if (response == NULL) { + p.writeInt32 (0); + } else { + char **p_cur = (char **) response; + + numStrings = responselen / sizeof(char *); + p.writeInt32 ((numStrings / inQANElements) * outQANElements); + + /* each string*/ + startResponse; + int j=0; + for (int i = 0 ; i < numStrings ; i++) { + /* Samsung is sending 5 elements, upper layer expects 4. + Drop every 5th element here */ + if (j == outQANElements) { + j=0; + } else { + appendPrintBuf("%s%s,", printBuf, (char*)p_cur[i]); + writeStringToParcel (p, p_cur[i]); + j++; + } + } + removeLastChar; + closeResponse; + } + return 0; +} + +/** response is a char **, pointing to an array of char *'s */ +static int responseStrings(Parcel &p, void *response, size_t responselen, bool network_search) { + int numStrings; + + if (response == NULL && responselen != 0) { + ALOGE("invalid response: NULL"); + return RIL_ERRNO_INVALID_RESPONSE; + } + if (responselen % sizeof(char *) != 0) { + ALOGE("invalid response length %d expected multiple of %d\n", + (int)responselen, (int)sizeof(char *)); + return RIL_ERRNO_INVALID_RESPONSE; + } + + if (response == NULL) { + p.writeInt32 (0); + } else { + char **p_cur = (char **) response; + + numStrings = responselen / sizeof(char *); + p.writeInt32 (numStrings); + + /* each string*/ + startResponse; + for (int i = 0 ; i < numStrings ; i++) { + appendPrintBuf("%s%s,", printBuf, (char*)p_cur[i]); + writeStringToParcel (p, p_cur[i]); + } + removeLastChar; + closeResponse; + } + return 0; +} + +/** + * NULL strings are accepted + * FIXME currently ignores responselen + */ +static int responseString(Parcel &p, void *response, size_t responselen) { + /* one string only */ + startResponse; + appendPrintBuf("%s%s", printBuf, (char*)response); + closeResponse; + + writeStringToParcel(p, (const char *)response); + + return 0; +} + +static int responseVoid(Parcel &p, void *response, size_t responselen) { + startResponse; + removeLastChar; + return 0; +} + +static int responseCallList(Parcel &p, void *response, size_t responselen) { + int num; + + if (response == NULL && responselen != 0) { + ALOGE("invalid response: NULL"); + return RIL_ERRNO_INVALID_RESPONSE; + } + + if (responselen % sizeof (RIL_Call *) != 0) { + ALOGE("invalid response length %d expected multiple of %d\n", + (int)responselen, (int)sizeof (RIL_Call *)); + return RIL_ERRNO_INVALID_RESPONSE; + } + + startResponse; + /* number of call info's */ + num = responselen / sizeof(RIL_Call *); + p.writeInt32(num); + + for (int i = 0 ; i < num ; i++) { + RIL_Call *p_cur = ((RIL_Call **) response)[i]; + /* each call info */ + p.writeInt32(p_cur->state); + p.writeInt32(p_cur->index); + p.writeInt32(p_cur->toa); + p.writeInt32(p_cur->isMpty); + p.writeInt32(p_cur->isMT); + p.writeInt32(p_cur->als); + p.writeInt32(p_cur->isVoice); + p.writeInt32(p_cur->isVoicePrivacy); + writeStringToParcel(p, p_cur->number); + p.writeInt32(p_cur->numberPresentation); + writeStringToParcel(p, p_cur->name); + p.writeInt32(p_cur->namePresentation); + // Remove when partners upgrade to version 3 + if ((s_callbacks.version < 3) || (p_cur->uusInfo == NULL || p_cur->uusInfo->uusData == NULL)) { + p.writeInt32(0); /* UUS Information is absent */ + } else { + RIL_UUS_Info *uusInfo = p_cur->uusInfo; + p.writeInt32(1); /* UUS Information is present */ + p.writeInt32(uusInfo->uusType); + p.writeInt32(uusInfo->uusDcs); + p.writeInt32(uusInfo->uusLength); + p.write(uusInfo->uusData, uusInfo->uusLength); + } + appendPrintBuf("%s[id=%d,%s,toa=%d,", + printBuf, + p_cur->index, + callStateToString(p_cur->state), + p_cur->toa); + appendPrintBuf("%s%s,%s,als=%d,%s,%s,", + printBuf, + (p_cur->isMpty)?"conf":"norm", + (p_cur->isMT)?"mt":"mo", + p_cur->als, + (p_cur->isVoice)?"voc":"nonvoc", + (p_cur->isVoicePrivacy)?"evp":"noevp"); + appendPrintBuf("%s%s,cli=%d,name='%s',%d]", + printBuf, + p_cur->number, + p_cur->numberPresentation, + p_cur->name, + p_cur->namePresentation); + } + removeLastChar; + closeResponse; + + return 0; +} + +static int responseSMS(Parcel &p, void *response, size_t responselen) { + if (response == NULL) { + ALOGE("invalid response: NULL"); + return RIL_ERRNO_INVALID_RESPONSE; + } + + if (responselen != sizeof (RIL_SMS_Response) ) { + ALOGE("invalid response length %d expected %d", + (int)responselen, (int)sizeof (RIL_SMS_Response)); + return RIL_ERRNO_INVALID_RESPONSE; + } + + RIL_SMS_Response *p_cur = (RIL_SMS_Response *) response; + + p.writeInt32(p_cur->messageRef); + writeStringToParcel(p, p_cur->ackPDU); + p.writeInt32(p_cur->errorCode); + + startResponse; + appendPrintBuf("%s%d,%s,%d", printBuf, p_cur->messageRef, + (char*)p_cur->ackPDU, p_cur->errorCode); + closeResponse; + + return 0; +} + +static int responseDataCallListV4(Parcel &p, void *response, size_t responselen) +{ + if (response == NULL && responselen != 0) { + ALOGE("invalid response: NULL"); + return RIL_ERRNO_INVALID_RESPONSE; + } + + if (responselen % sizeof(RIL_Data_Call_Response_v4) != 0) { + ALOGE("invalid response length %d expected multiple of %d", + (int)responselen, (int)sizeof(RIL_Data_Call_Response_v4)); + return RIL_ERRNO_INVALID_RESPONSE; + } + + int num = responselen / sizeof(RIL_Data_Call_Response_v4); + p.writeInt32(num); + + RIL_Data_Call_Response_v4 *p_cur = (RIL_Data_Call_Response_v4 *) response; + startResponse; + int i; + for (i = 0; i < num; i++) { + p.writeInt32(p_cur[i].cid); + p.writeInt32(p_cur[i].active); + writeStringToParcel(p, p_cur[i].type); + // apn is not used, so don't send. + writeStringToParcel(p, p_cur[i].address); + appendPrintBuf("%s[cid=%d,%s,%s,%s],", printBuf, + p_cur[i].cid, + (p_cur[i].active==0)?"down":"up", + (char*)p_cur[i].type, + (char*)p_cur[i].address); + } + removeLastChar; + closeResponse; + + return 0; +} + +static int responseDataCallList(Parcel &p, void *response, size_t responselen) +{ + // Write version + p.writeInt32(s_callbacks.version); + + if (s_callbacks.version < 5) { + return responseDataCallListV4(p, response, responselen); + } else { + if (response == NULL && responselen != 0) { + ALOGE("invalid response: NULL"); + return RIL_ERRNO_INVALID_RESPONSE; + } + + if (responselen % sizeof(RIL_Data_Call_Response_v6) != 0) { + ALOGE("invalid response length %d expected multiple of %d", + (int)responselen, (int)sizeof(RIL_Data_Call_Response_v6)); + return RIL_ERRNO_INVALID_RESPONSE; + } + + int num = responselen / sizeof(RIL_Data_Call_Response_v6); + p.writeInt32(num); + + RIL_Data_Call_Response_v6 *p_cur = (RIL_Data_Call_Response_v6 *) response; + startResponse; + int i; + for (i = 0; i < num; i++) { + p.writeInt32((int)p_cur[i].status); + p.writeInt32(p_cur[i].suggestedRetryTime); + p.writeInt32(p_cur[i].cid); + p.writeInt32(p_cur[i].active); + writeStringToParcel(p, p_cur[i].type); + writeStringToParcel(p, p_cur[i].ifname); + writeStringToParcel(p, p_cur[i].addresses); + writeStringToParcel(p, p_cur[i].dnses); + writeStringToParcel(p, p_cur[i].gateways); + appendPrintBuf("%s[status=%d,retry=%d,cid=%d,%s,%s,%s,%s,%s,%s],", printBuf, + p_cur[i].status, + p_cur[i].suggestedRetryTime, + p_cur[i].cid, + (p_cur[i].active==0)?"down":"up", + (char*)p_cur[i].type, + (char*)p_cur[i].ifname, + (char*)p_cur[i].addresses, + (char*)p_cur[i].dnses, + (char*)p_cur[i].gateways); + } + removeLastChar; + closeResponse; + } + + return 0; +} + +static int responseSetupDataCall(Parcel &p, void *response, size_t responselen) +{ + if (s_callbacks.version < 5) { + return responseStringsWithVersion(s_callbacks.version, p, response, responselen); + } else { + return responseDataCallList(p, response, responselen); + } +} + +static int responseRaw(Parcel &p, void *response, size_t responselen) { + if (response == NULL && responselen != 0) { + ALOGE("invalid response: NULL with responselen != 0"); + return RIL_ERRNO_INVALID_RESPONSE; + } + + // The java code reads -1 size as null byte array + if (response == NULL) { + p.writeInt32(-1); + } else { + p.writeInt32(responselen); + p.write(response, responselen); + } + + return 0; +} + + +static int responseSIM_IO(Parcel &p, void *response, size_t responselen) { + if (response == NULL) { + ALOGE("invalid response: NULL"); + return RIL_ERRNO_INVALID_RESPONSE; + } + + if (responselen != sizeof (RIL_SIM_IO_Response) ) { + ALOGE("invalid response length was %d expected %d", + (int)responselen, (int)sizeof (RIL_SIM_IO_Response)); + return RIL_ERRNO_INVALID_RESPONSE; + } + + RIL_SIM_IO_Response *p_cur = (RIL_SIM_IO_Response *) response; + p.writeInt32(p_cur->sw1); + p.writeInt32(p_cur->sw2); + writeStringToParcel(p, p_cur->simResponse); + + startResponse; + appendPrintBuf("%ssw1=0x%X,sw2=0x%X,%s", printBuf, p_cur->sw1, p_cur->sw2, + (char*)p_cur->simResponse); + closeResponse; + + + return 0; +} + +static int responseCallForwards(Parcel &p, void *response, size_t responselen) { + int num; + + if (response == NULL && responselen != 0) { + ALOGE("invalid response: NULL"); + return RIL_ERRNO_INVALID_RESPONSE; + } + + if (responselen % sizeof(RIL_CallForwardInfo *) != 0) { + ALOGE("invalid response length %d expected multiple of %d", + (int)responselen, (int)sizeof(RIL_CallForwardInfo *)); + return RIL_ERRNO_INVALID_RESPONSE; + } + + /* number of call info's */ + num = responselen / sizeof(RIL_CallForwardInfo *); + p.writeInt32(num); + + startResponse; + for (int i = 0 ; i < num ; i++) { + RIL_CallForwardInfo *p_cur = ((RIL_CallForwardInfo **) response)[i]; + + p.writeInt32(p_cur->status); + p.writeInt32(p_cur->reason); + p.writeInt32(p_cur->serviceClass); + p.writeInt32(p_cur->toa); + writeStringToParcel(p, p_cur->number); + p.writeInt32(p_cur->timeSeconds); + appendPrintBuf("%s[%s,reason=%d,cls=%d,toa=%d,%s,tout=%d],", printBuf, + (p_cur->status==1)?"enable":"disable", + p_cur->reason, p_cur->serviceClass, p_cur->toa, + (char*)p_cur->number, + p_cur->timeSeconds); + } + removeLastChar; + closeResponse; + + return 0; +} + +static int responseSsn(Parcel &p, void *response, size_t responselen) { + if (response == NULL) { + ALOGE("invalid response: NULL"); + return RIL_ERRNO_INVALID_RESPONSE; + } + + if (responselen != sizeof(RIL_SuppSvcNotification)) { + ALOGE("invalid response length was %d expected %d", + (int)responselen, (int)sizeof (RIL_SuppSvcNotification)); + return RIL_ERRNO_INVALID_RESPONSE; + } + + RIL_SuppSvcNotification *p_cur = (RIL_SuppSvcNotification *) response; + p.writeInt32(p_cur->notificationType); + p.writeInt32(p_cur->code); + p.writeInt32(p_cur->index); + p.writeInt32(p_cur->type); + writeStringToParcel(p, p_cur->number); + + startResponse; + appendPrintBuf("%s%s,code=%d,id=%d,type=%d,%s", printBuf, + (p_cur->notificationType==0)?"mo":"mt", + p_cur->code, p_cur->index, p_cur->type, + (char*)p_cur->number); + closeResponse; + + return 0; +} + +static int responseCellList(Parcel &p, void *response, size_t responselen) { + int num; + + if (response == NULL && responselen != 0) { + ALOGE("invalid response: NULL"); + return RIL_ERRNO_INVALID_RESPONSE; + } + + if (responselen % sizeof (RIL_NeighboringCell *) != 0) { + ALOGE("invalid response length %d expected multiple of %d\n", + (int)responselen, (int)sizeof (RIL_NeighboringCell *)); + return RIL_ERRNO_INVALID_RESPONSE; + } + + startResponse; + /* number of records */ + num = responselen / sizeof(RIL_NeighboringCell *); + p.writeInt32(num); + + for (int i = 0 ; i < num ; i++) { + RIL_NeighboringCell *p_cur = ((RIL_NeighboringCell **) response)[i]; + + p.writeInt32(p_cur->rssi); + writeStringToParcel (p, p_cur->cid); + + appendPrintBuf("%s[cid=%s,rssi=%d],", printBuf, + p_cur->cid, p_cur->rssi); + } + removeLastChar; + closeResponse; + + return 0; +} + +/** + * Marshall the signalInfoRecord into the parcel if it exists. + */ +static void marshallSignalInfoRecord(Parcel &p, + RIL_CDMA_SignalInfoRecord &p_signalInfoRecord) { + p.writeInt32(p_signalInfoRecord.isPresent); + p.writeInt32(p_signalInfoRecord.signalType); + p.writeInt32(p_signalInfoRecord.alertPitch); + p.writeInt32(p_signalInfoRecord.signal); +} + +static int responseCdmaInformationRecords(Parcel &p, + void *response, size_t responselen) { + int num; + char* string8 = NULL; + int buffer_lenght; + RIL_CDMA_InformationRecord *infoRec; + + if (response == NULL && responselen != 0) { + ALOGE("invalid response: NULL"); + return RIL_ERRNO_INVALID_RESPONSE; + } + + if (responselen != sizeof (RIL_CDMA_InformationRecords)) { + ALOGE("invalid response length %d expected multiple of %d\n", + (int)responselen, (int)sizeof (RIL_CDMA_InformationRecords *)); + return RIL_ERRNO_INVALID_RESPONSE; + } + + RIL_CDMA_InformationRecords *p_cur = + (RIL_CDMA_InformationRecords *) response; + num = MIN(p_cur->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS); + + startResponse; + p.writeInt32(num); + + for (int i = 0 ; i < num ; i++) { + infoRec = &p_cur->infoRec[i]; + p.writeInt32(infoRec->name); + switch (infoRec->name) { + case RIL_CDMA_DISPLAY_INFO_REC: + case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: + if (infoRec->rec.display.alpha_len > + CDMA_ALPHA_INFO_BUFFER_LENGTH) { + ALOGE("invalid display info response length %d \ + expected not more than %d\n", + (int)infoRec->rec.display.alpha_len, + CDMA_ALPHA_INFO_BUFFER_LENGTH); + return RIL_ERRNO_INVALID_RESPONSE; + } + string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) + * sizeof(char) ); + for (int i = 0 ; i < infoRec->rec.display.alpha_len ; i++) { + string8[i] = infoRec->rec.display.alpha_buf[i]; + } + string8[(int)infoRec->rec.display.alpha_len] = '\0'; + writeStringToParcel(p, (const char*)string8); + free(string8); + string8 = NULL; + break; + case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC: + case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC: + case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: + if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) { + ALOGE("invalid display info response length %d \ + expected not more than %d\n", + (int)infoRec->rec.number.len, + CDMA_NUMBER_INFO_BUFFER_LENGTH); + return RIL_ERRNO_INVALID_RESPONSE; + } + string8 = (char*) malloc((infoRec->rec.number.len + 1) + * sizeof(char) ); + for (int i = 0 ; i < infoRec->rec.number.len; i++) { + string8[i] = infoRec->rec.number.buf[i]; + } + string8[(int)infoRec->rec.number.len] = '\0'; + writeStringToParcel(p, (const char*)string8); + free(string8); + string8 = NULL; + p.writeInt32(infoRec->rec.number.number_type); + p.writeInt32(infoRec->rec.number.number_plan); + p.writeInt32(infoRec->rec.number.pi); + p.writeInt32(infoRec->rec.number.si); + break; + case RIL_CDMA_SIGNAL_INFO_REC: + p.writeInt32(infoRec->rec.signal.isPresent); + p.writeInt32(infoRec->rec.signal.signalType); + p.writeInt32(infoRec->rec.signal.alertPitch); + p.writeInt32(infoRec->rec.signal.signal); + + appendPrintBuf("%sisPresent=%X, signalType=%X, \ + alertPitch=%X, signal=%X, ", + printBuf, (int)infoRec->rec.signal.isPresent, + (int)infoRec->rec.signal.signalType, + (int)infoRec->rec.signal.alertPitch, + (int)infoRec->rec.signal.signal); + removeLastChar; + break; + case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: + if (infoRec->rec.redir.redirectingNumber.len > + CDMA_NUMBER_INFO_BUFFER_LENGTH) { + ALOGE("invalid display info response length %d \ + expected not more than %d\n", + (int)infoRec->rec.redir.redirectingNumber.len, + CDMA_NUMBER_INFO_BUFFER_LENGTH); + return RIL_ERRNO_INVALID_RESPONSE; + } + string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber + .len + 1) * sizeof(char) ); + for (int i = 0; + i < infoRec->rec.redir.redirectingNumber.len; + i++) { + string8[i] = infoRec->rec.redir.redirectingNumber.buf[i]; + } + string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0'; + writeStringToParcel(p, (const char*)string8); + free(string8); + string8 = NULL; + p.writeInt32(infoRec->rec.redir.redirectingNumber.number_type); + p.writeInt32(infoRec->rec.redir.redirectingNumber.number_plan); + p.writeInt32(infoRec->rec.redir.redirectingNumber.pi); + p.writeInt32(infoRec->rec.redir.redirectingNumber.si); + p.writeInt32(infoRec->rec.redir.redirectingReason); + break; + case RIL_CDMA_LINE_CONTROL_INFO_REC: + p.writeInt32(infoRec->rec.lineCtrl.lineCtrlPolarityIncluded); + p.writeInt32(infoRec->rec.lineCtrl.lineCtrlToggle); + p.writeInt32(infoRec->rec.lineCtrl.lineCtrlReverse); + p.writeInt32(infoRec->rec.lineCtrl.lineCtrlPowerDenial); + + appendPrintBuf("%slineCtrlPolarityIncluded=%d, \ + lineCtrlToggle=%d, lineCtrlReverse=%d, \ + lineCtrlPowerDenial=%d, ", printBuf, + (int)infoRec->rec.lineCtrl.lineCtrlPolarityIncluded, + (int)infoRec->rec.lineCtrl.lineCtrlToggle, + (int)infoRec->rec.lineCtrl.lineCtrlReverse, + (int)infoRec->rec.lineCtrl.lineCtrlPowerDenial); + removeLastChar; + break; + case RIL_CDMA_T53_CLIR_INFO_REC: + p.writeInt32((int)(infoRec->rec.clir.cause)); + + appendPrintBuf("%scause%d", printBuf, infoRec->rec.clir.cause); + removeLastChar; + break; + case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: + p.writeInt32(infoRec->rec.audioCtrl.upLink); + p.writeInt32(infoRec->rec.audioCtrl.downLink); + + appendPrintBuf("%supLink=%d, downLink=%d, ", printBuf, + infoRec->rec.audioCtrl.upLink, + infoRec->rec.audioCtrl.downLink); + removeLastChar; + break; + case RIL_CDMA_T53_RELEASE_INFO_REC: + // TODO(Moto): See David Krause, he has the answer:) + ALOGE("RIL_CDMA_T53_RELEASE_INFO_REC: return INVALID_RESPONSE"); + return RIL_ERRNO_INVALID_RESPONSE; + default: + ALOGE("Incorrect name value"); + return RIL_ERRNO_INVALID_RESPONSE; + } + } + closeResponse; + + return 0; +} + +static int responseRilSignalStrength(Parcel &p, + void *response, size_t responselen) { + + int gsmSignalStrength; + int cdmaDbm; + int evdoDbm; + + if (response == NULL && responselen != 0) { + ALOGE("invalid response: NULL"); + return RIL_ERRNO_INVALID_RESPONSE; + } + + ALOGE("responseRilSignalStrength()"); + + if (responselen >= sizeof (RIL_SignalStrength_v5)) { + RIL_SignalStrength_v6 *p_cur = ((RIL_SignalStrength_v6 *) response); + + /* gsmSignalStrength */ + ALOGD("gsmSignalStrength (raw)=%d", p_cur->GW_SignalStrength.signalStrength); + gsmSignalStrength = p_cur->GW_SignalStrength.signalStrength & 0xFF; + if (gsmSignalStrength < 0) { + gsmSignalStrength = 99; + } else if (gsmSignalStrength > 31 && gsmSignalStrength != 99) { + gsmSignalStrength = 31; + } + ALOGD("gsmSignalStrength (corrected)=%d", gsmSignalStrength); + p.writeInt32(gsmSignalStrength); + + /* gsmBitErrorRate */ + p.writeInt32(p_cur->GW_SignalStrength.bitErrorRate); + + /* cdmaDbm */ + //ALOGD("cdmaDbm (raw)=%d", p_cur->CDMA_SignalStrength.dbm); + cdmaDbm = p_cur->CDMA_SignalStrength.dbm & 0xFF; + if (cdmaDbm < 0) { + cdmaDbm = 99; + } else if (cdmaDbm > 31 && cdmaDbm != 99) { + cdmaDbm = 31; + } + //ALOGD("cdmaDbm (corrected)=%d", cdmaDbm); + p.writeInt32(cdmaDbm); + + /* cdmaEcio */ + p.writeInt32(p_cur->CDMA_SignalStrength.ecio); + + /* evdoDbm */ + //ALOGD("evdoDbm (raw)=%d", p_cur->EVDO_SignalStrength.dbm); + evdoDbm = p_cur->EVDO_SignalStrength.dbm & 0xFF; + if (evdoDbm < 0) { + evdoDbm = 99; + } else if (evdoDbm > 31 && evdoDbm != 99) { + evdoDbm = 31; + } + //ALOGD("evdoDbm (corrected)=%d", evdoDbm); + p.writeInt32(evdoDbm); + + /* evdoEcio */ + p.writeInt32(p_cur->EVDO_SignalStrength.ecio); + /* evdoSnr */ + p.writeInt32(p_cur->EVDO_SignalStrength.signalNoiseRatio); + + if (responselen >= sizeof (RIL_SignalStrength_v6)) { + /* lteSignalStrength */ + p.writeInt32(p_cur->LTE_SignalStrength.signalStrength); + + /* + * ril version <=6 receives negative values for rsrp + * workaround for backward compatibility + */ + p_cur->LTE_SignalStrength.rsrp = + ((s_callbacks.version <= 6) && (p_cur->LTE_SignalStrength.rsrp < 0 )) ? + -(p_cur->LTE_SignalStrength.rsrp) : p_cur->LTE_SignalStrength.rsrp; + + /* lteRsrp */ + p.writeInt32(p_cur->LTE_SignalStrength.rsrp); + /* lteRsrq */ + p.writeInt32(p_cur->LTE_SignalStrength.rsrq); + /* lteRssnr */ + p.writeInt32(p_cur->LTE_SignalStrength.rssnr); + /* lteCqi */ + p.writeInt32(p_cur->LTE_SignalStrength.cqi); + + } else { + memset(&p_cur->LTE_SignalStrength, sizeof (RIL_LTE_SignalStrength), 0); + } + + startResponse; + appendPrintBuf("%s[signalStrength=%d,bitErrorRate=%d,\ + CDMA_SS.dbm=%d,CDMA_SSecio=%d,\ + EVDO_SS.dbm=%d,EVDO_SS.ecio=%d,\ + EVDO_SS.signalNoiseRatio=%d,\ + LTE_SS.signalStrength=%d,LTE_SS.rsrp=%d,LTE_SS.rsrq=%d,\ + LTE_SS.rssnr=%d,LTE_SS.cqi=%d]", + printBuf, + gsmSignalStrength, + p_cur->GW_SignalStrength.bitErrorRate, + cdmaDbm, + p_cur->CDMA_SignalStrength.ecio, + evdoDbm, + p_cur->EVDO_SignalStrength.ecio, + p_cur->EVDO_SignalStrength.signalNoiseRatio, + p_cur->LTE_SignalStrength.signalStrength, + p_cur->LTE_SignalStrength.rsrp, + p_cur->LTE_SignalStrength.rsrq, + p_cur->LTE_SignalStrength.rssnr, + p_cur->LTE_SignalStrength.cqi); + closeResponse; + + } else { + ALOGE("invalid response length"); + return RIL_ERRNO_INVALID_RESPONSE; + } + + return 0; +} + +static int responseCallRing(Parcel &p, void *response, size_t responselen) { + if ((response == NULL) || (responselen == 0)) { + return responseVoid(p, response, responselen); + } else { + return responseCdmaSignalInfoRecord(p, response, responselen); + } +} + +static int responseCdmaSignalInfoRecord(Parcel &p, void *response, size_t responselen) { + if (response == NULL || responselen == 0) { + ALOGE("invalid response: NULL"); + return RIL_ERRNO_INVALID_RESPONSE; + } + + if (responselen != sizeof (RIL_CDMA_SignalInfoRecord)) { + ALOGE("invalid response length %d expected sizeof (RIL_CDMA_SignalInfoRecord) of %d\n", + (int)responselen, (int)sizeof (RIL_CDMA_SignalInfoRecord)); + return RIL_ERRNO_INVALID_RESPONSE; + } + + startResponse; + + RIL_CDMA_SignalInfoRecord *p_cur = ((RIL_CDMA_SignalInfoRecord *) response); + marshallSignalInfoRecord(p, *p_cur); + + appendPrintBuf("%s[isPresent=%d,signalType=%d,alertPitch=%d\ + signal=%d]", + printBuf, + p_cur->isPresent, + p_cur->signalType, + p_cur->alertPitch, + p_cur->signal); + + closeResponse; + return 0; +} + +static int responseCdmaCallWaiting(Parcel &p, void *response, + size_t responselen) { + if (response == NULL && responselen != 0) { + ALOGE("invalid response: NULL"); + return RIL_ERRNO_INVALID_RESPONSE; + } + + if (responselen < sizeof(RIL_CDMA_CallWaiting_v6)) { + ALOGW("Upgrade to ril version %d\n", RIL_VERSION); + } + + RIL_CDMA_CallWaiting_v6 *p_cur = ((RIL_CDMA_CallWaiting_v6 *) response); + + writeStringToParcel(p, p_cur->number); + p.writeInt32(p_cur->numberPresentation); + writeStringToParcel(p, p_cur->name); + marshallSignalInfoRecord(p, p_cur->signalInfoRecord); + + if (responselen >= sizeof(RIL_CDMA_CallWaiting_v6)) { + p.writeInt32(p_cur->number_type); + p.writeInt32(p_cur->number_plan); + } else { + p.writeInt32(0); + p.writeInt32(0); + } + + startResponse; + appendPrintBuf("%snumber=%s,numberPresentation=%d, name=%s,\ + signalInfoRecord[isPresent=%d,signalType=%d,alertPitch=%d\ + signal=%d,number_type=%d,number_plan=%d]", + printBuf, + p_cur->number, + p_cur->numberPresentation, + p_cur->name, + p_cur->signalInfoRecord.isPresent, + p_cur->signalInfoRecord.signalType, + p_cur->signalInfoRecord.alertPitch, + p_cur->signalInfoRecord.signal, + p_cur->number_type, + p_cur->number_plan); + closeResponse; + + return 0; +} + +static int responseSimRefresh(Parcel &p, void *response, size_t responselen) { + if (response == NULL && responselen != 0) { + ALOGE("responseSimRefresh: invalid response: NULL"); + return RIL_ERRNO_INVALID_RESPONSE; + } + + startResponse; + if (s_callbacks.version == 7) { + RIL_SimRefreshResponse_v7 *p_cur = ((RIL_SimRefreshResponse_v7 *) response); + p.writeInt32(p_cur->result); + p.writeInt32(p_cur->ef_id); + writeStringToParcel(p, p_cur->aid); + + appendPrintBuf("%sresult=%d, ef_id=%d, aid=%s", + printBuf, + p_cur->result, + p_cur->ef_id, + p_cur->aid); + } else { + int *p_cur = ((int *) response); + p.writeInt32(p_cur[0]); + p.writeInt32(p_cur[1]); + writeStringToParcel(p, NULL); + + appendPrintBuf("%sresult=%d, ef_id=%d", + printBuf, + p_cur[0], + p_cur[1]); + } + closeResponse; + + return 0; +} + +static void triggerEvLoop() { + int ret; + if (!pthread_equal(pthread_self(), s_tid_dispatch)) { + /* trigger event loop to wakeup. No reason to do this, + * if we're in the event loop thread */ + do { + ret = write (s_fdWakeupWrite, " ", 1); + } while (ret < 0 && errno == EINTR); + } +} + +static void rilEventAddWakeup(struct ril_event *ev) { + ril_event_add(ev); + triggerEvLoop(); +} + +static void sendSimStatusAppInfo(Parcel &p, int num_apps, RIL_AppStatus appStatus[]) { + p.writeInt32(num_apps); + startResponse; + for (int i = 0; i < num_apps; i++) { + p.writeInt32(appStatus[i].app_type); + p.writeInt32(appStatus[i].app_state); + p.writeInt32(appStatus[i].perso_substate); + writeStringToParcel(p, (const char*)(appStatus[i].aid_ptr)); + writeStringToParcel(p, (const char*) + (appStatus[i].app_label_ptr)); + p.writeInt32(appStatus[i].pin1_replaced); + p.writeInt32(appStatus[i].pin1); + p.writeInt32(appStatus[i].pin2); + appendPrintBuf("%s[app_type=%d,app_state=%d,perso_substate=%d,\ + aid_ptr=%s,app_label_ptr=%s,pin1_replaced=%d,pin1=%d,pin2=%d],", + printBuf, + appStatus[i].app_type, + appStatus[i].app_state, + appStatus[i].perso_substate, + appStatus[i].aid_ptr, + appStatus[i].app_label_ptr, + appStatus[i].pin1_replaced, + appStatus[i].pin1, + appStatus[i].pin2); + } + closeResponse; +} + +static int responseSimStatus(Parcel &p, void *response, size_t responselen) { + int i; + + if (response == NULL && responselen != 0) { + ALOGE("invalid response: NULL"); + return RIL_ERRNO_INVALID_RESPONSE; + } + + if (responselen == sizeof (RIL_CardStatus_v6)) { + ALOGE("RIL_CardStatus_v6"); + RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response); + + p.writeInt32(p_cur->card_state); + p.writeInt32(p_cur->universal_pin_state); + p.writeInt32(p_cur->gsm_umts_subscription_app_index); + p.writeInt32(p_cur->cdma_subscription_app_index); + p.writeInt32(p_cur->ims_subscription_app_index); + + sendSimStatusAppInfo(p, p_cur->num_applications, p_cur->applications); + } else if (responselen == sizeof (RIL_CardStatus_v5)) { + ALOGE("RIL_CardStatus_v5"); + RIL_CardStatus_v5 *p_cur = ((RIL_CardStatus_v5 *) response); + + p.writeInt32(p_cur->card_state); + p.writeInt32(p_cur->universal_pin_state); + p.writeInt32(p_cur->gsm_umts_subscription_app_index); + p.writeInt32(p_cur->cdma_subscription_app_index); + p.writeInt32(-1); + + sendSimStatusAppInfo(p, p_cur->num_applications, p_cur->applications); + } else { + ALOGE("responseSimStatus: A RilCardStatus_v6 or _v5 expected\n"); + ALOGE("responselen=%d", responselen); + ALOGE("RIL_CardStatus_v5=%d", sizeof (RIL_CardStatus_v5)); + ALOGE("RIL_CardStatus_v6=%d", sizeof (RIL_CardStatus_v6)); + return RIL_ERRNO_INVALID_RESPONSE; + } + + return 0; +} + +static int responseGsmBrSmsCnf(Parcel &p, void *response, size_t responselen) { + int num = responselen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *); + p.writeInt32(num); + + startResponse; + RIL_GSM_BroadcastSmsConfigInfo **p_cur = + (RIL_GSM_BroadcastSmsConfigInfo **) response; + for (int i = 0; i < num; i++) { + p.writeInt32(p_cur[i]->fromServiceId); + p.writeInt32(p_cur[i]->toServiceId); + p.writeInt32(p_cur[i]->fromCodeScheme); + p.writeInt32(p_cur[i]->toCodeScheme); + p.writeInt32(p_cur[i]->selected); + + appendPrintBuf("%s [%d: fromServiceId=%d, toServiceId=%d, \ + fromCodeScheme=%d, toCodeScheme=%d, selected =%d]", + printBuf, i, p_cur[i]->fromServiceId, p_cur[i]->toServiceId, + p_cur[i]->fromCodeScheme, p_cur[i]->toCodeScheme, + p_cur[i]->selected); + } + closeResponse; + + return 0; +} + +static int responseCdmaBrSmsCnf(Parcel &p, void *response, size_t responselen) { + RIL_CDMA_BroadcastSmsConfigInfo **p_cur = + (RIL_CDMA_BroadcastSmsConfigInfo **) response; + + int num = responselen / sizeof (RIL_CDMA_BroadcastSmsConfigInfo *); + p.writeInt32(num); + + startResponse; + for (int i = 0 ; i < num ; i++ ) { + p.writeInt32(p_cur[i]->service_category); + p.writeInt32(p_cur[i]->language); + p.writeInt32(p_cur[i]->selected); + + appendPrintBuf("%s [%d: srvice_category=%d, language =%d, \ + selected =%d], ", + printBuf, i, p_cur[i]->service_category, p_cur[i]->language, + p_cur[i]->selected); + } + closeResponse; + + return 0; +} + +static int responseCdmaSms(Parcel &p, void *response, size_t responselen) { + int num; + int digitCount; + int digitLimit; + uint8_t uct; + void* dest; + + ALOGD("Inside responseCdmaSms"); + + if (response == NULL && responselen != 0) { + ALOGE("invalid response: NULL"); + return RIL_ERRNO_INVALID_RESPONSE; + } + + if (responselen != sizeof(RIL_CDMA_SMS_Message)) { + ALOGE("invalid response length was %d expected %d", + (int)responselen, (int)sizeof(RIL_CDMA_SMS_Message)); + return RIL_ERRNO_INVALID_RESPONSE; + } + + RIL_CDMA_SMS_Message *p_cur = (RIL_CDMA_SMS_Message *) response; + p.writeInt32(p_cur->uTeleserviceID); + p.write(&(p_cur->bIsServicePresent),sizeof(uct)); + p.writeInt32(p_cur->uServicecategory); + p.writeInt32(p_cur->sAddress.digit_mode); + p.writeInt32(p_cur->sAddress.number_mode); + p.writeInt32(p_cur->sAddress.number_type); + p.writeInt32(p_cur->sAddress.number_plan); + p.write(&(p_cur->sAddress.number_of_digits), sizeof(uct)); + digitLimit= MIN((p_cur->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX); + for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { + p.write(&(p_cur->sAddress.digits[digitCount]),sizeof(uct)); + } + + p.writeInt32(p_cur->sSubAddress.subaddressType); + p.write(&(p_cur->sSubAddress.odd),sizeof(uct)); + p.write(&(p_cur->sSubAddress.number_of_digits),sizeof(uct)); + digitLimit= MIN((p_cur->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX); + for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { + p.write(&(p_cur->sSubAddress.digits[digitCount]),sizeof(uct)); + } + + digitLimit= MIN((p_cur->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX); + p.writeInt32(p_cur->uBearerDataLen); + for(digitCount =0 ; digitCount < digitLimit; digitCount ++) { + p.write(&(p_cur->aBearerData[digitCount]), sizeof(uct)); + } + + startResponse; + appendPrintBuf("%suTeleserviceID=%d, bIsServicePresent=%d, uServicecategory=%d, \ + sAddress.digit_mode=%d, sAddress.number_mode=%d, sAddress.number_type=%d, ", + printBuf, p_cur->uTeleserviceID,p_cur->bIsServicePresent,p_cur->uServicecategory, + p_cur->sAddress.digit_mode, p_cur->sAddress.number_mode,p_cur->sAddress.number_type); + closeResponse; + + return 0; +} + +/** + * A write on the wakeup fd is done just to pop us out of select() + * We empty the buffer here and then ril_event will reset the timers on the + * way back down + */ +static void processWakeupCallback(int fd, short flags, void *param) { + char buff[16]; + int ret; + + ALOGV("processWakeupCallback"); + + /* empty our wakeup socket out */ + do { + ret = read(s_fdWakeupRead, &buff, sizeof(buff)); + } while (ret > 0 || (ret < 0 && errno == EINTR)); +} + +static void onCommandsSocketClosed() { + int ret; + RequestInfo *p_cur; + + /* mark pending requests as "cancelled" so we dont report responses */ + + ret = pthread_mutex_lock(&s_pendingRequestsMutex); + assert (ret == 0); + + p_cur = s_pendingRequests; + + for (p_cur = s_pendingRequests + ; p_cur != NULL + ; p_cur = p_cur->p_next + ) { + p_cur->cancelled = 1; + } + + ret = pthread_mutex_unlock(&s_pendingRequestsMutex); + assert (ret == 0); +} + +static void processCommandsCallback(int fd, short flags, void *param) { + RecordStream *p_rs; + void *p_record; + size_t recordlen; + int ret; + + assert(fd == s_fdCommand); + + p_rs = (RecordStream *)param; + + for (;;) { + /* loop until EAGAIN/EINTR, end of stream, or other error */ + ret = record_stream_get_next(p_rs, &p_record, &recordlen); + + if (ret == 0 && p_record == NULL) { + /* end-of-stream */ + break; + } else if (ret < 0) { + break; + } else if (ret == 0) { /* && p_record != NULL */ + processCommandBuffer(p_record, recordlen); + } + } + + if (ret == 0 || !(errno == EAGAIN || errno == EINTR)) { + /* fatal error or end-of-stream */ + if (ret != 0) { + ALOGE("error on reading command socket errno:%d\n", errno); + } else { + ALOGW("EOS. Closing command socket."); + } + + close(s_fdCommand); + s_fdCommand = -1; + + ril_event_del(&s_commands_event); + + record_stream_free(p_rs); + + /* start listening for new connections again */ + rilEventAddWakeup(&s_listen_event); + + onCommandsSocketClosed(); + } +} + + +static void onNewCommandConnect() { + // Inform we are connected and the ril version + int rilVer = s_callbacks.version; + RIL_onUnsolicitedResponse(RIL_UNSOL_RIL_CONNECTED, + &rilVer, sizeof(rilVer)); + + // implicit radio state changed + RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, + NULL, 0); + + // Send last NITZ time data, in case it was missed + if (s_lastNITZTimeData != NULL) { + sendResponseRaw(s_lastNITZTimeData, s_lastNITZTimeDataSize); + + free(s_lastNITZTimeData); + s_lastNITZTimeData = NULL; + } + + // Get version string + if (s_callbacks.getVersion != NULL) { + const char *version; + version = s_callbacks.getVersion(); + ALOGI("RIL Daemon version: %s\n", version); + + property_set(PROPERTY_RIL_IMPL, version); + } else { + ALOGI("RIL Daemon version: unavailable\n"); + property_set(PROPERTY_RIL_IMPL, "unavailable"); + } + +} + +static void listenCallback (int fd, short flags, void *param) { + int ret; + int err; + int is_phone_socket; + RecordStream *p_rs; + + struct sockaddr_un peeraddr; + socklen_t socklen = sizeof (peeraddr); + + struct ucred creds; + socklen_t szCreds = sizeof(creds); + + struct passwd *pwd = NULL; + + assert (s_fdCommand < 0); + assert (fd == s_fdListen); + + s_fdCommand = accept(s_fdListen, (sockaddr *) &peeraddr, &socklen); + + if (s_fdCommand < 0 ) { + ALOGE("Error on accept() errno:%d", errno); + /* start listening for new connections again */ + rilEventAddWakeup(&s_listen_event); + return; + } + + /* check the credential of the other side and only accept socket from + * phone process + */ + errno = 0; + is_phone_socket = 0; + + err = getsockopt(s_fdCommand, SOL_SOCKET, SO_PEERCRED, &creds, &szCreds); + + if (err == 0 && szCreds > 0) { + errno = 0; + pwd = getpwuid(creds.uid); + if (pwd != NULL) { + if (strcmp(pwd->pw_name, PHONE_PROCESS) == 0) { + is_phone_socket = 1; + } else { + ALOGE("RILD can't accept socket from process %s", pwd->pw_name); + } + } else { + ALOGE("Error on getpwuid() errno: %d", errno); + } + } else { + ALOGD("Error on getsockopt() errno: %d", errno); + } + + if ( !is_phone_socket ) { + ALOGE("RILD must accept socket from %s", PHONE_PROCESS); + + close(s_fdCommand); + s_fdCommand = -1; + + onCommandsSocketClosed(); + + /* start listening for new connections again */ + rilEventAddWakeup(&s_listen_event); + + return; + } + + ret = fcntl(s_fdCommand, F_SETFL, O_NONBLOCK); + + if (ret < 0) { + ALOGE ("Error setting O_NONBLOCK errno:%d", errno); + } + + ALOGI("libril: new connection"); + + p_rs = record_stream_new(s_fdCommand, MAX_COMMAND_BYTES); + + ril_event_set (&s_commands_event, s_fdCommand, 1, + processCommandsCallback, p_rs); + + rilEventAddWakeup (&s_commands_event); + + onNewCommandConnect(); +} + +static void freeDebugCallbackArgs(int number, char **args) { + for (int i = 0; i < number; i++) { + if (args[i] != NULL) { + free(args[i]); + } + } + free(args); +} + +static void debugCallback (int fd, short flags, void *param) { + int acceptFD, option; + struct sockaddr_un peeraddr; + socklen_t socklen = sizeof (peeraddr); + int data; + unsigned int qxdm_data[6]; + const char *deactData[1] = {"1"}; + char *actData[1]; + RIL_Dial dialData; + int hangupData[1] = {1}; + int number; + char **args; + + acceptFD = accept (fd, (sockaddr *) &peeraddr, &socklen); + + if (acceptFD < 0) { + ALOGE ("error accepting on debug port: %d\n", errno); + return; + } + + if (recv(acceptFD, &number, sizeof(int), 0) != sizeof(int)) { + ALOGE ("error reading on socket: number of Args: \n"); + return; + } + args = (char **) malloc(sizeof(char*) * number); + + for (int i = 0; i < number; i++) { + int len; + if (recv(acceptFD, &len, sizeof(int), 0) != sizeof(int)) { + ALOGE ("error reading on socket: Len of Args: \n"); + freeDebugCallbackArgs(i, args); + return; + } + // +1 for null-term + args[i] = (char *) malloc((sizeof(char) * len) + 1); + if (recv(acceptFD, args[i], sizeof(char) * len, 0) + != (int)sizeof(char) * len) { + ALOGE ("error reading on socket: Args[%d] \n", i); + freeDebugCallbackArgs(i, args); + return; + } + char * buf = args[i]; + buf[len] = 0; + } + + switch (atoi(args[0])) { + case 0: + ALOGI ("Connection on debug port: issuing reset."); + issueLocalRequest(RIL_REQUEST_RESET_RADIO, NULL, 0); + break; + case 1: + ALOGI ("Connection on debug port: issuing radio power off."); + data = 0; + issueLocalRequest(RIL_REQUEST_RADIO_POWER, &data, sizeof(int)); + // Close the socket + close(s_fdCommand); + s_fdCommand = -1; + break; + case 2: + ALOGI ("Debug port: issuing unsolicited voice network change."); + RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED, + NULL, 0); + break; + case 3: + ALOGI ("Debug port: QXDM log enable."); + qxdm_data[0] = 65536; // head.func_tag + qxdm_data[1] = 16; // head.len + qxdm_data[2] = 1; // mode: 1 for 'start logging' + qxdm_data[3] = 32; // log_file_size: 32megabytes + qxdm_data[4] = 0; // log_mask + qxdm_data[5] = 8; // log_max_fileindex + issueLocalRequest(RIL_REQUEST_OEM_HOOK_RAW, qxdm_data, + 6 * sizeof(int)); + break; + case 4: + ALOGI ("Debug port: QXDM log disable."); + qxdm_data[0] = 65536; + qxdm_data[1] = 16; + qxdm_data[2] = 0; // mode: 0 for 'stop logging' + qxdm_data[3] = 32; + qxdm_data[4] = 0; + qxdm_data[5] = 8; + issueLocalRequest(RIL_REQUEST_OEM_HOOK_RAW, qxdm_data, + 6 * sizeof(int)); + break; + case 5: + ALOGI("Debug port: Radio On"); + data = 1; + issueLocalRequest(RIL_REQUEST_RADIO_POWER, &data, sizeof(int)); + sleep(2); + // Set network selection automatic. + issueLocalRequest(RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, NULL, 0); + break; + case 6: + ALOGI("Debug port: Setup Data Call, Apn :%s\n", args[1]); + actData[0] = args[1]; + issueLocalRequest(RIL_REQUEST_SETUP_DATA_CALL, &actData, + sizeof(actData)); + break; + case 7: + ALOGI("Debug port: Deactivate Data Call"); + issueLocalRequest(RIL_REQUEST_DEACTIVATE_DATA_CALL, &deactData, + sizeof(deactData)); + break; + case 8: + ALOGI("Debug port: Dial Call"); + dialData.clir = 0; + dialData.address = args[1]; + issueLocalRequest(RIL_REQUEST_DIAL, &dialData, sizeof(dialData)); + break; + case 9: + ALOGI("Debug port: Answer Call"); + issueLocalRequest(RIL_REQUEST_ANSWER, NULL, 0); + break; + case 10: + ALOGI("Debug port: End Call"); + issueLocalRequest(RIL_REQUEST_HANGUP, &hangupData, + sizeof(hangupData)); + break; + default: + ALOGE ("Invalid request"); + break; + } + freeDebugCallbackArgs(number, args); + close(acceptFD); +} + + +static void userTimerCallback (int fd, short flags, void *param) { + UserCallbackInfo *p_info; + + p_info = (UserCallbackInfo *)param; + + p_info->p_callback(p_info->userParam); + + + // FIXME generalize this...there should be a cancel mechanism + if (s_last_wake_timeout_info != NULL && s_last_wake_timeout_info == p_info) { + s_last_wake_timeout_info = NULL; + } + + free(p_info); +} + + +static void * +eventLoop(void *param) { + int ret; + int filedes[2]; + + ril_event_init(); + + pthread_mutex_lock(&s_startupMutex); + + s_started = 1; + pthread_cond_broadcast(&s_startupCond); + + pthread_mutex_unlock(&s_startupMutex); + + ret = pipe(filedes); + + if (ret < 0) { + ALOGE("Error in pipe() errno:%d", errno); + return NULL; + } + + s_fdWakeupRead = filedes[0]; + s_fdWakeupWrite = filedes[1]; + + fcntl(s_fdWakeupRead, F_SETFL, O_NONBLOCK); + + ril_event_set (&s_wakeupfd_event, s_fdWakeupRead, true, + processWakeupCallback, NULL); + + rilEventAddWakeup (&s_wakeupfd_event); + + // Only returns on error + ril_event_loop(); + ALOGE ("error in event_loop_base errno:%d", errno); + // kill self to restart on error + kill(0, SIGKILL); + + return NULL; +} + +extern "C" void +RIL_startEventLoop(void) { + int ret; + pthread_attr_t attr; + + /* spin up eventLoop thread and wait for it to get started */ + s_started = 0; + pthread_mutex_lock(&s_startupMutex); + + pthread_attr_init (&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + ret = pthread_create(&s_tid_dispatch, &attr, eventLoop, NULL); + + while (s_started == 0) { + pthread_cond_wait(&s_startupCond, &s_startupMutex); + } + + pthread_mutex_unlock(&s_startupMutex); + + if (ret < 0) { + ALOGE("Failed to create dispatch thread errno:%d", errno); + return; + } +} + +// Used for testing purpose only. +extern "C" void RIL_setcallbacks (const RIL_RadioFunctions *callbacks) { + memcpy(&s_callbacks, callbacks, sizeof (RIL_RadioFunctions)); +} + +extern "C" void +RIL_register (const RIL_RadioFunctions *callbacks) { + int ret; + int flags; + + if (callbacks == NULL) { + ALOGE("RIL_register: RIL_RadioFunctions * null"); + return; + } + if (callbacks->version < RIL_VERSION_MIN) { + ALOGE("RIL_register: version %d is to old, min version is %d", + callbacks->version, RIL_VERSION_MIN); + return; + } + if (callbacks->version > RIL_VERSION) { + ALOGE("RIL_register: version %d is too new, max version is %d", + callbacks->version, RIL_VERSION); + return; + } + ALOGE("RIL_register: RIL version %d", callbacks->version); + + if (s_registerCalled > 0) { + ALOGE("RIL_register has been called more than once. " + "Subsequent call ignored"); + return; + } + + memcpy(&s_callbacks, callbacks, sizeof (RIL_RadioFunctions)); + + s_registerCalled = 1; + + // Little self-check + + for (int i = 0; i < (int)NUM_ELEMS(s_commands); i++) { + assert(i == s_commands[i].requestNumber); + } + + for (int i = 0; i < (int)NUM_ELEMS(s_unsolResponses); i++) { + assert(i + RIL_UNSOL_RESPONSE_BASE + == s_unsolResponses[i].requestNumber); + } + + // New rild impl calls RIL_startEventLoop() first + // old standalone impl wants it here. + + if (s_started == 0) { + RIL_startEventLoop(); + } + + // start listen socket + +#if 0 + ret = socket_local_server (SOCKET_NAME_RIL, + ANDROID_SOCKET_NAMESPACE_ABSTRACT, SOCK_STREAM); + + if (ret < 0) { + ALOGE("Unable to bind socket errno:%d", errno); + exit (-1); + } + s_fdListen = ret; + +#else + s_fdListen = android_get_control_socket(SOCKET_NAME_RIL); + if (s_fdListen < 0) { + ALOGE("Failed to get socket '" SOCKET_NAME_RIL "'"); + exit(-1); + } + + ret = listen(s_fdListen, 4); + + if (ret < 0) { + ALOGE("Failed to listen on control socket '%d': %s", + s_fdListen, strerror(errno)); + exit(-1); + } +#endif + + + /* note: non-persistent so we can accept only one connection at a time */ + ril_event_set (&s_listen_event, s_fdListen, false, + listenCallback, NULL); + + rilEventAddWakeup (&s_listen_event); + +#if 1 + // start debug interface socket + + s_fdDebug = android_get_control_socket(SOCKET_NAME_RIL_DEBUG); + if (s_fdDebug < 0) { + ALOGE("Failed to get socket '" SOCKET_NAME_RIL_DEBUG "' errno:%d", errno); + exit(-1); + } + + ret = listen(s_fdDebug, 4); + + if (ret < 0) { + ALOGE("Failed to listen on ril debug socket '%d': %s", + s_fdDebug, strerror(errno)); + exit(-1); + } + + ril_event_set (&s_debug_event, s_fdDebug, true, + debugCallback, NULL); + + rilEventAddWakeup (&s_debug_event); +#endif + +} + +static int +checkAndDequeueRequestInfo(struct RequestInfo *pRI) { + int ret = 0; + + if (pRI == NULL) { + return 0; + } + + pthread_mutex_lock(&s_pendingRequestsMutex); + + for(RequestInfo **ppCur = &s_pendingRequests + ; *ppCur != NULL + ; ppCur = &((*ppCur)->p_next) + ) { + if (pRI == *ppCur) { + ret = 1; + + *ppCur = (*ppCur)->p_next; + break; + } + } + + pthread_mutex_unlock(&s_pendingRequestsMutex); + + return ret; +} + + +extern "C" void +RIL_onRequestComplete(RIL_Token t, RIL_Errno e, void *response, size_t responselen) { + RequestInfo *pRI; + int ret; + size_t errorOffset; + + pRI = (RequestInfo *)t; + + if (!checkAndDequeueRequestInfo(pRI)) { + ALOGE ("RIL_onRequestComplete: invalid RIL_Token"); + return; + } + + if (pRI->local > 0) { + // Locally issued command...void only! + // response does not go back up the command socket + ALOGD("C[locl]< %s", requestToString(pRI->pCI->requestNumber)); + + goto done; + } + + appendPrintBuf("[%04d]< %s", + pRI->token, requestToString(pRI->pCI->requestNumber)); + + if (pRI->cancelled == 0) { + Parcel p; + + p.writeInt32 (RESPONSE_SOLICITED); + p.writeInt32 (pRI->token); + errorOffset = p.dataPosition(); + + p.writeInt32 (e); + + if (response != NULL) { + // there is a response payload, no matter success or not. + ret = pRI->pCI->responseFunction(p, response, responselen); + + /* if an error occurred, rewind and mark it */ + if (ret != 0) { + p.setDataPosition(errorOffset); + p.writeInt32 (ret); + } + } + + if (e != RIL_E_SUCCESS) { + appendPrintBuf("%s fails by %s", printBuf, failCauseToString(e)); + } + + if (s_fdCommand < 0) { + ALOGD ("RIL onRequestComplete: Command channel closed"); + } + sendResponse(p); + } + +done: + free(pRI); +} + + +static void +grabPartialWakeLock() { + acquire_wake_lock(PARTIAL_WAKE_LOCK, ANDROID_WAKE_LOCK_NAME); +} + +static void +releaseWakeLock() { + release_wake_lock(ANDROID_WAKE_LOCK_NAME); +} + +/** + * Timer callback to put us back to sleep before the default timeout + */ +static void +wakeTimeoutCallback (void *param) { + // We're using "param != NULL" as a cancellation mechanism + if (param == NULL) { + //ALOGD("wakeTimeout: releasing wake lock"); + + releaseWakeLock(); + } else { + //ALOGD("wakeTimeout: releasing wake lock CANCELLED"); + } +} + +static int +decodeVoiceRadioTechnology (RIL_RadioState radioState) { + switch (radioState) { + case RADIO_STATE_SIM_NOT_READY: + case RADIO_STATE_SIM_LOCKED_OR_ABSENT: + case RADIO_STATE_SIM_READY: + return RADIO_TECH_UMTS; + + case RADIO_STATE_RUIM_NOT_READY: + case RADIO_STATE_RUIM_READY: + case RADIO_STATE_RUIM_LOCKED_OR_ABSENT: + case RADIO_STATE_NV_NOT_READY: + case RADIO_STATE_NV_READY: + return RADIO_TECH_1xRTT; + + default: + ALOGD("decodeVoiceRadioTechnology: Invoked with incorrect RadioState"); + return -1; + } +} + +static int +decodeCdmaSubscriptionSource (RIL_RadioState radioState) { + switch (radioState) { + case RADIO_STATE_SIM_NOT_READY: + case RADIO_STATE_SIM_LOCKED_OR_ABSENT: + case RADIO_STATE_SIM_READY: + case RADIO_STATE_RUIM_NOT_READY: + case RADIO_STATE_RUIM_READY: + case RADIO_STATE_RUIM_LOCKED_OR_ABSENT: + return CDMA_SUBSCRIPTION_SOURCE_RUIM_SIM; + + case RADIO_STATE_NV_NOT_READY: + case RADIO_STATE_NV_READY: + return CDMA_SUBSCRIPTION_SOURCE_NV; + + default: + ALOGD("decodeCdmaSubscriptionSource: Invoked with incorrect RadioState"); + return -1; + } +} + +static int +decodeSimStatus (RIL_RadioState radioState) { + switch (radioState) { + case RADIO_STATE_SIM_NOT_READY: + case RADIO_STATE_RUIM_NOT_READY: + case RADIO_STATE_NV_NOT_READY: + case RADIO_STATE_NV_READY: + return -1; + case RADIO_STATE_SIM_LOCKED_OR_ABSENT: + case RADIO_STATE_SIM_READY: + case RADIO_STATE_RUIM_READY: + case RADIO_STATE_RUIM_LOCKED_OR_ABSENT: + return radioState; + default: + ALOGD("decodeSimStatus: Invoked with incorrect RadioState"); + return -1; + } +} + +static bool is3gpp2(int radioTech) { + switch (radioTech) { + case RADIO_TECH_IS95A: + case RADIO_TECH_IS95B: + case RADIO_TECH_1xRTT: + case RADIO_TECH_EVDO_0: + case RADIO_TECH_EVDO_A: + case RADIO_TECH_EVDO_B: + case RADIO_TECH_EHRPD: + return true; + default: + return false; + } +} + +/* If RIL sends SIM states or RUIM states, store the voice radio + * technology and subscription source information so that they can be + * returned when telephony framework requests them + */ +static RIL_RadioState +processRadioState(RIL_RadioState newRadioState) { + + if((newRadioState > RADIO_STATE_UNAVAILABLE) && (newRadioState < RADIO_STATE_ON)) { + int newVoiceRadioTech; + int newCdmaSubscriptionSource; + int newSimStatus; + + /* This is old RIL. Decode Subscription source and Voice Radio Technology + from Radio State and send change notifications if there has been a change */ + newVoiceRadioTech = decodeVoiceRadioTechnology(newRadioState); + if(newVoiceRadioTech != voiceRadioTech) { + voiceRadioTech = newVoiceRadioTech; + RIL_onUnsolicitedResponse (RIL_UNSOL_VOICE_RADIO_TECH_CHANGED, + &voiceRadioTech, sizeof(voiceRadioTech)); + } + if(is3gpp2(newVoiceRadioTech)) { + newCdmaSubscriptionSource = decodeCdmaSubscriptionSource(newRadioState); + if(newCdmaSubscriptionSource != cdmaSubscriptionSource) { + cdmaSubscriptionSource = newCdmaSubscriptionSource; + RIL_onUnsolicitedResponse (RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED, + &cdmaSubscriptionSource, sizeof(cdmaSubscriptionSource)); + } + } + newSimStatus = decodeSimStatus(newRadioState); + if(newSimStatus != simRuimStatus) { + simRuimStatus = newSimStatus; + RIL_onUnsolicitedResponse(RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, NULL, 0); + } + + /* Send RADIO_ON to telephony */ + newRadioState = RADIO_STATE_ON; + } + + return newRadioState; +} + +extern "C" +void RIL_onUnsolicitedResponse(int unsolResponse, void *data, + size_t datalen) +{ + int unsolResponseIndex; + int ret; + int64_t timeReceived = 0; + bool shouldScheduleTimeout = false; + RIL_RadioState newState; + + if (s_registerCalled == 0) { + // Ignore RIL_onUnsolicitedResponse before RIL_register + ALOGW("RIL_onUnsolicitedResponse called before RIL_register"); + return; + } + + unsolResponseIndex = unsolResponse - RIL_UNSOL_RESPONSE_BASE; + + if ((unsolResponseIndex < 0) + || (unsolResponseIndex >= (int32_t)NUM_ELEMS(s_unsolResponses))) { + ALOGE("unsupported unsolicited response code %d", unsolResponse); + return; + } + + // Grab a wake lock if needed for this reponse, + // as we exit we'll either release it immediately + // or set a timer to release it later. + switch (s_unsolResponses[unsolResponseIndex].wakeType) { + case WAKE_PARTIAL: + grabPartialWakeLock(); + shouldScheduleTimeout = true; + break; + + case DONT_WAKE: + default: + // No wake lock is grabed so don't set timeout + shouldScheduleTimeout = false; + break; + } + + // Mark the time this was received, doing this + // after grabing the wakelock incase getting + // the elapsedRealTime might cause us to goto + // sleep. + if (unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) { + timeReceived = elapsedRealtime(); + } + + appendPrintBuf("[UNSL]< %s", requestToString(unsolResponse)); + + Parcel p; + + p.writeInt32 (RESPONSE_UNSOLICITED); + p.writeInt32 (unsolResponse); + + ret = s_unsolResponses[unsolResponseIndex] + .responseFunction(p, data, datalen); + if (ret != 0) { + // Problem with the response. Don't continue; + goto error_exit; + } + + // some things get more payload + switch(unsolResponse) { + case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: + newState = processRadioState(s_callbacks.onStateRequest()); + p.writeInt32(newState); + appendPrintBuf("%s {%s}", printBuf, + radioStateToString(s_callbacks.onStateRequest())); + break; + + + case RIL_UNSOL_NITZ_TIME_RECEIVED: + // Store the time that this was received so the + // handler of this message can account for + // the time it takes to arrive and process. In + // particular the system has been known to sleep + // before this message can be processed. + p.writeInt64(timeReceived); + break; + } + + ret = sendResponse(p); + if (ret != 0 && unsolResponse == RIL_UNSOL_NITZ_TIME_RECEIVED) { + + // Unfortunately, NITZ time is not poll/update like everything + // else in the system. So, if the upstream client isn't connected, + // keep a copy of the last NITZ response (with receive time noted + // above) around so we can deliver it when it is connected + + if (s_lastNITZTimeData != NULL) { + free (s_lastNITZTimeData); + s_lastNITZTimeData = NULL; + } + + s_lastNITZTimeData = malloc(p.dataSize()); + s_lastNITZTimeDataSize = p.dataSize(); + memcpy(s_lastNITZTimeData, p.data(), p.dataSize()); + } + + // For now, we automatically go back to sleep after TIMEVAL_WAKE_TIMEOUT + // FIXME The java code should handshake here to release wake lock + + if (shouldScheduleTimeout) { + // Cancel the previous request + if (s_last_wake_timeout_info != NULL) { + s_last_wake_timeout_info->userParam = (void *)1; + } + + s_last_wake_timeout_info + = internalRequestTimedCallback(wakeTimeoutCallback, NULL, + &TIMEVAL_WAKE_TIMEOUT); + } + + // Normal exit + return; + +error_exit: + if (shouldScheduleTimeout) { + releaseWakeLock(); + } +} + +/** FIXME generalize this if you track UserCAllbackInfo, clear it + when the callback occurs +*/ +static UserCallbackInfo * +internalRequestTimedCallback (RIL_TimedCallback callback, void *param, + const struct timeval *relativeTime) +{ + struct timeval myRelativeTime; + UserCallbackInfo *p_info; + + p_info = (UserCallbackInfo *) malloc (sizeof(UserCallbackInfo)); + + p_info->p_callback = callback; + p_info->userParam = param; + + if (relativeTime == NULL) { + /* treat null parameter as a 0 relative time */ + memset (&myRelativeTime, 0, sizeof(myRelativeTime)); + } else { + /* FIXME I think event_add's tv param is really const anyway */ + memcpy (&myRelativeTime, relativeTime, sizeof(myRelativeTime)); + } + + ril_event_set(&(p_info->event), -1, false, userTimerCallback, p_info); + + ril_timer_add(&(p_info->event), &myRelativeTime); + + triggerEvLoop(); + return p_info; +} + + +extern "C" void +RIL_requestTimedCallback (RIL_TimedCallback callback, void *param, + const struct timeval *relativeTime) { + internalRequestTimedCallback (callback, param, relativeTime); +} + +const char * +failCauseToString(RIL_Errno e) { + switch(e) { + case RIL_E_SUCCESS: return "E_SUCCESS"; + case RIL_E_RADIO_NOT_AVAILABLE: return "E_RAIDO_NOT_AVAILABLE"; + case RIL_E_GENERIC_FAILURE: return "E_GENERIC_FAILURE"; + case RIL_E_PASSWORD_INCORRECT: return "E_PASSWORD_INCORRECT"; + case RIL_E_SIM_PIN2: return "E_SIM_PIN2"; + case RIL_E_SIM_PUK2: return "E_SIM_PUK2"; + case RIL_E_REQUEST_NOT_SUPPORTED: return "E_REQUEST_NOT_SUPPORTED"; + case RIL_E_CANCELLED: return "E_CANCELLED"; + case RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL: return "E_OP_NOT_ALLOWED_DURING_VOICE_CALL"; + case RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW: return "E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW"; + case RIL_E_SMS_SEND_FAIL_RETRY: return "E_SMS_SEND_FAIL_RETRY"; + case RIL_E_SIM_ABSENT:return "E_SIM_ABSENT"; + case RIL_E_ILLEGAL_SIM_OR_ME:return "E_ILLEGAL_SIM_OR_ME"; +#ifdef FEATURE_MULTIMODE_ANDROID + case RIL_E_SUBSCRIPTION_NOT_AVAILABLE:return "E_SUBSCRIPTION_NOT_AVAILABLE"; + case RIL_E_MODE_NOT_SUPPORTED:return "E_MODE_NOT_SUPPORTED"; +#endif + default: return ""; + } +} + +const char * +radioStateToString(RIL_RadioState s) { + switch(s) { + case RADIO_STATE_OFF: return "RADIO_OFF"; + case RADIO_STATE_UNAVAILABLE: return "RADIO_UNAVAILABLE"; + case RADIO_STATE_SIM_NOT_READY: return "RADIO_SIM_NOT_READY"; + case RADIO_STATE_SIM_LOCKED_OR_ABSENT: return "RADIO_SIM_LOCKED_OR_ABSENT"; + case RADIO_STATE_SIM_READY: return "RADIO_SIM_READY"; + case RADIO_STATE_RUIM_NOT_READY:return"RADIO_RUIM_NOT_READY"; + case RADIO_STATE_RUIM_READY:return"RADIO_RUIM_READY"; + case RADIO_STATE_RUIM_LOCKED_OR_ABSENT:return"RADIO_RUIM_LOCKED_OR_ABSENT"; + case RADIO_STATE_NV_NOT_READY:return"RADIO_NV_NOT_READY"; + case RADIO_STATE_NV_READY:return"RADIO_NV_READY"; + case RADIO_STATE_ON:return"RADIO_ON"; + default: return ""; + } +} + +const char * +callStateToString(RIL_CallState s) { + switch(s) { + case RIL_CALL_ACTIVE : return "ACTIVE"; + case RIL_CALL_HOLDING: return "HOLDING"; + case RIL_CALL_DIALING: return "DIALING"; + case RIL_CALL_ALERTING: return "ALERTING"; + case RIL_CALL_INCOMING: return "INCOMING"; + case RIL_CALL_WAITING: return "WAITING"; + default: return ""; + } +} + +const char * +requestToString(int request) { +/* + cat libs/telephony/ril_commands.h \ + | egrep "^ *{RIL_" \ + | sed -re 's/\{RIL_([^,]+),[^,]+,([^}]+).+/case RIL_\1: return "\1";/' + + + cat libs/telephony/ril_unsol_commands.h \ + | egrep "^ *{RIL_" \ + | sed -re 's/\{RIL_([^,]+),([^}]+).+/case RIL_\1: return "\1";/' + +*/ + switch(request) { + case RIL_REQUEST_GET_SIM_STATUS: return "GET_SIM_STATUS"; + case RIL_REQUEST_ENTER_SIM_PIN: return "ENTER_SIM_PIN"; + case RIL_REQUEST_ENTER_SIM_PUK: return "ENTER_SIM_PUK"; + case RIL_REQUEST_ENTER_SIM_PIN2: return "ENTER_SIM_PIN2"; + case RIL_REQUEST_ENTER_SIM_PUK2: return "ENTER_SIM_PUK2"; + case RIL_REQUEST_CHANGE_SIM_PIN: return "CHANGE_SIM_PIN"; + case RIL_REQUEST_CHANGE_SIM_PIN2: return "CHANGE_SIM_PIN2"; + case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: return "ENTER_NETWORK_DEPERSONALIZATION"; + case RIL_REQUEST_GET_CURRENT_CALLS: return "GET_CURRENT_CALLS"; + case RIL_REQUEST_DIAL: return "DIAL"; + case RIL_REQUEST_GET_IMSI: return "GET_IMSI"; + case RIL_REQUEST_HANGUP: return "HANGUP"; + case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: return "HANGUP_WAITING_OR_BACKGROUND"; + case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: return "HANGUP_FOREGROUND_RESUME_BACKGROUND"; + case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: return "SWITCH_WAITING_OR_HOLDING_AND_ACTIVE"; + case RIL_REQUEST_CONFERENCE: return "CONFERENCE"; + case RIL_REQUEST_UDUB: return "UDUB"; + case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: return "LAST_CALL_FAIL_CAUSE"; + case RIL_REQUEST_SIGNAL_STRENGTH: return "SIGNAL_STRENGTH"; + case RIL_REQUEST_VOICE_REGISTRATION_STATE: return "VOICE_REGISTRATION_STATE"; + case RIL_REQUEST_DATA_REGISTRATION_STATE: return "DATA_REGISTRATION_STATE"; + case RIL_REQUEST_OPERATOR: return "OPERATOR"; + case RIL_REQUEST_RADIO_POWER: return "RADIO_POWER"; + case RIL_REQUEST_DTMF: return "DTMF"; + case RIL_REQUEST_SEND_SMS: return "SEND_SMS"; + case RIL_REQUEST_SEND_SMS_EXPECT_MORE: return "SEND_SMS_EXPECT_MORE"; + case RIL_REQUEST_SETUP_DATA_CALL: return "SETUP_DATA_CALL"; + case RIL_REQUEST_SIM_IO: return "SIM_IO"; + case RIL_REQUEST_SEND_USSD: return "SEND_USSD"; + case RIL_REQUEST_CANCEL_USSD: return "CANCEL_USSD"; + case RIL_REQUEST_GET_CLIR: return "GET_CLIR"; + case RIL_REQUEST_SET_CLIR: return "SET_CLIR"; + case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: return "QUERY_CALL_FORWARD_STATUS"; + case RIL_REQUEST_SET_CALL_FORWARD: return "SET_CALL_FORWARD"; + case RIL_REQUEST_QUERY_CALL_WAITING: return "QUERY_CALL_WAITING"; + case RIL_REQUEST_SET_CALL_WAITING: return "SET_CALL_WAITING"; + case RIL_REQUEST_SMS_ACKNOWLEDGE: return "SMS_ACKNOWLEDGE"; + case RIL_REQUEST_GET_IMEI: return "GET_IMEI"; + case RIL_REQUEST_GET_IMEISV: return "GET_IMEISV"; + case RIL_REQUEST_ANSWER: return "ANSWER"; + case RIL_REQUEST_DEACTIVATE_DATA_CALL: return "DEACTIVATE_DATA_CALL"; + case RIL_REQUEST_QUERY_FACILITY_LOCK: return "QUERY_FACILITY_LOCK"; + case RIL_REQUEST_SET_FACILITY_LOCK: return "SET_FACILITY_LOCK"; + case RIL_REQUEST_CHANGE_BARRING_PASSWORD: return "CHANGE_BARRING_PASSWORD"; + case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: return "QUERY_NETWORK_SELECTION_MODE"; + case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: return "SET_NETWORK_SELECTION_AUTOMATIC"; + case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: return "SET_NETWORK_SELECTION_MANUAL"; + case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : return "QUERY_AVAILABLE_NETWORKS "; + case RIL_REQUEST_DTMF_START: return "DTMF_START"; + case RIL_REQUEST_DTMF_STOP: return "DTMF_STOP"; + case RIL_REQUEST_BASEBAND_VERSION: return "BASEBAND_VERSION"; + case RIL_REQUEST_SEPARATE_CONNECTION: return "SEPARATE_CONNECTION"; + case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: return "SET_PREFERRED_NETWORK_TYPE"; + case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: return "GET_PREFERRED_NETWORK_TYPE"; + case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: return "GET_NEIGHBORING_CELL_IDS"; + case RIL_REQUEST_SET_MUTE: return "SET_MUTE"; + case RIL_REQUEST_GET_MUTE: return "GET_MUTE"; + case RIL_REQUEST_QUERY_CLIP: return "QUERY_CLIP"; + case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "LAST_DATA_CALL_FAIL_CAUSE"; + case RIL_REQUEST_DATA_CALL_LIST: return "DATA_CALL_LIST"; + case RIL_REQUEST_RESET_RADIO: return "RESET_RADIO"; + case RIL_REQUEST_OEM_HOOK_RAW: return "OEM_HOOK_RAW"; + case RIL_REQUEST_OEM_HOOK_STRINGS: return "OEM_HOOK_STRINGS"; + case RIL_REQUEST_SET_BAND_MODE: return "SET_BAND_MODE"; + case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "QUERY_AVAILABLE_BAND_MODE"; + case RIL_REQUEST_STK_GET_PROFILE: return "STK_GET_PROFILE"; + case RIL_REQUEST_STK_SET_PROFILE: return "STK_SET_PROFILE"; + case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: return "STK_SEND_ENVELOPE_COMMAND"; + case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: return "STK_SEND_TERMINAL_RESPONSE"; + case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: return "STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM"; + case RIL_REQUEST_SCREEN_STATE: return "SCREEN_STATE"; + case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "EXPLICIT_CALL_TRANSFER"; + case RIL_REQUEST_SET_LOCATION_UPDATES: return "SET_LOCATION_UPDATES"; + case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE:return"CDMA_SET_SUBSCRIPTION_SOURCE"; + case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE:return"CDMA_SET_ROAMING_PREFERENCE"; + case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE:return"CDMA_QUERY_ROAMING_PREFERENCE"; + case RIL_REQUEST_SET_TTY_MODE:return"SET_TTY_MODE"; + case RIL_REQUEST_QUERY_TTY_MODE:return"QUERY_TTY_MODE"; + case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE"; + case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE"; + case RIL_REQUEST_CDMA_FLASH:return"CDMA_FLASH"; + case RIL_REQUEST_CDMA_BURST_DTMF:return"CDMA_BURST_DTMF"; + case RIL_REQUEST_CDMA_SEND_SMS:return"CDMA_SEND_SMS"; + case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE:return"CDMA_SMS_ACKNOWLEDGE"; + case RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG:return"GSM_GET_BROADCAST_SMS_CONFIG"; + case RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG:return"GSM_SET_BROADCAST_SMS_CONFIG"; + case RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG:return "CDMA_GET_BROADCAST_SMS_CONFIG"; + case RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG:return "CDMA_SET_BROADCAST_SMS_CONFIG"; + case RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION:return "CDMA_SMS_BROADCAST_ACTIVATION"; + case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: return"CDMA_VALIDATE_AND_WRITE_AKEY"; + case RIL_REQUEST_CDMA_SUBSCRIPTION: return"CDMA_SUBSCRIPTION"; + case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "CDMA_WRITE_SMS_TO_RUIM"; + case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "CDMA_DELETE_SMS_ON_RUIM"; + case RIL_REQUEST_DEVICE_IDENTITY: return "DEVICE_IDENTITY"; + case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: return "EXIT_EMERGENCY_CALLBACK_MODE"; + case RIL_REQUEST_GET_SMSC_ADDRESS: return "GET_SMSC_ADDRESS"; + case RIL_REQUEST_SET_SMSC_ADDRESS: return "SET_SMSC_ADDRESS"; + case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: return "REPORT_SMS_MEMORY_STATUS"; + case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: return "REPORT_STK_SERVICE_IS_RUNNING"; + case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: return "CDMA_GET_SUBSCRIPTION_SOURCE"; + case RIL_REQUEST_ISIM_AUTHENTICATION: return "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_VOICE_RADIO_TECH: return "VOICE_RADIO_TECH"; + 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_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"; + case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: return "UNSOL_VOICE_RADIO_TECH_CHANGED"; + default: return ""; + } +} + +} /* namespace android */ diff --git a/libril/ril_commands.h b/libril/ril_commands.h new file mode 100644 index 0000000..96f06ba --- /dev/null +++ b/libril/ril_commands.h @@ -0,0 +1,125 @@ +/* //device/libs/telephony/ril_commands.h +** +** Copyright 2006, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + {0, NULL, NULL}, //none + {RIL_REQUEST_GET_SIM_STATUS, dispatchVoid, responseSimStatus}, + {RIL_REQUEST_ENTER_SIM_PIN, dispatchStrings, responseInts}, + {RIL_REQUEST_ENTER_SIM_PUK, dispatchStrings, responseInts}, + {RIL_REQUEST_ENTER_SIM_PIN2, dispatchStrings, responseInts}, + {RIL_REQUEST_ENTER_SIM_PUK2, dispatchStrings, responseInts}, + {RIL_REQUEST_CHANGE_SIM_PIN, dispatchStrings, responseInts}, + {RIL_REQUEST_CHANGE_SIM_PIN2, dispatchStrings, responseInts}, + {RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION, dispatchStrings, responseInts}, + {RIL_REQUEST_GET_CURRENT_CALLS, dispatchVoid, responseCallList}, + {RIL_REQUEST_DIAL, dispatchDial, responseVoid}, + {RIL_REQUEST_GET_IMSI, dispatchStrings, responseString}, + {RIL_REQUEST_HANGUP, dispatchInts, responseVoid}, + {RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND, dispatchVoid, responseVoid}, + {RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND, dispatchVoid, responseVoid}, + {RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE, dispatchVoid, responseVoid}, + {RIL_REQUEST_CONFERENCE, dispatchVoid, responseVoid}, + {RIL_REQUEST_UDUB, dispatchVoid, responseVoid}, + {RIL_REQUEST_LAST_CALL_FAIL_CAUSE, dispatchVoid, responseInts}, + {RIL_REQUEST_SIGNAL_STRENGTH, dispatchVoid, responseRilSignalStrength}, + {RIL_REQUEST_VOICE_REGISTRATION_STATE, dispatchVoid, responseStrings}, + {RIL_REQUEST_DATA_REGISTRATION_STATE, dispatchVoid, responseStrings}, + {RIL_REQUEST_OPERATOR, dispatchVoid, responseStrings}, + {RIL_REQUEST_RADIO_POWER, dispatchInts, responseVoid}, + {RIL_REQUEST_DTMF, dispatchString, responseVoid}, + {RIL_REQUEST_SEND_SMS, dispatchStrings, responseSMS}, + {RIL_REQUEST_SEND_SMS_EXPECT_MORE, dispatchStrings, responseSMS}, + {RIL_REQUEST_SETUP_DATA_CALL, dispatchDataCall, responseSetupDataCall}, + {RIL_REQUEST_SIM_IO, dispatchSIM_IO, responseSIM_IO}, + {RIL_REQUEST_SEND_USSD, dispatchString, responseVoid}, + {RIL_REQUEST_CANCEL_USSD, dispatchVoid, responseVoid}, + {RIL_REQUEST_GET_CLIR, dispatchVoid, responseInts}, + {RIL_REQUEST_SET_CLIR, dispatchInts, responseVoid}, + {RIL_REQUEST_QUERY_CALL_FORWARD_STATUS, dispatchCallForward, responseCallForwards}, + {RIL_REQUEST_SET_CALL_FORWARD, dispatchCallForward, responseVoid}, + {RIL_REQUEST_QUERY_CALL_WAITING, dispatchInts, responseInts}, + {RIL_REQUEST_SET_CALL_WAITING, dispatchInts, responseVoid}, + {RIL_REQUEST_SMS_ACKNOWLEDGE, dispatchInts, responseVoid}, + {RIL_REQUEST_GET_IMEI, dispatchVoid, responseString}, + {RIL_REQUEST_GET_IMEISV, dispatchVoid, responseString}, + {RIL_REQUEST_ANSWER,dispatchVoid, responseVoid}, + {RIL_REQUEST_DEACTIVATE_DATA_CALL, dispatchStrings, responseVoid}, + {RIL_REQUEST_QUERY_FACILITY_LOCK, dispatchStrings, responseInts}, + {RIL_REQUEST_SET_FACILITY_LOCK, dispatchStrings, responseInts}, + {RIL_REQUEST_CHANGE_BARRING_PASSWORD, dispatchStrings, responseVoid}, + {RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE, dispatchVoid, responseInts}, + {RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, dispatchVoid, responseVoid}, + {RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL, dispatchString, responseVoid}, + {RIL_REQUEST_QUERY_AVAILABLE_NETWORKS , dispatchVoid, responseStringsNetworks}, + {RIL_REQUEST_DTMF_START, dispatchString, responseVoid}, + {RIL_REQUEST_DTMF_STOP, dispatchVoid, responseVoid}, + {RIL_REQUEST_BASEBAND_VERSION, dispatchVoid, responseString}, + {RIL_REQUEST_SEPARATE_CONNECTION, dispatchInts, responseVoid}, + {RIL_REQUEST_SET_MUTE, dispatchInts, responseVoid}, + {RIL_REQUEST_GET_MUTE, dispatchVoid, responseInts}, + {RIL_REQUEST_QUERY_CLIP, dispatchVoid, responseInts}, + {RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE, dispatchVoid, responseInts}, + {RIL_REQUEST_DATA_CALL_LIST, dispatchVoid, responseDataCallList}, + {RIL_REQUEST_RESET_RADIO, dispatchVoid, responseVoid}, + {RIL_REQUEST_OEM_HOOK_RAW, dispatchRaw, responseRaw}, + {RIL_REQUEST_OEM_HOOK_STRINGS, dispatchStrings, responseStrings}, + {RIL_REQUEST_SCREEN_STATE, dispatchInts, responseVoid}, + {RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, dispatchInts, responseVoid}, + {RIL_REQUEST_WRITE_SMS_TO_SIM, dispatchSmsWrite, responseInts}, + {RIL_REQUEST_DELETE_SMS_ON_SIM, dispatchInts, responseVoid}, + {RIL_REQUEST_SET_BAND_MODE, dispatchInts, responseVoid}, + {RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE, dispatchVoid, responseInts}, + {RIL_REQUEST_STK_GET_PROFILE, dispatchVoid, responseString}, + {RIL_REQUEST_STK_SET_PROFILE, dispatchString, responseVoid}, + {RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND, dispatchString, responseString}, + {RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE, dispatchString, responseVoid}, + {RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM, dispatchInts, responseVoid}, + {RIL_REQUEST_EXPLICIT_CALL_TRANSFER, dispatchVoid, responseVoid}, + {RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, dispatchInts, responseVoid}, + {RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE, dispatchVoid, responseInts}, + {RIL_REQUEST_GET_NEIGHBORING_CELL_IDS, dispatchVoid, responseCellList}, + {RIL_REQUEST_SET_LOCATION_UPDATES, dispatchInts, responseVoid}, + {RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, dispatchInts, responseVoid}, + {RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, dispatchInts, responseVoid}, + {RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE, dispatchVoid, responseInts}, + {RIL_REQUEST_SET_TTY_MODE, dispatchInts, responseVoid}, + {RIL_REQUEST_QUERY_TTY_MODE, dispatchVoid, responseInts}, + {RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE, dispatchInts, responseVoid}, + {RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE, dispatchVoid, responseInts}, + {RIL_REQUEST_CDMA_FLASH, dispatchString, responseVoid}, + {RIL_REQUEST_CDMA_BURST_DTMF, dispatchStrings, responseVoid}, + {RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY, dispatchString, responseVoid}, + {RIL_REQUEST_CDMA_SEND_SMS, dispatchCdmaSms, responseSMS}, + {RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE, dispatchCdmaSmsAck, responseVoid}, + {RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG, dispatchVoid, responseGsmBrSmsCnf}, + {RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG, dispatchGsmBrSmsCnf, responseVoid}, + {RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION, dispatchInts, responseVoid}, + {RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG, dispatchVoid, responseCdmaBrSmsCnf}, + {RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG, dispatchCdmaBrSmsCnf, responseVoid}, + {RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION, dispatchInts, responseVoid}, + {RIL_REQUEST_CDMA_SUBSCRIPTION, dispatchVoid, responseStrings}, + {RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM, dispatchRilCdmaSmsWriteArgs, responseInts}, + {RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, dispatchInts, responseVoid}, + {RIL_REQUEST_DEVICE_IDENTITY, dispatchVoid, responseStrings}, + {RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE, dispatchVoid, responseVoid}, + {RIL_REQUEST_GET_SMSC_ADDRESS, dispatchVoid, responseString}, + {RIL_REQUEST_SET_SMSC_ADDRESS, dispatchString, responseVoid}, + {RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, dispatchInts, responseVoid}, + {RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING, dispatchVoid, responseVoid}, + {RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE, dispatchCdmaSubscriptionSource, responseInts}, + {RIL_REQUEST_ISIM_AUTHENTICATION, dispatchString, responseString}, + {RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU, dispatchStrings, responseVoid}, + {RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS, dispatchString, responseSIM_IO}, + {RIL_REQUEST_VOICE_RADIO_TECH, dispatchVoiceRadioTech, responseInts}, diff --git a/libril/ril_event.cpp b/libril/ril_event.cpp new file mode 100644 index 0000000..93511e9 --- /dev/null +++ b/libril/ril_event.cpp @@ -0,0 +1,385 @@ +/* //device/libs/telephony/ril_event.cpp +** +** Copyright 2008, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +#define LOG_TAG "RILC" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +static pthread_mutex_t listMutex; +#define MUTEX_ACQUIRE() pthread_mutex_lock(&listMutex) +#define MUTEX_RELEASE() pthread_mutex_unlock(&listMutex) +#define MUTEX_INIT() pthread_mutex_init(&listMutex, NULL) +#define MUTEX_DESTROY() pthread_mutex_destroy(&listMutex) + +#ifndef timeradd +#define timeradd(tvp, uvp, vvp) \ + do { \ + (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \ + (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \ + if ((vvp)->tv_usec >= 1000000) { \ + (vvp)->tv_sec++; \ + (vvp)->tv_usec -= 1000000; \ + } \ + } while (0) +#endif + +#ifndef timercmp +#define timercmp(a, b, op) \ + ((a)->tv_sec == (b)->tv_sec \ + ? (a)->tv_usec op (b)->tv_usec \ + : (a)->tv_sec op (b)->tv_sec) +#endif + +#ifndef timersub +#define timersub(a, b, res) \ + do { \ + (res)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ + (res)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ + if ((res)->tv_usec < 0) { \ + (res)->tv_usec += 1000000; \ + (res)->tv_sec -= 1; \ + } \ + } while(0); +#endif + +static fd_set readFds; +static int nfds = 0; + +static struct ril_event * watch_table[MAX_FD_EVENTS]; +static struct ril_event timer_list; +static struct ril_event pending_list; + +#define DEBUG 0 + +#if DEBUG +#define dlog(x...) ALOGD( x ) +static void dump_event(struct ril_event * ev) +{ + dlog("~~~~ Event %x ~~~~", (unsigned int)ev); + dlog(" next = %x", (unsigned int)ev->next); + dlog(" prev = %x", (unsigned int)ev->prev); + dlog(" fd = %d", ev->fd); + dlog(" pers = %d", ev->persist); + dlog(" timeout = %ds + %dus", (int)ev->timeout.tv_sec, (int)ev->timeout.tv_usec); + dlog(" func = %x", (unsigned int)ev->func); + dlog(" param = %x", (unsigned int)ev->param); + dlog("~~~~~~~~~~~~~~~~~~"); +} +#else +#define dlog(x...) do {} while(0) +#define dump_event(x) do {} while(0) +#endif + +static void getNow(struct timeval * tv) +{ +#ifdef HAVE_POSIX_CLOCKS + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + tv->tv_sec = ts.tv_sec; + tv->tv_usec = ts.tv_nsec/1000; +#else + gettimeofday(tv, NULL); +#endif +} + +static void init_list(struct ril_event * list) +{ + memset(list, 0, sizeof(struct ril_event)); + list->next = list; + list->prev = list; + list->fd = -1; +} + +static void addToList(struct ril_event * ev, struct ril_event * list) +{ + ev->next = list; + ev->prev = list->prev; + ev->prev->next = ev; + list->prev = ev; + dump_event(ev); +} + +static void removeFromList(struct ril_event * ev) +{ + dlog("~~~~ Removing event ~~~~"); + dump_event(ev); + + ev->next->prev = ev->prev; + ev->prev->next = ev->next; + ev->next = NULL; + ev->prev = NULL; +} + + +static void removeWatch(struct ril_event * ev, int index) +{ + watch_table[index] = NULL; + ev->index = -1; + + FD_CLR(ev->fd, &readFds); + + if (ev->fd+1 == nfds) { + int n = 0; + + for (int i = 0; i < MAX_FD_EVENTS; i++) { + struct ril_event * rev = watch_table[i]; + + if ((rev != NULL) && (rev->fd > n)) { + n = rev->fd; + } + } + nfds = n + 1; + dlog("~~~~ nfds = %d ~~~~", nfds); + } +} + +static void processTimeouts() +{ + dlog("~~~~ +processTimeouts ~~~~"); + MUTEX_ACQUIRE(); + struct timeval now; + struct ril_event * tev = timer_list.next; + struct ril_event * next; + + getNow(&now); + // walk list, see if now >= ev->timeout for any events + + dlog("~~~~ Looking for timers <= %ds + %dus ~~~~", (int)now.tv_sec, (int)now.tv_usec); + while ((tev != &timer_list) && (timercmp(&now, &tev->timeout, >))) { + // Timer expired + dlog("~~~~ firing timer ~~~~"); + next = tev->next; + removeFromList(tev); + addToList(tev, &pending_list); + tev = next; + } + MUTEX_RELEASE(); + dlog("~~~~ -processTimeouts ~~~~"); +} + +static void processReadReadies(fd_set * rfds, int n) +{ + dlog("~~~~ +processReadReadies (%d) ~~~~", n); + MUTEX_ACQUIRE(); + + for (int i = 0; (i < MAX_FD_EVENTS) && (n > 0); i++) { + struct ril_event * rev = watch_table[i]; + if (rev != NULL && FD_ISSET(rev->fd, rfds)) { + addToList(rev, &pending_list); + if (rev->persist == false) { + removeWatch(rev, i); + } + n--; + } + } + + MUTEX_RELEASE(); + dlog("~~~~ -processReadReadies (%d) ~~~~", n); +} + +static void firePending() +{ + dlog("~~~~ +firePending ~~~~"); + struct ril_event * ev = pending_list.next; + while (ev != &pending_list) { + struct ril_event * next = ev->next; + removeFromList(ev); + ev->func(ev->fd, 0, ev->param); + ev = next; + } + dlog("~~~~ -firePending ~~~~"); +} + +static int calcNextTimeout(struct timeval * tv) +{ + struct ril_event * tev = timer_list.next; + struct timeval now; + + getNow(&now); + + // Sorted list, so calc based on first node + if (tev == &timer_list) { + // no pending timers + return -1; + } + + dlog("~~~~ now = %ds + %dus ~~~~", (int)now.tv_sec, (int)now.tv_usec); + dlog("~~~~ next = %ds + %dus ~~~~", + (int)tev->timeout.tv_sec, (int)tev->timeout.tv_usec); + if (timercmp(&tev->timeout, &now, >)) { + timersub(&tev->timeout, &now, tv); + } else { + // timer already expired. + tv->tv_sec = tv->tv_usec = 0; + } + return 0; +} + +// Initialize internal data structs +void ril_event_init() +{ + MUTEX_INIT(); + + FD_ZERO(&readFds); + init_list(&timer_list); + init_list(&pending_list); + memset(watch_table, 0, sizeof(watch_table)); +} + +// Initialize an event +void ril_event_set(struct ril_event * ev, int fd, bool persist, ril_event_cb func, void * param) +{ + dlog("~~~~ ril_event_set %x ~~~~", (unsigned int)ev); + memset(ev, 0, sizeof(struct ril_event)); + ev->fd = fd; + ev->index = -1; + ev->persist = persist; + ev->func = func; + ev->param = param; + fcntl(fd, F_SETFL, O_NONBLOCK); +} + +// Add event to watch list +void ril_event_add(struct ril_event * ev) +{ + dlog("~~~~ +ril_event_add ~~~~"); + MUTEX_ACQUIRE(); + for (int i = 0; i < MAX_FD_EVENTS; i++) { + if (watch_table[i] == NULL) { + watch_table[i] = ev; + ev->index = i; + dlog("~~~~ added at %d ~~~~", i); + dump_event(ev); + FD_SET(ev->fd, &readFds); + if (ev->fd >= nfds) nfds = ev->fd+1; + dlog("~~~~ nfds = %d ~~~~", nfds); + break; + } + } + MUTEX_RELEASE(); + dlog("~~~~ -ril_event_add ~~~~"); +} + +// Add timer event +void ril_timer_add(struct ril_event * ev, struct timeval * tv) +{ + dlog("~~~~ +ril_timer_add ~~~~"); + MUTEX_ACQUIRE(); + + struct ril_event * list; + if (tv != NULL) { + // add to timer list + list = timer_list.next; + ev->fd = -1; // make sure fd is invalid + + struct timeval now; + getNow(&now); + timeradd(&now, tv, &ev->timeout); + + // keep list sorted + while (timercmp(&list->timeout, &ev->timeout, < ) + && (list != &timer_list)) { + list = list->next; + } + // list now points to the first event older than ev + addToList(ev, list); + } + + MUTEX_RELEASE(); + dlog("~~~~ -ril_timer_add ~~~~"); +} + +// Remove event from watch or timer list +void ril_event_del(struct ril_event * ev) +{ + dlog("~~~~ +ril_event_del ~~~~"); + MUTEX_ACQUIRE(); + + if (ev->index < 0 || ev->index >= MAX_FD_EVENTS) { + MUTEX_RELEASE(); + return; + } + + removeWatch(ev, ev->index); + + MUTEX_RELEASE(); + dlog("~~~~ -ril_event_del ~~~~"); +} + +#if DEBUG +static void printReadies(fd_set * rfds) +{ + for (int i = 0; (i < MAX_FD_EVENTS); i++) { + struct ril_event * rev = watch_table[i]; + if (rev != NULL && FD_ISSET(rev->fd, rfds)) { + dlog("DON: fd=%d is ready", rev->fd); + } + } +} +#else +#define printReadies(rfds) do {} while(0) +#endif + +void ril_event_loop() +{ + int n; + fd_set rfds; + struct timeval tv; + struct timeval * ptv; + + + for (;;) { + + // make local copy of read fd_set + memcpy(&rfds, &readFds, sizeof(fd_set)); + if (-1 == calcNextTimeout(&tv)) { + // no pending timers; block indefinitely + dlog("~~~~ no timers; blocking indefinitely ~~~~"); + ptv = NULL; + } else { + dlog("~~~~ blocking for %ds + %dus ~~~~", (int)tv.tv_sec, (int)tv.tv_usec); + ptv = &tv; + } + printReadies(&rfds); + n = select(nfds, &rfds, NULL, NULL, ptv); + printReadies(&rfds); + dlog("~~~~ %d events fired ~~~~", n); + if (n < 0) { + if (errno == EINTR) continue; + + ALOGE("ril_event: select error (%d)", errno); + // bail? + return; + } + + // Check for timeouts + processTimeouts(); + // Check for read-ready + processReadReadies(&rfds, n); + // Fire away + firePending(); + } +} diff --git a/libril/ril_event.h b/libril/ril_event.h new file mode 100644 index 0000000..7ba231b --- /dev/null +++ b/libril/ril_event.h @@ -0,0 +1,52 @@ +/* //device/libs/telephony/ril_event.h +** +** Copyright 2008, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +// Max number of fd's we watch at any one time. Increase if necessary. +#define MAX_FD_EVENTS 8 + +typedef void (*ril_event_cb)(int fd, short events, void *userdata); + +struct ril_event { + struct ril_event *next; + struct ril_event *prev; + + int fd; + int index; + bool persist; + struct timeval timeout; + ril_event_cb func; + void *param; +}; + +// Initialize internal data structs +void ril_event_init(); + +// Initialize an event +void ril_event_set(struct ril_event * ev, int fd, bool persist, ril_event_cb func, void * param); + +// Add event to watch list +void ril_event_add(struct ril_event * ev); + +// Add timer event +void ril_timer_add(struct ril_event * ev, struct timeval * tv); + +// Remove event from watch list +void ril_event_del(struct ril_event * ev); + +// Event loop +void ril_event_loop(); + diff --git a/libril/ril_unsol_commands.h b/libril/ril_unsol_commands.h new file mode 100644 index 0000000..7e3f8f0 --- /dev/null +++ b/libril/ril_unsol_commands.h @@ -0,0 +1,52 @@ +/* //device/libs/telephony/ril_unsol_commands.h +** +** Copyright 2006, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + {RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, responseVoid, WAKE_PARTIAL}, + {RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED, responseVoid, WAKE_PARTIAL}, + {RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED, responseVoid, WAKE_PARTIAL}, + {RIL_UNSOL_RESPONSE_NEW_SMS, responseString, WAKE_PARTIAL}, + {RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT, responseString, WAKE_PARTIAL}, + {RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM, responseInts, WAKE_PARTIAL}, + {RIL_UNSOL_ON_USSD, responseStrings, WAKE_PARTIAL}, + {RIL_UNSOL_ON_USSD_REQUEST, responseVoid, DONT_WAKE}, + {RIL_UNSOL_NITZ_TIME_RECEIVED, responseString, WAKE_PARTIAL}, + {RIL_UNSOL_SIGNAL_STRENGTH, responseRilSignalStrength, DONT_WAKE}, + {RIL_UNSOL_DATA_CALL_LIST_CHANGED, responseDataCallList, WAKE_PARTIAL}, + {RIL_UNSOL_SUPP_SVC_NOTIFICATION, responseSsn, WAKE_PARTIAL}, + {RIL_UNSOL_STK_SESSION_END, responseVoid, WAKE_PARTIAL}, + {RIL_UNSOL_STK_PROACTIVE_COMMAND, responseString, WAKE_PARTIAL}, + {RIL_UNSOL_STK_EVENT_NOTIFY, responseString, WAKE_PARTIAL}, + {RIL_UNSOL_STK_CALL_SETUP, responseInts, WAKE_PARTIAL}, + {RIL_UNSOL_SIM_SMS_STORAGE_FULL, responseVoid, WAKE_PARTIAL}, + {RIL_UNSOL_SIM_REFRESH, responseSimRefresh, WAKE_PARTIAL}, + {RIL_UNSOL_CALL_RING, responseCallRing, WAKE_PARTIAL}, + {RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, responseVoid, WAKE_PARTIAL}, + {RIL_UNSOL_RESPONSE_CDMA_NEW_SMS, responseCdmaSms, WAKE_PARTIAL}, + {RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS, responseRaw, WAKE_PARTIAL}, + {RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL, responseVoid, WAKE_PARTIAL}, + {RIL_UNSOL_RESTRICTED_STATE_CHANGED, responseInts, WAKE_PARTIAL}, + {RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE, responseVoid, WAKE_PARTIAL}, + {RIL_UNSOL_CDMA_CALL_WAITING, responseCdmaCallWaiting, WAKE_PARTIAL}, + {RIL_UNSOL_CDMA_OTA_PROVISION_STATUS, responseInts, WAKE_PARTIAL}, + {RIL_UNSOL_CDMA_INFO_REC, responseCdmaInformationRecords, WAKE_PARTIAL}, + {RIL_UNSOL_OEM_HOOK_RAW, responseRaw, WAKE_PARTIAL}, + {RIL_UNSOL_RINGBACK_TONE, responseInts, WAKE_PARTIAL}, + {RIL_UNSOL_RESEND_INCALL_MUTE, responseVoid, WAKE_PARTIAL}, + {RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED, responseInts, WAKE_PARTIAL}, + {RIL_UNSOL_CDMA_PRL_CHANGED, responseInts, WAKE_PARTIAL}, + {RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE, responseVoid, WAKE_PARTIAL}, + {RIL_UNSOL_RIL_CONNECTED, responseInts, WAKE_PARTIAL}, + {RIL_UNSOL_VOICE_RADIO_TECH_CHANGED, responseInts, WAKE_PARTIAL}, diff --git a/proprietary-files.txt b/proprietary-files.txt index 19c9032..e382d7a 100644 --- a/proprietary-files.txt +++ b/proprietary-files.txt @@ -1,10 +1,8 @@ system/bin/gpsd -system/bin/rild system/lib/hw/gps.exynos4.so system/lib/hw/vendor-camera.exynos4.so system/lib/hw/sensors.smdk4x12.so system/lib/libakm.so -system/lib/libril.so system/lib/libsec-ril.so system/usr/idc/sec_touchscreen.idc system/usr/keylayout/sec_touchkey.kl -- cgit v1.1