[DO NOT MERGE] klte-common: libril: Add Samsung changes

* Changes in ril.cpp based off of hardware/samsung/libril

[haggertk]: Forward port to ril-caf on lineage-15.1 by
            remapping all the samsung unsol responses
            to NULL with the old response in a comment,
            and all the samsung requests to NULL with
            the old request mapping in a comment.
            This is safe because nothing in AOSP knows
            about any of Samsung's requests/responses

***** SIGNAL STRENGTH HACKS NOT PORTED YET *****

Change-Id: I59bad9925d141e6cefbc24d4eefdc0c79017852a
This commit is contained in:
Paul Keith 2017-10-19 02:26:41 +02:00 committed by Kevin F. Haggerty
parent bcc9a6c694
commit 1bafc74e01
5 changed files with 266 additions and 10 deletions

View File

@ -150,7 +150,7 @@ typedef enum {
RIL_E_ILLEGAL_SIM_OR_ME = 15, /* network selection failed due to
illegal SIM or ME */
RIL_E_MISSING_RESOURCE = 16, /* no logical channel available */
RIL_E_NO_SUCH_ELEMENT = 17, /* application not found on SIM */
RIL_E_NO_SUCH_ELEMENT = 17, /* application not found on SIM */
RIL_E_DIAL_MODIFIED_TO_USSD = 18, /* DIAL request modified to USSD */
RIL_E_DIAL_MODIFIED_TO_SS = 19, /* DIAL request modified to SS */
RIL_E_DIAL_MODIFIED_TO_DIAL = 20, /* DIAL request modified to DIAL with different
@ -358,7 +358,7 @@ typedef enum {
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 */
PREF_NET_TYPE_LTE_WCDMA = 12, /* LTE/WCDMA */
PREF_NET_TYPE_LTE_WCDMA = 12, /* LTE/WCDMA */
PREF_NET_TYPE_TD_SCDMA_ONLY = 13, /* TD-SCDMA only */
PREF_NET_TYPE_TD_SCDMA_WCDMA = 14, /* TD-SCDMA and WCDMA */
PREF_NET_TYPE_TD_SCDMA_LTE = 15, /* TD-SCDMA and LTE */
@ -733,7 +733,7 @@ typedef struct {
const char * mcc;
const char * mnc;
RIL_CarrierMatchType match_type; /* Specify match type for the carrier.
* If its RIL_MATCH_ALL, match_data is null;
* If it's RIL_MATCH_ALL, match_data is null;
* otherwise, match_data is the value for the match type.
*/
const char * match_data;
@ -1111,6 +1111,13 @@ typedef struct
int pin1_replaced; /* applicable to USIM, CSIM & ISIM */
RIL_PinState pin1;
RIL_PinState pin2;
/* Samsung SIM PIN/Unlock fields */
int pin1_num_retries;
int puk1_num_retries;
int pin2_num_retries;
int puk2_num_retries;
int perso_unblock_retries;
/* End of Samsung SIM PIN/Unlock fields */
} RIL_AppStatus;
/* Deprecated, use RIL_CardStatus_v6 */
@ -6320,6 +6327,44 @@ typedef struct {
#define RIL_RESPONSE_ACKNOWLEDGEMENT 800
/**********************************************************
* SAMSUNG REQUESTS
**********************************************************/
#define SAMSUNG_REQUEST_BASE 10000
#define RIL_REQUEST_DIAL_EMERGENCY_CALL 10001
#define RIL_REQUEST_CALL_DEFLECTION 10002
#define RIL_REQUEST_MODIFY_CALL_INITIATE 10003
#define RIL_REQUEST_MODIFY_CALL_CONFIRM 10004
#define RIL_REQUEST_SET_VOICE_DOMAIN_PREF 10005
#define RIL_REQUEST_SAFE_MODE 10006
#define RIL_REQUEST_SET_TRANSMIT_POWER 10007
#define RIL_REQUEST_GET_CELL_BROADCAST_CONFIG 10008
#define RIL_REQUEST_GET_PHONEBOOK_STORAGE_INFO 10009
#define RIL_REQUEST_GET_PHONEBOOK_ENTRY 10010
#define RIL_REQUEST_ACCESS_PHONEBOOK_ENTRY 10011
#define RIL_REQUEST_USIM_PB_CAPA 10012
#define RIL_REQUEST_LOCK_INFO 10013
#define RIL_REQUEST_STK_SIM_INIT_EVENT 10014
#define RIL_REQUEST_SET_PREFERRED_NETWORK_LIST 10015
#define RIL_REQUEST_GET_PREFERRED_NETWORK_LIST 10016
#define RIL_REQUEST_CHANGE_SIM_PERSO 10017
#define RIL_REQUEST_ENTER_SIM_PERSO 10018
#define RIL_REQUEST_SEND_ENCODED_USSD 10019
#define RIL_REQUEST_CDMA_SEND_SMS_EXPECT_MORE 10020
#define RIL_REQUEST_HANGUP_VT 10021
#define RIL_REQUEST_HOLD 10022
#define RIL_REQUEST_SET_SIM_POWER 10023
#define RIL_REQUEST_UICC_GBA_AUTHENTICATE_BOOTSTRAP 10025
#define RIL_REQUEST_UICC_GBA_AUTHENTICATE_NAF 10026
#define RIL_REQUEST_GET_INCOMING_COMMUNICATION_BARRING 10027
#define RIL_REQUEST_SET_INCOMING_COMMUNICATION_BARRING 10028
#define RIL_REQUEST_QUERY_CNAP 10029
#define RIL_REQUEST_SET_TRANSFER_CALL 10030
#define RIL_REQUEST_GET_DISABLE_2G 10031
#define RIL_REQUEST_SET_DISABLE_2G 10032
#define RIL_REQUEST_REFRESH_NITZ_TIME 10033
/***********************************************************************/
@ -6988,6 +7033,43 @@ typedef struct {
*/
#define RIL_UNSOL_KEEPALIVE_STATUS 1050
/**********************************************************
* SAMSUNG UNSOLS
**********************************************************/
#define SAMSUNG_UNSOL_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_DEVICE_READY_NOTI 11008
#define RIL_UNSOL_GPS_NOTI 11009
#define RIL_UNSOL_AM 11010
#define RIL_UNSOL_SAP 11013
#define RIL_UNSOL_UART 11020
#define RIL_UNSOL_SIM_PB_READY 11021
#define RIL_UNSOL_VE 11024
#define RIL_UNSOL_FACTORY_AM 11026
#define RIL_UNSOL_IMS_REGISTRATION_STATE_CHANGED 11027
#define RIL_UNSOL_MODIFY_CALL 11028
#define RIL_UNSOL_CS_FALLBACK 11030
#define RIL_UNSOL_VOICE_SYSTEM_ID 11032
#define RIL_UNSOL_IMS_RETRYOVER 11034
#define RIL_UNSOL_PB_INIT_COMPLETE 11035
#define RIL_UNSOL_HYSTERESIS_DCN 11037
#define RIL_UNSOL_CP_POSITION 11038
#define RIL_UNSOL_HOME_NETWORK_NOTI 11043
#define RIL_UNSOL_STK_CALL_STATUS 11054
#define RIL_UNSOL_MODEM_CAP 11056
#define RIL_UNSOL_SIM_SWAP_STATE_CHANGED 11057
#define RUL_UNSOL_SIM_COUNT_MISMATCHED 11058
#define RIL_UNSOL_DUN 11060
#define RIL_UNSOL_IMS_PREFERENCE_CHANGED 11061
#define RIL_UNSOL_SIM_APPLICATION_REFRESH 11062
#define RIL_UNSOL_UICC_APPLICATION_STATUS 11063
#define RIL_UNSOL_VOICE_RADIO_BEARER_HO_STATUS 11064
#define RIL_UNSOL_CLM_NOTI 11065
#define RIL_UNSOL_SIM_ICCID_NOTI 11066
/***********************************************************************/

View File

@ -1,6 +1,6 @@
# Copyright 2006 The Android Open Source Project
ifneq ($(BOARD_PROVIDES_LIBRIL),true)
ifeq ($(BOARD_PROVIDES_LIBRIL),true)
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

View File

@ -191,6 +191,14 @@ static UnsolResponseInfo s_unsolResponses[] = {
#include "ril_unsol_commands.h"
};
static CommandInfo s_commands_v[] = {
#include "ril_commands_vendor.h"
};
static UnsolResponseInfo s_unsolResponses_v[] = {
#include "ril_unsol_commands_vendor.h"
};
char * RIL_getServiceName() {
return ril_service_name;
}
@ -237,9 +245,15 @@ addRequestToList(int serial, int slotId, int request) {
}
pRI->token = serial;
pRI->pCI = &(s_commands[request]);
pRI->socket_id = socket_id;
/* Hack to include Samsung requests */
if (request > SAMSUNG_REQUEST_BASE) {
pRI->pCI = &(s_commands_v[request - SAMSUNG_REQUEST_BASE]);
} else {
pRI->pCI = &(s_commands[request]);
}
ret = pthread_mutex_lock(pendingRequestsMutexHook);
assert (ret == 0);
@ -448,11 +462,21 @@ RIL_register (const RIL_RadioFunctions *callbacks) {
assert(i == s_commands[i].requestNumber);
}
for (int i = 0; i < (int)NUM_ELEMS(s_commands_v); i++) {
assert(i + SAMSUNG_REQUEST_BASE
== s_commands_v[i].requestNumber);
}
for (int i = 0; i < (int)NUM_ELEMS(s_unsolResponses); i++) {
assert(i + RIL_UNSOL_RESPONSE_BASE
== s_unsolResponses[i].requestNumber);
}
for (int i = 0; i < (int)NUM_ELEMS(s_unsolResponses_v); i++) {
assert(i + SAMSUNG_UNSOL_BASE
== s_unsolResponses_v[i].requestNumber);
}
radio::registerService(&s_callbacks, s_commands);
RLOGI("RILHIDL called registerService");
@ -728,6 +752,8 @@ void RIL_onUnsolicitedResponse(int unsolResponse, const void *data,
int ret;
bool shouldScheduleTimeout = false;
RIL_SOCKET_ID soc_id = RIL_SOCKET_1;
UnsolResponseInfo *pRI = NULL;
int32_t pRI_elements;
#if defined(ANDROID_MULTI_SIM)
soc_id = socket_id;
@ -741,9 +767,24 @@ void RIL_onUnsolicitedResponse(int unsolResponse, const void *data,
}
unsolResponseIndex = unsolResponse - RIL_UNSOL_RESPONSE_BASE;
pRI = s_unsolResponses;
if ((unsolResponseIndex < 0)
|| (unsolResponseIndex >= (int32_t)NUM_ELEMS(s_unsolResponses))) {
/* Hack to include Samsung responses */
if (unsolResponse > SAMSUNG_UNSOL_BASE) {
unsolResponseIndex = unsolResponse - SAMSUNG_UNSOL_BASE;
pRI = s_unsolResponses_v;
}
pRI_elements = pRI == s_unsolResponses
? (int32_t)NUM_ELEMS(s_unsolResponses) : (int32_t)NUM_ELEMS(s_unsolResponses_v);
if (unsolResponseIndex >= 0 && unsolResponseIndex < pRI_elements) {
pRI = &pRI[unsolResponseIndex];
} else {
pRI = NULL;
}
if (pRI == NULL || pRI->responseFunction == NULL) {
RLOGE("unsupported unsolicited response code %d", unsolResponse);
return;
}
@ -751,7 +792,7 @@ void RIL_onUnsolicitedResponse(int unsolResponse, const void *data,
// 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) {
switch (pRI->wakeType) {
case WAKE_PARTIAL:
grabPartialWakeLock();
shouldScheduleTimeout = true;
@ -768,7 +809,7 @@ void RIL_onUnsolicitedResponse(int unsolResponse, const void *data,
int responseType;
if (s_callbacks.version >= 13
&& s_unsolResponses[unsolResponseIndex].wakeType == WAKE_PARTIAL) {
&& pRI->wakeType == WAKE_PARTIAL) {
responseType = RESPONSE_UNSOLICITED_ACK_EXP;
} else {
responseType = RESPONSE_UNSOLICITED;
@ -778,7 +819,7 @@ void RIL_onUnsolicitedResponse(int unsolResponse, const void *data,
int rwlockRet = pthread_rwlock_rdlock(radioServiceRwlockPtr);
assert(rwlockRet == 0);
ret = s_unsolResponses[unsolResponseIndex].responseFunction(
ret = pRI->responseFunction(
(int) soc_id, responseType, 0, RIL_E_SUCCESS, const_cast<void*>(data),
datalen);

View File

@ -0,0 +1,50 @@
/* //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.
*/
{SAMSUNG_REQUEST_BASE, NULL}, // 10000
{RIL_REQUEST_DIAL_EMERGENCY_CALL, /* dispatchDial */ NULL}, // 10001
{RIL_REQUEST_CALL_DEFLECTION, /* dispatchVoid */ NULL}, // 10002
{RIL_REQUEST_MODIFY_CALL_INITIATE, /* dispatchVoid */ NULL}, // 10003
{RIL_REQUEST_MODIFY_CALL_CONFIRM, /* dispatchVoid */ NULL}, // 10004
{RIL_REQUEST_SET_VOICE_DOMAIN_PREF, /* dispatchVoid */ NULL}, // 10005
{RIL_REQUEST_SAFE_MODE, /* dispatchVoid */ NULL}, // 10006
{RIL_REQUEST_SET_TRANSMIT_POWER, /* dispatchVoid */ NULL}, // 10007
{RIL_REQUEST_GET_CELL_BROADCAST_CONFIG, /* dispatchVoid */ NULL}, // 10008
{RIL_REQUEST_GET_PHONEBOOK_STORAGE_INFO, /* dispatchVoid */ NULL}, // 10009
{RIL_REQUEST_GET_PHONEBOOK_ENTRY, /* dispatchVoid */ NULL}, // 10010
{RIL_REQUEST_ACCESS_PHONEBOOK_ENTRY, /* dispatchVoid */ NULL}, // 10011
{RIL_REQUEST_USIM_PB_CAPA, /* dispatchVoid */ NULL}, // 10012
{RIL_REQUEST_LOCK_INFO, /* dispatchVoid */ NULL}, // 10013
{RIL_REQUEST_STK_SIM_INIT_EVENT, /* dispatchVoid */ NULL}, // 10014
{RIL_REQUEST_SET_PREFERRED_NETWORK_LIST, /* dispatchVoid */ NULL}, // 10015
{RIL_REQUEST_GET_PREFERRED_NETWORK_LIST, /* dispatchVoid */ NULL}, // 10016
{RIL_REQUEST_CHANGE_SIM_PERSO, /* dispatchVoid */ NULL}, // 10017
{RIL_REQUEST_ENTER_SIM_PERSO, /* dispatchVoid */ NULL}, // 10018
{RIL_REQUEST_SEND_ENCODED_USSD, /* dispatchVoid */ NULL}, // 10019
{RIL_REQUEST_CDMA_SEND_SMS_EXPECT_MORE, /* dispatchVoid */ NULL}, // 10020
{RIL_REQUEST_HANGUP_VT, /* dispatchVoid */ NULL}, // 10021
{RIL_REQUEST_HOLD, /* dispatchVoid */ NULL}, // 10022
{RIL_REQUEST_SET_SIM_POWER, /* dispatchVoid */ NULL}, // 10023
{10024, NULL}, // 10024
{RIL_REQUEST_UICC_GBA_AUTHENTICATE_BOOTSTRAP, /* dispatchVoid */ NULL}, // 10025
{RIL_REQUEST_UICC_GBA_AUTHENTICATE_NAF, /* dispatchVoid */ NULL}, // 10026
{RIL_REQUEST_GET_INCOMING_COMMUNICATION_BARRING, /* dispatchVoid */ NULL}, // 10027
{RIL_REQUEST_SET_INCOMING_COMMUNICATION_BARRING, /* dispatchVoid */ NULL}, // 10028
{RIL_REQUEST_QUERY_CNAP, /* dispatchVoid */ NULL}, // 10029
{RIL_REQUEST_SET_TRANSFER_CALL, /* dispatchVoid */ NULL}, // 10030
{RIL_REQUEST_GET_DISABLE_2G, /* dispatchVoid */ NULL}, // 10031
{RIL_REQUEST_SET_DISABLE_2G, /* dispatchVoid */ NULL}, // 10032
{RIL_REQUEST_REFRESH_NITZ_TIME, /* dispatchVoid */ NULL}, // 10033

View File

@ -0,0 +1,83 @@
/* //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.
*/
{SAMSUNG_UNSOL_BASE, /* responseVoid */ NULL, WAKE_PARTIAL}, // 11000, actually UNSOL_RESPONSE_NEW_CB_MSG
{RIL_UNSOL_RELEASE_COMPLETE_MESSAGE, /* responseVoid */ NULL, WAKE_PARTIAL}, // 11001
{RIL_UNSOL_STK_SEND_SMS_RESULT, /* responseInts */ NULL, WAKE_PARTIAL}, // 11002
{RIL_UNSOL_STK_CALL_CONTROL_RESULT, /* responseString */ NULL, WAKE_PARTIAL}, // 11003
{11004, NULL, WAKE_PARTIAL}, // 11004
{11005, NULL, WAKE_PARTIAL}, // 11005
{11006, NULL, WAKE_PARTIAL}, // 11006
{11007, NULL, WAKE_PARTIAL}, // 11007
{RIL_UNSOL_DEVICE_READY_NOTI, /* responseVoid */ NULL, WAKE_PARTIAL}, // 11008
{RIL_UNSOL_GPS_NOTI, /* responseVoid */ NULL, WAKE_PARTIAL}, // 11009
{RIL_UNSOL_AM, /* responseString */ NULL, WAKE_PARTIAL}, // 11010
{11011, NULL, WAKE_PARTIAL}, // 11011
{11012, NULL, WAKE_PARTIAL}, // 11012
{RIL_UNSOL_SAP, /* responseRaw */ NULL, WAKE_PARTIAL}, // 11013
{11014, NULL, WAKE_PARTIAL}, // 11014
{11015, NULL, WAKE_PARTIAL}, // 11015
{11016, NULL, WAKE_PARTIAL}, // 11016
{11017, NULL, WAKE_PARTIAL}, // 11017
{11018, NULL, WAKE_PARTIAL}, // 11018
{11019, NULL, WAKE_PARTIAL}, // 11019
{RIL_UNSOL_UART, /* responseRaw */ NULL, WAKE_PARTIAL}, // 11020
{RIL_UNSOL_SIM_PB_READY, /* responseVoid */ NULL, WAKE_PARTIAL}, // 11021
{11022, NULL, WAKE_PARTIAL}, // 11022
{11023, NULL, WAKE_PARTIAL}, // 11023
{RIL_UNSOL_VE, /* responseRaw */ NULL, WAKE_PARTIAL}, // 11024
{11025, NULL, WAKE_PARTIAL},
{RIL_UNSOL_FACTORY_AM, /* responseVoid */ NULL, WAKE_PARTIAL}, // 11026
{RIL_UNSOL_IMS_REGISTRATION_STATE_CHANGED, /* responseInts */ NULL, WAKE_PARTIAL}, // 11027
{RIL_UNSOL_MODIFY_CALL, /* responseVoid */ NULL, WAKE_PARTIAL}, // 11028
{11029, NULL, WAKE_PARTIAL}, // 11029
{RIL_UNSOL_CS_FALLBACK, /* responseInts */ NULL, WAKE_PARTIAL}, // 11030
{11031, NULL, WAKE_PARTIAL}, // 11031
{RIL_UNSOL_VOICE_SYSTEM_ID, /* responseInts */ NULL, WAKE_PARTIAL}, // 11032
{11033, NULL, WAKE_PARTIAL}, // 11033
{RIL_UNSOL_IMS_RETRYOVER, /* responseVoid */ NULL, WAKE_PARTIAL}, // 11034
{RIL_UNSOL_PB_INIT_COMPLETE, /* responseVoid */ NULL, WAKE_PARTIAL}, // 11035
{11036, NULL, WAKE_PARTIAL}, // 11036
{RIL_UNSOL_HYSTERESIS_DCN, /* responseVoid */ NULL, WAKE_PARTIAL}, // 11037
{RIL_UNSOL_CP_POSITION, /* responseVoid */ NULL, WAKE_PARTIAL}, // 11038
{11039, NULL, WAKE_PARTIAL}, // 11039
{11040, NULL, WAKE_PARTIAL}, // 11040
{11041, NULL, WAKE_PARTIAL}, // 11041
{11042, NULL, WAKE_PARTIAL}, // 11042
{RIL_UNSOL_HOME_NETWORK_NOTI, /* responseVoid */ NULL, WAKE_PARTIAL}, // 11043
{11044, NULL, WAKE_PARTIAL}, // 11044
{11045, NULL, WAKE_PARTIAL}, // 11045
{11046, NULL, WAKE_PARTIAL}, // 11046
{11047, NULL, WAKE_PARTIAL}, // 11047
{11048, NULL, WAKE_PARTIAL}, // 11048
{11049, NULL, WAKE_PARTIAL}, // 11049
{11050, NULL, WAKE_PARTIAL}, // 11050
{11051, NULL, WAKE_PARTIAL}, // 11051
{11052, NULL, WAKE_PARTIAL}, // 11052
{11053, NULL, WAKE_PARTIAL}, // 11053
{RIL_UNSOL_STK_CALL_STATUS, /* responseInts */ NULL, WAKE_PARTIAL}, // 11054
{11055, NULL, WAKE_PARTIAL}, // 11055
{RIL_UNSOL_MODEM_CAP, /* responseRaw */ NULL, WAKE_PARTIAL}, // 11056
{RIL_UNSOL_SIM_SWAP_STATE_CHANGED, /* responseInts */ NULL, WAKE_PARTIAL}, // 11057
{RUL_UNSOL_SIM_COUNT_MISMATCHED, /* responseInts */ NULL, WAKE_PARTIAL}, // 11058
{11059, NULL, WAKE_PARTIAL}, // 11059
{RIL_UNSOL_DUN, /* responseStrings */ NULL, WAKE_PARTIAL}, // 11060
{RIL_UNSOL_IMS_PREFERENCE_CHANGED, /* responseInts */ NULL, WAKE_PARTIAL}, // 11061
{RIL_UNSOL_SIM_APPLICATION_REFRESH, /* responseInts */ NULL, WAKE_PARTIAL}, // 11062
{RIL_UNSOL_UICC_APPLICATION_STATUS, /* responseVoid */ NULL, WAKE_PARTIAL}, // 11063
{RIL_UNSOL_VOICE_RADIO_BEARER_HO_STATUS, /* responseInts */ NULL, WAKE_PARTIAL}, // 11064
{RIL_UNSOL_CLM_NOTI, /* responseVoid */ NULL, WAKE_PARTIAL}, // 11065
{RIL_UNSOL_SIM_ICCID_NOTI, /* responseString */ NULL, WAKE_PARTIAL}, // 11066