OSDN Git Service

Merge "Fix the RIL-to-HIDL conversion for Cell Lat and Long"
[android-x86/hardware-ril.git] / libril / ril_service.cpp
index 0087d5b..443225a 100644 (file)
 
 #define LOG_TAG "RILC"
 
-#include <android/hardware/radio/1.0/IRadio.h>
+#include <android/hardware/radio/1.1/IRadio.h>
+#include <android/hardware/radio/1.1/IRadioResponse.h>
+#include <android/hardware/radio/1.1/IRadioIndication.h>
+#include <android/hardware/radio/1.1/types.h>
+
 #include <android/hardware/radio/deprecated/1.0/IOemHook.h>
 
 #include <hwbinder/IPCThreadState.h>
@@ -36,6 +40,8 @@ using ::android::hardware::Return;
 using ::android::hardware::hidl_string;
 using ::android::hardware::hidl_vec;
 using ::android::hardware::hidl_array;
+using ::android::hardware::radio::V1_1::NetworkScanRequest;
+using ::android::hardware::radio::V1_1::KeepaliveRequest;
 using ::android::hardware::Void;
 using android::CommandInfo;
 using android::RequestInfo;
@@ -56,12 +62,14 @@ struct OemHookImpl;
 sp<RadioImpl> radioService[SIM_COUNT];
 sp<OemHookImpl> oemHookService[SIM_COUNT];
 // counter used for synchronization. It is incremented every time response callbacks are updated.
-volatile int32_t mCounter[SIM_COUNT];
+volatile int32_t mCounterRadio[SIM_COUNT];
+volatile int32_t mCounterOemHook[SIM_COUNT];
 #else
 sp<RadioImpl> radioService[1];
 sp<OemHookImpl> oemHookService[1];
 // counter used for synchronization. It is incremented every time response callbacks are updated.
-volatile int32_t mCounter[1];
+volatile int32_t mCounterRadio[1];
+volatile int32_t mCounterOemHook[1];
 #endif
 
 static pthread_rwlock_t radioServiceRwlock = PTHREAD_RWLOCK_INITIALIZER;
@@ -94,7 +102,7 @@ void convertRilDataCallListToHal(void *response, size_t responseLen,
 
 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records);
 
-struct RadioImpl : public IRadio {
+struct RadioImpl : public ::android::hardware::radio::V1_1::IRadio {
     int32_t mSlotId;
     sp<IRadioResponse> mRadioResponse;
     sp<IRadioIndication> mRadioIndication;
@@ -228,6 +236,10 @@ struct RadioImpl : public IRadio {
 
     Return<void> getAvailableNetworks(int32_t serial);
 
+    Return<void> startNetworkScan(int32_t serial, const NetworkScanRequest& request);
+
+    Return<void> stopNetworkScan(int32_t serial);
+
     Return<void> startDtmf(int32_t serial,
             const ::android::hardware::hidl_string& s);
 
@@ -363,7 +375,7 @@ struct RadioImpl : public IRadio {
     Return<void> iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message);
 
     Return<void> iccOpenLogicalChannel(int32_t serial,
-            const ::android::hardware::hidl_string& aid);
+            const ::android::hardware::hidl_string& aid, int32_t p2);
 
     Return<void> iccCloseLogicalChannel(int32_t serial, int32_t channelId);
 
@@ -416,10 +428,19 @@ struct RadioImpl : public IRadio {
 
     Return<void> setIndicationFilter(int32_t serial, int32_t indicationFilter);
 
+    Return<void> startKeepalive(int32_t serial, const KeepaliveRequest& keepalive);
+
+    Return<void> stopKeepalive(int32_t serial, int32_t sessionHandle);
+
     Return<void> setSimCardPower(int32_t serial, bool powerUp);
+    Return<void> setSimCardPower_1_1(int32_t serial,
+            const ::android::hardware::radio::V1_1::CardPowerState state);
 
     Return<void> responseAcknowledgement();
 
+    Return<void> setCarrierInfoForImsiEncryption(int32_t serial,
+            const ::android::hardware::radio::V1_1::ImsiEncryptionInfo& message);
+
     void checkReturnStatus(Return<void>& ret);
 };
 
@@ -446,8 +467,8 @@ void memsetAndFreeStrings(int numPointers, ...) {
         char *ptr = va_arg(ap, char *);
         if (ptr) {
 #ifdef MEMSET_FREED
-            // TODO: Should pass in the maximum length of the string
-            memsetString(ptr);
+#define MAX_STRING_LENGTH 4096
+            memset(ptr, 0, strnlen(ptr, MAX_STRING_LENGTH));
 #endif
             free(ptr);
         }
@@ -477,7 +498,7 @@ bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI)
         sendErrorResponse(pRI, RIL_E_NO_MEMORY);
         return false;
     }
-    strncpy(*dest, src, len + 1);
+    strncpy(*dest, src.c_str(), len + 1);
     return true;
 }
 
@@ -533,7 +554,7 @@ bool dispatchStrings(int serial, int slotId, int request, int countStrings, ...)
     va_start(ap, countStrings);
     for (int i = 0; i < countStrings; i++) {
         const char* str = va_arg(ap, const char *);
-        if (!copyHidlStringToRil(&pStrings[i], str, pRI)) {
+        if (!copyHidlStringToRil(&pStrings[i], hidl_string(str), pRI)) {
             va_end(ap);
             for (int j = 0; j < i; j++) {
                 memsetAndFreeStrings(1, pStrings[j]);
@@ -674,8 +695,7 @@ bool dispatchIccApdu(int serial, int slotId, int request, const SimApdu& message
         return false;
     }
 
-    RIL_SIM_APDU apdu;
-    memset (&apdu, 0, sizeof(RIL_SIM_APDU));
+    RIL_SIM_APDU apdu = {};
 
     apdu.sessionid = message.sessionId;
     apdu.cla = message.cla;
@@ -695,7 +715,7 @@ bool dispatchIccApdu(int serial, int slotId, int request, const SimApdu& message
     return true;
 }
 
-void checkReturnStatus(int32_t slotId, Return<void>& ret) {
+void checkReturnStatus(int32_t slotId, Return<void>& ret, bool isRadioService) {
     if (ret.isOk() == false) {
         RLOGE("checkReturnStatus: unable to call response/indication callback");
         // Remote process hosting the callbacks must be dead. Reset the callback objects;
@@ -705,7 +725,7 @@ void checkReturnStatus(int32_t slotId, Return<void>& ret) {
         // Caller should already hold rdlock, release that first
         // note the current counter to avoid overwriting updates made by another thread before
         // write lock is acquired.
-        int counter = mCounter[slotId];
+        int counter = isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId];
         pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(slotId);
         int ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
         assert(ret == 0);
@@ -715,12 +735,15 @@ void checkReturnStatus(int32_t slotId, Return<void>& ret) {
         assert(ret == 0);
 
         // make sure the counter value has not changed
-        if (counter == mCounter[slotId]) {
-            radioService[slotId]->mRadioResponse = NULL;
-            radioService[slotId]->mRadioIndication = NULL;
-            oemHookService[slotId]->mOemHookResponse = NULL;
-            oemHookService[slotId]->mOemHookIndication = NULL;
-            mCounter[slotId]++;
+        if (counter == (isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId])) {
+            if (isRadioService) {
+                radioService[slotId]->mRadioResponse = NULL;
+                radioService[slotId]->mRadioIndication = NULL;
+            } else {
+                oemHookService[slotId]->mOemHookResponse = NULL;
+                oemHookService[slotId]->mOemHookIndication = NULL;
+            }
+            isRadioService ? mCounterRadio[slotId]++ : mCounterOemHook[slotId]++;
         } else {
             RLOGE("checkReturnStatus: not resetting responseFunctions as they likely "
                     "got updated on another thread");
@@ -737,7 +760,7 @@ void checkReturnStatus(int32_t slotId, Return<void>& ret) {
 }
 
 void RadioImpl::checkReturnStatus(Return<void>& ret) {
-    ::checkReturnStatus(mSlotId, ret);
+    ::checkReturnStatus(mSlotId, ret, true);
 }
 
 Return<void> RadioImpl::setResponseFunctions(
@@ -751,84 +774,107 @@ Return<void> RadioImpl::setResponseFunctions(
 
     mRadioResponse = radioResponseParam;
     mRadioIndication = radioIndicationParam;
-    mCounter[mSlotId]++;
+    mCounterRadio[mSlotId]++;
 
     ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
     assert(ret == 0);
 
+    // client is connected. Send initial indications.
+    android::onNewCommandConnect((RIL_SOCKET_ID) mSlotId);
+
     return Void();
 }
 
 Return<void> RadioImpl::getIccCardStatus(int32_t serial) {
+#if VDBG
     RLOGD("getIccCardStatus: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_STATUS);
     return Void();
 }
 
 Return<void> RadioImpl::supplyIccPinForApp(int32_t serial, const hidl_string& pin,
         const hidl_string& aid) {
+#if VDBG
     RLOGD("supplyIccPinForApp: serial %d", serial);
+#endif
     dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN,
-            2, (const char *)pin, (const char *)aid);
+            2, pin.c_str(), aid.c_str());
     return Void();
 }
 
 Return<void> RadioImpl::supplyIccPukForApp(int32_t serial, const hidl_string& puk,
                                            const hidl_string& pin, const hidl_string& aid) {
+#if VDBG
     RLOGD("supplyIccPukForApp: serial %d", serial);
+#endif
     dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK,
-            3, (const char *)puk, (const char *)pin, (const char *)aid);
+            3, puk.c_str(), pin.c_str(), aid.c_str());
     return Void();
 }
 
 Return<void> RadioImpl::supplyIccPin2ForApp(int32_t serial, const hidl_string& pin2,
                                             const hidl_string& aid) {
+#if VDBG
     RLOGD("supplyIccPin2ForApp: serial %d", serial);
+#endif
     dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN2,
-            2, (const char *)pin2, (const char *)aid);
+            2, pin2.c_str(), aid.c_str());
     return Void();
 }
 
 Return<void> RadioImpl::supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
                                             const hidl_string& pin2, const hidl_string& aid) {
+#if VDBG
     RLOGD("supplyIccPuk2ForApp: serial %d", serial);
+#endif
     dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK2,
-            3, (const char *)puk2, (const char *)pin2, (const char *)aid);
+            3, puk2.c_str(), pin2.c_str(), aid.c_str());
     return Void();
 }
 
 Return<void> RadioImpl::changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
                                            const hidl_string& newPin, const hidl_string& aid) {
+#if VDBG
     RLOGD("changeIccPinForApp: serial %d", serial);
+#endif
     dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN,
-            3, (const char *)oldPin, (const char *)newPin, (const char *)aid);
+            3, oldPin.c_str(), newPin.c_str(), aid.c_str());
     return Void();
 }
 
 Return<void> RadioImpl::changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
                                             const hidl_string& newPin2, const hidl_string& aid) {
+#if VDBG
     RLOGD("changeIccPin2ForApp: serial %d", serial);
+#endif
     dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN2,
-            3, (const char *)oldPin2, (const char *)newPin2, (const char *)aid);
+            3, oldPin2.c_str(), newPin2.c_str(), aid.c_str());
     return Void();
 }
 
 Return<void> RadioImpl::supplyNetworkDepersonalization(int32_t serial,
                                                        const hidl_string& netPin) {
+#if VDBG
     RLOGD("supplyNetworkDepersonalization: serial %d", serial);
+#endif
     dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION,
-            1, (const char *)netPin);
+            1, netPin.c_str());
     return Void();
 }
 
 Return<void> RadioImpl::getCurrentCalls(int32_t serial) {
+#if VDBG
     RLOGD("getCurrentCalls: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS);
     return Void();
 }
 
 Return<void> RadioImpl::dial(int32_t serial, const Dial& dialInfo) {
+#if VDBG
     RLOGD("dial: serial %d", serial);
+#endif
     RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_DIAL);
     if (pRI == NULL) {
         return Void();
@@ -868,74 +914,98 @@ Return<void> RadioImpl::dial(int32_t serial, const Dial& dialInfo) {
 }
 
 Return<void> RadioImpl::getImsiForApp(int32_t serial, const hidl_string& aid) {
+#if VDBG
     RLOGD("getImsiForApp: serial %d", serial);
+#endif
     dispatchStrings(serial, mSlotId, RIL_REQUEST_GET_IMSI,
-            1, (const char *) aid);
+            1, aid.c_str());
     return Void();
 }
 
 Return<void> RadioImpl::hangup(int32_t serial, int32_t gsmIndex) {
+#if VDBG
     RLOGD("hangup: serial %d", serial);
+#endif
     dispatchInts(serial, mSlotId, RIL_REQUEST_HANGUP, 1, gsmIndex);
     return Void();
 }
 
 Return<void> RadioImpl::hangupWaitingOrBackground(int32_t serial) {
+#if VDBG
     RLOGD("hangupWaitingOrBackground: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND);
     return Void();
 }
 
 Return<void> RadioImpl::hangupForegroundResumeBackground(int32_t serial) {
+#if VDBG
     RLOGD("hangupForegroundResumeBackground: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND);
     return Void();
 }
 
 Return<void> RadioImpl::switchWaitingOrHoldingAndActive(int32_t serial) {
+#if VDBG
     RLOGD("switchWaitingOrHoldingAndActive: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE);
     return Void();
 }
 
 Return<void> RadioImpl::conference(int32_t serial) {
+#if VDBG
     RLOGD("conference: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFERENCE);
     return Void();
 }
 
 Return<void> RadioImpl::rejectCall(int32_t serial) {
+#if VDBG
     RLOGD("rejectCall: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_UDUB);
     return Void();
 }
 
 Return<void> RadioImpl::getLastCallFailCause(int32_t serial) {
+#if VDBG
     RLOGD("getLastCallFailCause: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_LAST_CALL_FAIL_CAUSE);
     return Void();
 }
 
 Return<void> RadioImpl::getSignalStrength(int32_t serial) {
+#if VDBG
     RLOGD("getSignalStrength: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
     return Void();
 }
 
 Return<void> RadioImpl::getVoiceRegistrationState(int32_t serial) {
+#if VDBG
     RLOGD("getVoiceRegistrationState: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
     return Void();
 }
 
 Return<void> RadioImpl::getDataRegistrationState(int32_t serial) {
+#if VDBG
     RLOGD("getDataRegistrationState: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
     return Void();
 }
 
 Return<void> RadioImpl::getOperator(int32_t serial) {
+#if VDBG
     RLOGD("getOperator: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_OPERATOR);
     return Void();
 }
@@ -947,39 +1017,56 @@ Return<void> RadioImpl::setRadioPower(int32_t serial, bool on) {
 }
 
 Return<void> RadioImpl::sendDtmf(int32_t serial, const hidl_string& s) {
+#if VDBG
     RLOGD("sendDtmf: serial %d", serial);
-    dispatchString(serial, mSlotId, RIL_REQUEST_DTMF, (const char *) s);
+#endif
+    dispatchString(serial, mSlotId, RIL_REQUEST_DTMF, s.c_str());
     return Void();
 }
 
 Return<void> RadioImpl::sendSms(int32_t serial, const GsmSmsMessage& message) {
+#if VDBG
     RLOGD("sendSms: serial %d", serial);
+#endif
     dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS,
-            2, (const char *) message.smscPdu, (const char *) message.pdu);
+            2, message.smscPdu.c_str(), message.pdu.c_str());
     return Void();
 }
 
 Return<void> RadioImpl::sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message) {
+#if VDBG
     RLOGD("sendSMSExpectMore: serial %d", serial);
+#endif
     dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE,
-            2, (const char *) message.smscPdu, (const char *) message.pdu);
+            2, message.smscPdu.c_str(), message.pdu.c_str());
     return Void();
 }
 
-const char *convertMvnoTypeToString(MvnoType type) {
+static bool convertMvnoTypeToString(MvnoType type, char *&str) {
     switch (type) {
-        case MvnoType::IMSI: return "imsi";
-        case MvnoType::GID: return "gid";
-        case MvnoType::SPN: return "spn";
-        default: return NULL;
+        case MvnoType::IMSI:
+            str = (char *)"imsi";
+            return true;
+        case MvnoType::GID:
+            str = (char *)"gid";
+            return true;
+        case MvnoType::SPN:
+            str = (char *)"spn";
+            return true;
+        case MvnoType::NONE:
+            str = (char *)"";
+            return true;
     }
+    return false;
 }
 
 Return<void> RadioImpl::setupDataCall(int32_t serial, RadioTechnology radioTechnology,
                                       const DataProfileInfo& dataProfileInfo, bool modemCognitive,
                                       bool roamingAllowed, bool isRoaming) {
 
+#if VDBG
     RLOGD("setupDataCall: serial %d", serial);
+#endif
 
     if (s_vendorFunctions->version >= 4 && s_vendorFunctions->version <= 14) {
         const hidl_string &protocol =
@@ -993,8 +1080,8 @@ Return<void> RadioImpl::setupDataCall(int32_t serial, RadioTechnology radioTechn
             std::to_string((int) dataProfileInfo.authType).c_str(),
             protocol.c_str());
     } else if (s_vendorFunctions->version >= 15) {
-        const char *mvnoTypeStr = convertMvnoTypeToString(dataProfileInfo.mvnoType);
-        if (mvnoTypeStr == NULL) {
+        char *mvnoTypeStr = NULL;
+        if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, mvnoTypeStr)) {
             RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
                     RIL_REQUEST_SETUP_DATA_CALL);
             if (pRI != NULL) {
@@ -1013,11 +1100,11 @@ Return<void> RadioImpl::setupDataCall(int32_t serial, RadioTechnology radioTechn
             dataProfileInfo.roamingProtocol.c_str(),
             std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
             std::to_string(dataProfileInfo.bearerBitmap).c_str(),
-            BOOL_TO_INT(modemCognitive),
+            modemCognitive ? "1" : "0",
             std::to_string(dataProfileInfo.mtu).c_str(),
             mvnoTypeStr,
             dataProfileInfo.mvnoMatchData.c_str(),
-            BOOL_TO_INT(roamingAllowed));
+            roamingAllowed ? "1" : "0");
     } else {
         RLOGE("Unsupported RIL version %d, min version expected 4", s_vendorFunctions->version);
         RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
@@ -1030,13 +1117,15 @@ Return<void> RadioImpl::setupDataCall(int32_t serial, RadioTechnology radioTechn
 }
 
 Return<void> RadioImpl::iccIOForApp(int32_t serial, const IccIo& iccIo) {
+#if VDBG
     RLOGD("iccIOForApp: serial %d", serial);
+#endif
     RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_IO);
     if (pRI == NULL) {
         return Void();
     }
 
-    RIL_SIM_IO_v6 rilIccIo;
+    RIL_SIM_IO_v6 rilIccIo = {};
     rilIccIo.command = iccIo.command;
     rilIccIo.fileid = iccIo.fileId;
     if (!copyHidlStringToRil(&rilIccIo.path, iccIo.path, pRI)) {
@@ -1070,51 +1159,67 @@ Return<void> RadioImpl::iccIOForApp(int32_t serial, const IccIo& iccIo) {
 }
 
 Return<void> RadioImpl::sendUssd(int32_t serial, const hidl_string& ussd) {
+#if VDBG
     RLOGD("sendUssd: serial %d", serial);
-    dispatchString(serial, mSlotId, RIL_REQUEST_SEND_USSD, (const char *) ussd);
+#endif
+    dispatchString(serial, mSlotId, RIL_REQUEST_SEND_USSD, ussd.c_str());
     return Void();
 }
 
 Return<void> RadioImpl::cancelPendingUssd(int32_t serial) {
+#if VDBG
     RLOGD("cancelPendingUssd: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_USSD);
     return Void();
 }
 
 Return<void> RadioImpl::getClir(int32_t serial) {
+#if VDBG
     RLOGD("getClir: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CLIR);
     return Void();
 }
 
 Return<void> RadioImpl::setClir(int32_t serial, int32_t status) {
+#if VDBG
     RLOGD("setClir: serial %d", serial);
+#endif
     dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CLIR, 1, status);
     return Void();
 }
 
 Return<void> RadioImpl::getCallForwardStatus(int32_t serial, const CallForwardInfo& callInfo) {
+#if VDBG
     RLOGD("getCallForwardStatus: serial %d", serial);
+#endif
     dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_QUERY_CALL_FORWARD_STATUS,
             callInfo);
     return Void();
 }
 
 Return<void> RadioImpl::setCallForward(int32_t serial, const CallForwardInfo& callInfo) {
+#if VDBG
     RLOGD("setCallForward: serial %d", serial);
+#endif
     dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_SET_CALL_FORWARD,
             callInfo);
     return Void();
 }
 
 Return<void> RadioImpl::getCallWaiting(int32_t serial, int32_t serviceClass) {
+#if VDBG
     RLOGD("getCallWaiting: serial %d", serial);
+#endif
     dispatchInts(serial, mSlotId, RIL_REQUEST_QUERY_CALL_WAITING, 1, serviceClass);
     return Void();
 }
 
 Return<void> RadioImpl::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) {
+#if VDBG
     RLOGD("setCallWaiting: serial %d", serial);
+#endif
     dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CALL_WAITING, 2, BOOL_TO_INT(enable),
             serviceClass);
     return Void();
@@ -1122,139 +1227,253 @@ Return<void> RadioImpl::setCallWaiting(int32_t serial, bool enable, int32_t serv
 
 Return<void> RadioImpl::acknowledgeLastIncomingGsmSms(int32_t serial,
                                                       bool success, SmsAcknowledgeFailCause cause) {
+#if VDBG
     RLOGD("acknowledgeLastIncomingGsmSms: serial %d", serial);
+#endif
     dispatchInts(serial, mSlotId, RIL_REQUEST_SMS_ACKNOWLEDGE, 2, BOOL_TO_INT(success),
             cause);
     return Void();
 }
 
 Return<void> RadioImpl::acceptCall(int32_t serial) {
+#if VDBG
     RLOGD("acceptCall: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_ANSWER);
     return Void();
 }
 
 Return<void> RadioImpl::deactivateDataCall(int32_t serial,
                                            int32_t cid, bool reasonRadioShutDown) {
+#if VDBG
     RLOGD("deactivateDataCall: serial %d", serial);
+#endif
     dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL,
-            2, (const char *) (std::to_string(cid)).c_str(), reasonRadioShutDown ? "1" : "0");
+            2, (std::to_string(cid)).c_str(), reasonRadioShutDown ? "1" : "0");
     return Void();
 }
 
 Return<void> RadioImpl::getFacilityLockForApp(int32_t serial, const hidl_string& facility,
                                               const hidl_string& password, int32_t serviceClass,
                                               const hidl_string& appId) {
+#if VDBG
     RLOGD("getFacilityLockForApp: serial %d", serial);
+#endif
     dispatchStrings(serial, mSlotId, RIL_REQUEST_QUERY_FACILITY_LOCK,
-            4, (const char *) facility, (const char *) password,
-            (const char *) (std::to_string(serviceClass)).c_str(), (const char *) appId);
+            4, facility.c_str(), password.c_str(),
+            (std::to_string(serviceClass)).c_str(), appId.c_str());
     return Void();
 }
 
 Return<void> RadioImpl::setFacilityLockForApp(int32_t serial, const hidl_string& facility,
                                               bool lockState, const hidl_string& password,
                                               int32_t serviceClass, const hidl_string& appId) {
+#if VDBG
     RLOGD("setFacilityLockForApp: serial %d", serial);
+#endif
     dispatchStrings(serial, mSlotId, RIL_REQUEST_SET_FACILITY_LOCK,
-            5, (const char *) facility, lockState ? "1" : "0", (const char *) password,
-            (const char *) (std::to_string(serviceClass)).c_str(), (const char *) appId);
+            5, facility.c_str(), lockState ? "1" : "0", password.c_str(),
+            (std::to_string(serviceClass)).c_str(), appId.c_str() );
     return Void();
 }
 
 Return<void> RadioImpl::setBarringPassword(int32_t serial, const hidl_string& facility,
                                            const hidl_string& oldPassword,
                                            const hidl_string& newPassword) {
+#if VDBG
     RLOGD("setBarringPassword: serial %d", serial);
+#endif
     dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_BARRING_PASSWORD,
-            2, (const char *) oldPassword,  (const char *) newPassword);
+            2, oldPassword.c_str(), newPassword.c_str());
     return Void();
 }
 
 Return<void> RadioImpl::getNetworkSelectionMode(int32_t serial) {
+#if VDBG
     RLOGD("getNetworkSelectionMode: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE);
     return Void();
 }
 
 Return<void> RadioImpl::setNetworkSelectionModeAutomatic(int32_t serial) {
+#if VDBG
     RLOGD("setNetworkSelectionModeAutomatic: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC);
     return Void();
 }
 
 Return<void> RadioImpl::setNetworkSelectionModeManual(int32_t serial,
                                                       const hidl_string& operatorNumeric) {
+#if VDBG
     RLOGD("setNetworkSelectionModeManual: serial %d", serial);
+#endif
     dispatchString(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL,
-            (const char *) operatorNumeric);
+            operatorNumeric.c_str());
     return Void();
 }
 
 Return<void> RadioImpl::getAvailableNetworks(int32_t serial) {
+#if VDBG
     RLOGD("getAvailableNetworks: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_NETWORKS);
     return Void();
 }
 
+Return<void> RadioImpl::startNetworkScan(int32_t serial, const NetworkScanRequest& request) {
+#if VDBG
+    RLOGD("startNetworkScan: serial %d", serial);
+#endif
+
+    RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_NETWORK_SCAN);
+    if (pRI == NULL) {
+        return Void();
+    }
+
+    if (request.specifiers.size() > MAX_RADIO_ACCESS_NETWORKS) {
+        sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
+        return Void();
+    }
+
+    RIL_NetworkScanRequest scan_request = {};
+
+    scan_request.type = (RIL_ScanType) request.type;
+    scan_request.interval = request.interval;
+    scan_request.specifiers_length = request.specifiers.size();
+    for (size_t i = 0; i < request.specifiers.size(); ++i) {
+        if (request.specifiers[i].geranBands.size() > MAX_BANDS ||
+            request.specifiers[i].utranBands.size() > MAX_BANDS ||
+            request.specifiers[i].eutranBands.size() > MAX_BANDS ||
+            request.specifiers[i].channels.size() > MAX_CHANNELS) {
+            sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
+            return Void();
+        }
+        const ::android::hardware::radio::V1_1::RadioAccessSpecifier& ras_from =
+                request.specifiers[i];
+        RIL_RadioAccessSpecifier& ras_to = scan_request.specifiers[i];
+
+        ras_to.radio_access_network = (RIL_RadioAccessNetworks) ras_from.radioAccessNetwork;
+        ras_to.channels_length = ras_from.channels.size();
+
+        std::copy(ras_from.channels.begin(), ras_from.channels.end(), ras_to.channels);
+        const std::vector<uint32_t> * bands = nullptr;
+        switch (request.specifiers[i].radioAccessNetwork) {
+            case ::android::hardware::radio::V1_1::RadioAccessNetworks::GERAN:
+                ras_to.bands_length = ras_from.geranBands.size();
+                bands = (std::vector<uint32_t> *) &ras_from.geranBands;
+                break;
+            case ::android::hardware::radio::V1_1::RadioAccessNetworks::UTRAN:
+                ras_to.bands_length = ras_from.utranBands.size();
+                bands = (std::vector<uint32_t> *) &ras_from.utranBands;
+                break;
+            case ::android::hardware::radio::V1_1::RadioAccessNetworks::EUTRAN:
+                ras_to.bands_length = ras_from.eutranBands.size();
+                bands = (std::vector<uint32_t> *) &ras_from.eutranBands;
+                break;
+            default:
+                sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
+                return Void();
+        }
+        // safe to copy to geran_bands because it's a union member
+        for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
+            ras_to.bands.geran_bands[idx] = (RIL_GeranBands) (*bands)[idx];
+        }
+    }
+
+    s_vendorFunctions->onRequest(
+            RIL_REQUEST_START_NETWORK_SCAN, &scan_request, sizeof(scan_request), pRI);
+
+    return Void();
+}
+
+Return<void> RadioImpl::stopNetworkScan(int32_t serial) {
+#if VDBG
+    RLOGD("stopNetworkScan: serial %d", serial);
+#endif
+    dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_NETWORK_SCAN);
+    return Void();
+}
+
 Return<void> RadioImpl::startDtmf(int32_t serial, const hidl_string& s) {
+#if VDBG
     RLOGD("startDtmf: serial %d", serial);
+#endif
     dispatchString(serial, mSlotId, RIL_REQUEST_DTMF_START,
-            (const char *) s);
+            s.c_str());
     return Void();
 }
 
 Return<void> RadioImpl::stopDtmf(int32_t serial) {
+#if VDBG
     RLOGD("stopDtmf: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_DTMF_STOP);
     return Void();
 }
 
 Return<void> RadioImpl::getBasebandVersion(int32_t serial) {
+#if VDBG
     RLOGD("getBasebandVersion: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_BASEBAND_VERSION);
     return Void();
 }
 
 Return<void> RadioImpl::separateConnection(int32_t serial, int32_t gsmIndex) {
+#if VDBG
     RLOGD("separateConnection: serial %d", serial);
+#endif
     dispatchInts(serial, mSlotId, RIL_REQUEST_SEPARATE_CONNECTION, 1, gsmIndex);
     return Void();
 }
 
 Return<void> RadioImpl::setMute(int32_t serial, bool enable) {
+#if VDBG
     RLOGD("setMute: serial %d", serial);
+#endif
     dispatchInts(serial, mSlotId, RIL_REQUEST_SET_MUTE, 1, BOOL_TO_INT(enable));
     return Void();
 }
 
 Return<void> RadioImpl::getMute(int32_t serial) {
+#if VDBG
     RLOGD("getMute: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MUTE);
     return Void();
 }
 
 Return<void> RadioImpl::getClip(int32_t serial) {
+#if VDBG
     RLOGD("getClip: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_CLIP);
     return Void();
 }
 
 Return<void> RadioImpl::getDataCallList(int32_t serial) {
+#if VDBG
     RLOGD("getDataCallList: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST);
     return Void();
 }
 
 Return<void> RadioImpl::setSuppServiceNotifications(int32_t serial, bool enable) {
+#if VDBG
     RLOGD("setSuppServiceNotifications: serial %d", serial);
+#endif
     dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, 1,
             BOOL_TO_INT(enable));
     return Void();
 }
 
 Return<void> RadioImpl::writeSmsToSim(int32_t serial, const SmsWriteArgs& smsWriteArgs) {
+#if VDBG
     RLOGD("writeSmsToSim: serial %d", serial);
+#endif
     RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_WRITE_SMS_TO_SIM);
     if (pRI == NULL) {
         return Void();
@@ -1281,137 +1500,175 @@ Return<void> RadioImpl::writeSmsToSim(int32_t serial, const SmsWriteArgs& smsWri
 }
 
 Return<void> RadioImpl::deleteSmsOnSim(int32_t serial, int32_t index) {
+#if VDBG
     RLOGD("deleteSmsOnSim: serial %d", serial);
+#endif
     dispatchInts(serial, mSlotId, RIL_REQUEST_DELETE_SMS_ON_SIM, 1, index);
     return Void();
 }
 
 Return<void> RadioImpl::setBandMode(int32_t serial, RadioBandMode mode) {
+#if VDBG
     RLOGD("setBandMode: serial %d", serial);
+#endif
     dispatchInts(serial, mSlotId, RIL_REQUEST_SET_BAND_MODE, 1, mode);
     return Void();
 }
 
 Return<void> RadioImpl::getAvailableBandModes(int32_t serial) {
+#if VDBG
     RLOGD("getAvailableBandModes: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE);
     return Void();
 }
 
 Return<void> RadioImpl::sendEnvelope(int32_t serial, const hidl_string& command) {
+#if VDBG
     RLOGD("sendEnvelope: serial %d", serial);
+#endif
     dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND,
-            (const char *) command);
+            command.c_str());
     return Void();
 }
 
 Return<void> RadioImpl::sendTerminalResponseToSim(int32_t serial,
                                                   const hidl_string& commandResponse) {
+#if VDBG
     RLOGD("sendTerminalResponseToSim: serial %d", serial);
+#endif
     dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE,
-            (const char *) commandResponse);
+            commandResponse.c_str());
     return Void();
 }
 
 Return<void> RadioImpl::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) {
+#if VDBG
     RLOGD("handleStkCallSetupRequestFromSim: serial %d", serial);
+#endif
     dispatchInts(serial, mSlotId, RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM,
             1, BOOL_TO_INT(accept));
     return Void();
 }
 
 Return<void> RadioImpl::explicitCallTransfer(int32_t serial) {
+#if VDBG
     RLOGD("explicitCallTransfer: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_EXPLICIT_CALL_TRANSFER);
     return Void();
 }
 
 Return<void> RadioImpl::setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType) {
+#if VDBG
     RLOGD("setPreferredNetworkType: serial %d", serial);
+#endif
     dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, 1, nwType);
     return Void();
 }
 
 Return<void> RadioImpl::getPreferredNetworkType(int32_t serial) {
+#if VDBG
     RLOGD("getPreferredNetworkType: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE);
     return Void();
 }
 
 Return<void> RadioImpl::getNeighboringCids(int32_t serial) {
+#if VDBG
     RLOGD("getNeighboringCids: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_NEIGHBORING_CELL_IDS);
     return Void();
 }
 
 Return<void> RadioImpl::setLocationUpdates(int32_t serial, bool enable) {
+#if VDBG
     RLOGD("setLocationUpdates: serial %d", serial);
+#endif
     dispatchInts(serial, mSlotId, RIL_REQUEST_SET_LOCATION_UPDATES, 1, BOOL_TO_INT(enable));
     return Void();
 }
 
 Return<void> RadioImpl::setCdmaSubscriptionSource(int32_t serial, CdmaSubscriptionSource cdmaSub) {
+#if VDBG
     RLOGD("setCdmaSubscriptionSource: serial %d", serial);
+#endif
     dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, 1, cdmaSub);
     return Void();
 }
 
 Return<void> RadioImpl::setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type) {
+#if VDBG
     RLOGD("setCdmaRoamingPreference: serial %d", serial);
+#endif
     dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, 1, type);
     return Void();
 }
 
 Return<void> RadioImpl::getCdmaRoamingPreference(int32_t serial) {
+#if VDBG
     RLOGD("getCdmaRoamingPreference: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE);
     return Void();
 }
 
 Return<void> RadioImpl::setTTYMode(int32_t serial, TtyMode mode) {
+#if VDBG
     RLOGD("setTTYMode: serial %d", serial);
+#endif
     dispatchInts(serial, mSlotId, RIL_REQUEST_SET_TTY_MODE, 1, mode);
     return Void();
 }
 
 Return<void> RadioImpl::getTTYMode(int32_t serial) {
+#if VDBG
     RLOGD("getTTYMode: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_TTY_MODE);
     return Void();
 }
 
 Return<void> RadioImpl::setPreferredVoicePrivacy(int32_t serial, bool enable) {
+#if VDBG
     RLOGD("setPreferredVoicePrivacy: serial %d", serial);
+#endif
     dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE,
             1, BOOL_TO_INT(enable));
     return Void();
 }
 
 Return<void> RadioImpl::getPreferredVoicePrivacy(int32_t serial) {
+#if VDBG
     RLOGD("getPreferredVoicePrivacy: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE);
     return Void();
 }
 
 Return<void> RadioImpl::sendCDMAFeatureCode(int32_t serial, const hidl_string& featureCode) {
+#if VDBG
     RLOGD("sendCDMAFeatureCode: serial %d", serial);
+#endif
     dispatchString(serial, mSlotId, RIL_REQUEST_CDMA_FLASH,
-            (const char *) featureCode);
+            featureCode.c_str());
     return Void();
 }
 
 Return<void> RadioImpl::sendBurstDtmf(int32_t serial, const hidl_string& dtmf, int32_t on,
                                       int32_t off) {
+#if VDBG
     RLOGD("sendBurstDtmf: serial %d", serial);
+#endif
     dispatchStrings(serial, mSlotId, RIL_REQUEST_CDMA_BURST_DTMF,
-            3, (const char *) dtmf, (const char *) (std::to_string(on)).c_str(),
-            (const char *) (std::to_string(off)).c_str());
+            3, dtmf.c_str(), (std::to_string(on)).c_str(),
+            (std::to_string(off)).c_str());
     return Void();
 }
 
 void constructCdmaSms(RIL_CDMA_SMS_Message &rcsm, const CdmaSmsMessage& sms) {
-    memset(&rcsm, 0, sizeof(rcsm));
-
     rcsm.uTeleserviceID = sms.teleserviceId;
     rcsm.bIsServicePresent = BOOL_TO_INT(sms.isServicePresent);
     rcsm.uServicecategory = sms.serviceCategory;
@@ -1443,13 +1700,15 @@ void constructCdmaSms(RIL_CDMA_SMS_Message &rcsm, const CdmaSmsMessage& sms) {
 }
 
 Return<void> RadioImpl::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) {
+#if VDBG
     RLOGD("sendCdmaSms: serial %d", serial);
+#endif
     RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SEND_SMS);
     if (pRI == NULL) {
         return Void();
     }
 
-    RIL_CDMA_SMS_Message rcsm;
+    RIL_CDMA_SMS_Message rcsm = {};
     constructCdmaSms(rcsm, sms);
 
     s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI);
@@ -1457,7 +1716,9 @@ Return<void> RadioImpl::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) {
 }
 
 Return<void> RadioImpl::acknowledgeLastIncomingCdmaSms(int32_t serial, const CdmaSmsAck& smsAck) {
+#if VDBG
     RLOGD("acknowledgeLastIncomingCdmaSms: serial %d", serial);
+#endif
     RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE);
     if (pRI == NULL) {
         return Void();
@@ -1473,7 +1734,9 @@ Return<void> RadioImpl::acknowledgeLastIncomingCdmaSms(int32_t serial, const Cdm
 }
 
 Return<void> RadioImpl::getGsmBroadcastConfig(int32_t serial) {
+#if VDBG
     RLOGD("getGsmBroadcastConfig: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG);
     return Void();
 }
@@ -1481,7 +1744,9 @@ Return<void> RadioImpl::getGsmBroadcastConfig(int32_t serial) {
 Return<void> RadioImpl::setGsmBroadcastConfig(int32_t serial,
                                               const hidl_vec<GsmBroadcastSmsConfigInfo>&
                                               configInfo) {
+#if VDBG
     RLOGD("setGsmBroadcastConfig: serial %d", serial);
+#endif
     RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
             RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG);
     if (pRI == NULL) {
@@ -1507,14 +1772,18 @@ Return<void> RadioImpl::setGsmBroadcastConfig(int32_t serial,
 }
 
 Return<void> RadioImpl::setGsmBroadcastActivation(int32_t serial, bool activate) {
+#if VDBG
     RLOGD("setGsmBroadcastActivation: serial %d", serial);
+#endif
     dispatchInts(serial, mSlotId, RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION,
             1, BOOL_TO_INT(!activate));
     return Void();
 }
 
 Return<void> RadioImpl::getCdmaBroadcastConfig(int32_t serial) {
+#if VDBG
     RLOGD("getCdmaBroadcastConfig: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG);
     return Void();
 }
@@ -1522,7 +1791,9 @@ Return<void> RadioImpl::getCdmaBroadcastConfig(int32_t serial) {
 Return<void> RadioImpl::setCdmaBroadcastConfig(int32_t serial,
                                                const hidl_vec<CdmaBroadcastSmsConfigInfo>&
                                                configInfo) {
+#if VDBG
     RLOGD("setCdmaBroadcastConfig: serial %d", serial);
+#endif
     RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
             RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG);
     if (pRI == NULL) {
@@ -1546,20 +1817,26 @@ Return<void> RadioImpl::setCdmaBroadcastConfig(int32_t serial,
 }
 
 Return<void> RadioImpl::setCdmaBroadcastActivation(int32_t serial, bool activate) {
+#if VDBG
     RLOGD("setCdmaBroadcastActivation: serial %d", serial);
+#endif
     dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION,
             1, BOOL_TO_INT(!activate));
     return Void();
 }
 
 Return<void> RadioImpl::getCDMASubscription(int32_t serial) {
+#if VDBG
     RLOGD("getCDMASubscription: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_SUBSCRIPTION);
     return Void();
 }
 
 Return<void> RadioImpl::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms) {
+#if VDBG
     RLOGD("writeSmsToRuim: serial %d", serial);
+#endif
     RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
             RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM);
     if (pRI == NULL) {
@@ -1575,98 +1852,128 @@ Return<void> RadioImpl::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& c
 }
 
 Return<void> RadioImpl::deleteSmsOnRuim(int32_t serial, int32_t index) {
+#if VDBG
     RLOGD("deleteSmsOnRuim: serial %d", serial);
+#endif
     dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, 1, index);
     return Void();
 }
 
 Return<void> RadioImpl::getDeviceIdentity(int32_t serial) {
+#if VDBG
     RLOGD("getDeviceIdentity: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_DEVICE_IDENTITY);
     return Void();
 }
 
 Return<void> RadioImpl::exitEmergencyCallbackMode(int32_t serial) {
+#if VDBG
     RLOGD("exitEmergencyCallbackMode: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE);
     return Void();
 }
 
 Return<void> RadioImpl::getSmscAddress(int32_t serial) {
+#if VDBG
     RLOGD("getSmscAddress: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SMSC_ADDRESS);
     return Void();
 }
 
 Return<void> RadioImpl::setSmscAddress(int32_t serial, const hidl_string& smsc) {
+#if VDBG
     RLOGD("setSmscAddress: serial %d", serial);
+#endif
     dispatchString(serial, mSlotId, RIL_REQUEST_SET_SMSC_ADDRESS,
-            (const char *) smsc);
+            smsc.c_str());
     return Void();
 }
 
 Return<void> RadioImpl::reportSmsMemoryStatus(int32_t serial, bool available) {
+#if VDBG
     RLOGD("reportSmsMemoryStatus: serial %d", serial);
+#endif
     dispatchInts(serial, mSlotId, RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, 1,
             BOOL_TO_INT(available));
     return Void();
 }
 
 Return<void> RadioImpl::reportStkServiceIsRunning(int32_t serial) {
+#if VDBG
     RLOGD("reportStkServiceIsRunning: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING);
     return Void();
 }
 
 Return<void> RadioImpl::getCdmaSubscriptionSource(int32_t serial) {
+#if VDBG
     RLOGD("getCdmaSubscriptionSource: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE);
     return Void();
 }
 
 Return<void> RadioImpl::requestIsimAuthentication(int32_t serial, const hidl_string& challenge) {
+#if VDBG
     RLOGD("requestIsimAuthentication: serial %d", serial);
+#endif
     dispatchString(serial, mSlotId, RIL_REQUEST_ISIM_AUTHENTICATION,
-            (const char *) challenge);
+            challenge.c_str());
     return Void();
 }
 
 Return<void> RadioImpl::acknowledgeIncomingGsmSmsWithPdu(int32_t serial, bool success,
                                                          const hidl_string& ackPdu) {
+#if VDBG
     RLOGD("acknowledgeIncomingGsmSmsWithPdu: serial %d", serial);
+#endif
     dispatchStrings(serial, mSlotId, RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU,
-            2, success ? "1" : "0", (const char *) ackPdu);
+            2, success ? "1" : "0", ackPdu.c_str());
     return Void();
 }
 
 Return<void> RadioImpl::sendEnvelopeWithStatus(int32_t serial, const hidl_string& contents) {
+#if VDBG
     RLOGD("sendEnvelopeWithStatus: serial %d", serial);
+#endif
     dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS,
-            (const char *) contents);
+            contents.c_str());
     return Void();
 }
 
 Return<void> RadioImpl::getVoiceRadioTechnology(int32_t serial) {
+#if VDBG
     RLOGD("getVoiceRadioTechnology: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_RADIO_TECH);
     return Void();
 }
 
 Return<void> RadioImpl::getCellInfoList(int32_t serial) {
+#if VDBG
     RLOGD("getCellInfoList: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CELL_INFO_LIST);
     return Void();
 }
 
 Return<void> RadioImpl::setCellInfoListRate(int32_t serial, int32_t rate) {
+#if VDBG
     RLOGD("setCellInfoListRate: serial %d", serial);
+#endif
     dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, 1, rate);
     return Void();
 }
 
 Return<void> RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
                                             bool modemCognitive, bool isRoaming) {
+#if VDBG
     RLOGD("setInitialAttachApn: serial %d", serial);
+#endif
     RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
             RIL_REQUEST_SET_INITIAL_ATTACH_APN);
     if (pRI == NULL) {
@@ -1684,13 +1991,16 @@ Return<void> RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInf
                 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
 
         if (!copyHidlStringToRil(&iaa.protocol, protocol, pRI)) {
+            memsetAndFreeStrings(1, iaa.apn);
             return Void();
         }
         iaa.authtype = (int) dataProfileInfo.authType;
         if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
+            memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
             return Void();
         }
         if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
+            memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.username);
             return Void();
         }
 
@@ -1704,16 +2014,20 @@ Return<void> RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInf
             return Void();
         }
         if (!copyHidlStringToRil(&iaa.protocol, dataProfileInfo.protocol, pRI)) {
+            memsetAndFreeStrings(1, iaa.apn);
             return Void();
         }
         if (!copyHidlStringToRil(&iaa.roamingProtocol, dataProfileInfo.roamingProtocol, pRI)) {
+            memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
             return Void();
         }
         iaa.authtype = (int) dataProfileInfo.authType;
         if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
+            memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.roamingProtocol);
             return Void();
         }
         if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
+            memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username);
             return Void();
         }
         iaa.supportedTypesBitmask = dataProfileInfo.supportedApnTypesBitmap;
@@ -1721,14 +2035,16 @@ Return<void> RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInf
         iaa.modemCognitive = BOOL_TO_INT(modemCognitive);
         iaa.mtu = dataProfileInfo.mtu;
 
-        // Note that there is no need for memory allocation/free.
-        iaa.mvnoType = (char *) convertMvnoTypeToString(dataProfileInfo.mvnoType);
-        if (iaa.mvnoType == NULL) {
+        if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, iaa.mvnoType)) {
             sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
+            memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
+                    iaa.password);
             return Void();
         }
 
         if (!copyHidlStringToRil(&iaa.mvnoMatchData, dataProfileInfo.mvnoMatchData, pRI)) {
+            memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
+                    iaa.password);
             return Void();
         }
 
@@ -1742,7 +2058,9 @@ Return<void> RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInf
 }
 
 Return<void> RadioImpl::getImsRegistrationState(int32_t serial) {
+#if VDBG
     RLOGD("getImsRegistrationState: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_IMS_REGISTRATION_STATE);
     return Void();
 }
@@ -1773,7 +2091,7 @@ bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) {
 
     if (!copyHidlStringToRil(&pStrings[0], message.gsmMessage[0].smscPdu, pRI)) {
 #ifdef MEMSET_FREED
-        memset(pStrings, 0, datalen);
+        memset(pStrings, 0, dataLen);
 #endif
         free(pStrings);
         return false;
@@ -1782,7 +2100,7 @@ bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) {
     if (!copyHidlStringToRil(&pStrings[1], message.gsmMessage[0].pdu, pRI)) {
         memsetAndFreeStrings(1, pStrings[0]);
 #ifdef MEMSET_FREED
-        memset(pStrings, 0, datalen);
+        memset(pStrings, 0, dataLen);
 #endif
         free(pStrings);
         return false;
@@ -1797,7 +2115,7 @@ bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) {
     }
 
 #ifdef MEMSET_FREED
-    memset(pStrings, 0, datalen);
+    memset(pStrings, 0, dataLen);
 #endif
     free(pStrings);
 
@@ -1805,8 +2123,8 @@ bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) {
 }
 
 bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) {
-    RIL_IMS_SMS_Message rism;
-    RIL_CDMA_SMS_Message rcsm;
+    RIL_IMS_SMS_Message rism = {};
+    RIL_CDMA_SMS_Message rcsm = {};
 
     if (message.cdmaMessage.size() != 1) {
         RLOGE("dispatchImsCdmaSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
@@ -1828,7 +2146,9 @@ bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) {
 }
 
 Return<void> RadioImpl::sendImsSms(int32_t serial, const ImsSmsMessage& message) {
+#if VDBG
     RLOGD("sendImsSms: serial %d", serial);
+#endif
     RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_IMS_SEND_SMS);
     if (pRI == NULL) {
         return Void();
@@ -1849,39 +2169,66 @@ Return<void> RadioImpl::sendImsSms(int32_t serial, const ImsSmsMessage& message)
 }
 
 Return<void> RadioImpl::iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message) {
+#if VDBG
     RLOGD("iccTransmitApduBasicChannel: serial %d", serial);
+#endif
     dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, message);
     return Void();
 }
 
-Return<void> RadioImpl::iccOpenLogicalChannel(int32_t serial, const hidl_string& aid) {
+Return<void> RadioImpl::iccOpenLogicalChannel(int32_t serial, const hidl_string& aid, int32_t p2) {
+#if VDBG
     RLOGD("iccOpenLogicalChannel: serial %d", serial);
-    dispatchString(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL,
-            (const char *) aid);
+#endif
+    if (s_vendorFunctions->version < 15) {
+        dispatchString(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL, aid.c_str());
+    } else {
+        RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL);
+        if (pRI == NULL) {
+            return Void();
+        }
+
+        RIL_OpenChannelParams params = {};
+
+        params.p2 = p2;
+
+        if (!copyHidlStringToRil(&params.aidPtr, aid, pRI)) {
+            return Void();
+        }
+
+        s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &params, sizeof(params), pRI);
+
+        memsetAndFreeStrings(1, params.aidPtr);
+    }
     return Void();
 }
 
 Return<void> RadioImpl::iccCloseLogicalChannel(int32_t serial, int32_t channelId) {
+#if VDBG
     RLOGD("iccCloseLogicalChannel: serial %d", serial);
+#endif
     dispatchInts(serial, mSlotId, RIL_REQUEST_SIM_CLOSE_CHANNEL, 1, channelId);
     return Void();
 }
 
 Return<void> RadioImpl::iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message) {
+#if VDBG
     RLOGD("iccTransmitApduLogicalChannel: serial %d", serial);
+#endif
     dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, message);
     return Void();
 }
 
 Return<void> RadioImpl::nvReadItem(int32_t serial, NvItem itemId) {
+#if VDBG
     RLOGD("nvReadItem: serial %d", serial);
+#endif
     RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_READ_ITEM);
     if (pRI == NULL) {
         return Void();
     }
 
-    RIL_NV_ReadItem nvri;
-    memset (&nvri, 0, sizeof(nvri));
+    RIL_NV_ReadItem nvri = {};
     nvri.itemID = (RIL_NV_Item) itemId;
 
     s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI);
@@ -1889,14 +2236,15 @@ Return<void> RadioImpl::nvReadItem(int32_t serial, NvItem itemId) {
 }
 
 Return<void> RadioImpl::nvWriteItem(int32_t serial, const NvWriteItem& item) {
+#if VDBG
     RLOGD("nvWriteItem: serial %d", serial);
+#endif
     RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_WRITE_ITEM);
     if (pRI == NULL) {
         return Void();
     }
 
-    RIL_NV_WriteItem nvwi;
-    memset (&nvwi, 0, sizeof(nvwi));
+    RIL_NV_WriteItem nvwi = {};
 
     nvwi.itemID = (RIL_NV_Item) item.itemId;
 
@@ -1911,19 +2259,43 @@ Return<void> RadioImpl::nvWriteItem(int32_t serial, const NvWriteItem& item) {
 }
 
 Return<void> RadioImpl::nvWriteCdmaPrl(int32_t serial, const hidl_vec<uint8_t>& prl) {
+#if VDBG
     RLOGD("nvWriteCdmaPrl: serial %d", serial);
+#endif
     dispatchRaw(serial, mSlotId, RIL_REQUEST_NV_WRITE_CDMA_PRL, prl);
     return Void();
 }
 
 Return<void> RadioImpl::nvResetConfig(int32_t serial, ResetNvType resetType) {
+    int rilResetType = -1;
+#if VDBG
     RLOGD("nvResetConfig: serial %d", serial);
-    dispatchInts(serial, mSlotId, RIL_REQUEST_NV_RESET_CONFIG, 1, (int) resetType);
+#endif
+    /* Convert ResetNvType to RIL.h values
+     * RIL_REQUEST_NV_RESET_CONFIG
+     * 1 - reload all NV items
+     * 2 - erase NV reset (SCRTN)
+     * 3 - factory reset (RTN)
+     */
+    switch(resetType) {
+      case ResetNvType::RELOAD:
+        rilResetType = 1;
+        break;
+      case ResetNvType::ERASE:
+        rilResetType = 2;
+        break;
+      case ResetNvType::FACTORY_RESET:
+        rilResetType = 3;
+        break;
+    }
+    dispatchInts(serial, mSlotId, RIL_REQUEST_NV_RESET_CONFIG, 1, rilResetType);
     return Void();
 }
 
 Return<void> RadioImpl::setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub) {
+#if VDBG
     RLOGD("setUiccSubscription: serial %d", serial);
+#endif
     RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
             RIL_REQUEST_SET_UICC_SUBSCRIPTION);
     if (pRI == NULL) {
@@ -1942,27 +2314,32 @@ Return<void> RadioImpl::setUiccSubscription(int32_t serial, const SelectUiccSub&
 }
 
 Return<void> RadioImpl::setDataAllowed(int32_t serial, bool allow) {
+#if VDBG
     RLOGD("setDataAllowed: serial %d", serial);
+#endif
     dispatchInts(serial, mSlotId, RIL_REQUEST_ALLOW_DATA, 1, BOOL_TO_INT(allow));
     return Void();
 }
 
 Return<void> RadioImpl::getHardwareConfig(int32_t serial) {
+#if VDBG
     RLOGD("getHardwareConfig: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_HARDWARE_CONFIG);
     return Void();
 }
 
 Return<void> RadioImpl::requestIccSimAuthentication(int32_t serial, int32_t authContext,
         const hidl_string& authData, const hidl_string& aid) {
+#if VDBG
     RLOGD("requestIccSimAuthentication: serial %d", serial);
+#endif
     RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_AUTHENTICATION);
     if (pRI == NULL) {
         return Void();
     }
 
-    RIL_SimAuthentication pf;
-    memset (&pf, 0, sizeof(pf));
+    RIL_SimAuthentication pf = {};
 
     pf.authContext = authContext;
 
@@ -2018,7 +2395,9 @@ void freeSetDataProfileData(int numProfiles, T *dataProfiles, T **dataProfilePtr
 
 Return<void> RadioImpl::setDataProfile(int32_t serial, const hidl_vec<DataProfileInfo>& profiles,
                                        bool isRoaming) {
+#if VDBG
     RLOGD("setDataProfile: serial %d", serial);
+#endif
     RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_DATA_PROFILE);
     if (pRI == NULL) {
         return Void();
@@ -2131,18 +2510,15 @@ Return<void> RadioImpl::setDataProfile(int32_t serial, const hidl_vec<DataProfil
                     pRI)) {
                 success = false;
             }
-
             if (success && !copyHidlStringToRil(&dataProfiles[i].mvnoMatchData,
                     profiles[i].mvnoMatchData, pRI)) {
                 success = false;
             }
 
-            if (success) {
-                dataProfiles[i].mvnoType = (char *) convertMvnoTypeToString(profiles[i].mvnoType);
-                if (dataProfiles[i].mvnoType == NULL) {
-                    sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
-                    success = false;
-                }
+            if (success && !convertMvnoTypeToString(profiles[i].mvnoType,
+                    dataProfiles[i].mvnoType)) {
+                sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
+                success = false;
             }
 
             if (!success) {
@@ -2178,33 +2554,38 @@ Return<void> RadioImpl::setDataProfile(int32_t serial, const hidl_vec<DataProfil
 }
 
 Return<void> RadioImpl::requestShutdown(int32_t serial) {
+#if VDBG
     RLOGD("requestShutdown: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_SHUTDOWN);
     return Void();
 }
 
 Return<void> RadioImpl::getRadioCapability(int32_t serial) {
+#if VDBG
     RLOGD("getRadioCapability: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_RADIO_CAPABILITY);
     return Void();
 }
 
 Return<void> RadioImpl::setRadioCapability(int32_t serial, const RadioCapability& rc) {
+#if VDBG
     RLOGD("setRadioCapability: serial %d", serial);
+#endif
     RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_RADIO_CAPABILITY);
     if (pRI == NULL) {
         return Void();
     }
 
-    RIL_RadioCapability rilRc;
-    memset (&rilRc, 0, sizeof(rilRc));
+    RIL_RadioCapability rilRc = {};
 
     // TODO : set rilRc.version using HIDL version ?
     rilRc.session = rc.session;
     rilRc.phase = (int) rc.phase;
     rilRc.rat = (int) rc.raf;
     rilRc.status = (int) rc.status;
-    strncpy(rilRc.logicalModemUuid, (const char *) rc.logicalModemUuid, MAX_UUID_LENGTH);
+    strncpy(rilRc.logicalModemUuid, rc.logicalModemUuid.c_str(), MAX_UUID_LENGTH);
 
     s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI);
 
@@ -2212,33 +2593,43 @@ Return<void> RadioImpl::setRadioCapability(int32_t serial, const RadioCapability
 }
 
 Return<void> RadioImpl::startLceService(int32_t serial, int32_t reportInterval, bool pullMode) {
+#if VDBG
     RLOGD("startLceService: serial %d", serial);
+#endif
     dispatchInts(serial, mSlotId, RIL_REQUEST_START_LCE, 2, reportInterval,
             BOOL_TO_INT(pullMode));
     return Void();
 }
 
 Return<void> RadioImpl::stopLceService(int32_t serial) {
+#if VDBG
     RLOGD("stopLceService: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_LCE);
     return Void();
 }
 
 Return<void> RadioImpl::pullLceData(int32_t serial) {
+#if VDBG
     RLOGD("pullLceData: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_PULL_LCEDATA);
     return Void();
 }
 
 Return<void> RadioImpl::getModemActivityInfo(int32_t serial) {
+#if VDBG
     RLOGD("getModemActivityInfo: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ACTIVITY_INFO);
     return Void();
 }
 
 Return<void> RadioImpl::setAllowedCarriers(int32_t serial, bool allAllowed,
                                            const CarrierRestrictions& carriers) {
+#if VDBG
     RLOGD("setAllowedCarriers: serial %d", serial);
+#endif
     RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
             RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
     if (pRI == NULL) {
@@ -2274,18 +2665,18 @@ Return<void> RadioImpl::setAllowedCarriers(int32_t serial, bool allAllowed,
     cr.excluded_carriers = excludedCarriers;
 
     for (int i = 0; i < cr.len_allowed_carriers; i++) {
-        allowedCarriers[i].mcc = (const char *) carriers.allowedCarriers[i].mcc;
-        allowedCarriers[i].mnc = (const char *) carriers.allowedCarriers[i].mnc;
+        allowedCarriers[i].mcc = carriers.allowedCarriers[i].mcc.c_str();
+        allowedCarriers[i].mnc = carriers.allowedCarriers[i].mnc.c_str();
         allowedCarriers[i].match_type = (RIL_CarrierMatchType) carriers.allowedCarriers[i].matchType;
-        allowedCarriers[i].match_data = (const char *) carriers.allowedCarriers[i].matchData;
+        allowedCarriers[i].match_data = carriers.allowedCarriers[i].matchData.c_str();
     }
 
     for (int i = 0; i < cr.len_excluded_carriers; i++) {
-        excludedCarriers[i].mcc = (const char *) carriers.excludedCarriers[i].mcc;
-        excludedCarriers[i].mnc = (const char *) carriers.excludedCarriers[i].mnc;
+        excludedCarriers[i].mcc = carriers.excludedCarriers[i].mcc.c_str();
+        excludedCarriers[i].mnc = carriers.excludedCarriers[i].mnc.c_str();
         excludedCarriers[i].match_type =
                 (RIL_CarrierMatchType) carriers.excludedCarriers[i].matchType;
-        excludedCarriers[i].match_data = (const char *) carriers.excludedCarriers[i].matchData;
+        excludedCarriers[i].match_data = carriers.excludedCarriers[i].matchData.c_str();
     }
 
     s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI);
@@ -2300,14 +2691,18 @@ Return<void> RadioImpl::setAllowedCarriers(int32_t serial, bool allAllowed,
 }
 
 Return<void> RadioImpl::getAllowedCarriers(int32_t serial) {
+#if VDBG
     RLOGD("getAllowedCarriers: serial %d", serial);
+#endif
     dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
     return Void();
 }
 
 Return<void> RadioImpl::sendDeviceState(int32_t serial, DeviceStateType deviceStateType,
                                         bool state) {
+#if VDBG
     RLOGD("sendDeviceState: serial %d", serial);
+#endif
     if (s_vendorFunctions->version < 15) {
         if (deviceStateType ==  DeviceStateType::LOW_DATA_EXPECTED) {
             RLOGD("sendDeviceState: calling screen state %d", BOOL_TO_INT(!state));
@@ -2325,7 +2720,9 @@ Return<void> RadioImpl::sendDeviceState(int32_t serial, DeviceStateType deviceSt
 }
 
 Return<void> RadioImpl::setIndicationFilter(int32_t serial, int32_t indicationFilter) {
+#if VDBG
     RLOGD("setIndicationFilter: serial %d", serial);
+#endif
     if (s_vendorFunctions->version < 15) {
         RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
                 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
@@ -2337,11 +2734,22 @@ Return<void> RadioImpl::setIndicationFilter(int32_t serial, int32_t indicationFi
 }
 
 Return<void> RadioImpl::setSimCardPower(int32_t serial, bool powerUp) {
+#if VDBG
     RLOGD("setSimCardPower: serial %d", serial);
+#endif
     dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, BOOL_TO_INT(powerUp));
     return Void();
 }
 
+Return<void> RadioImpl::setSimCardPower_1_1(int32_t serial,
+        const ::android::hardware::radio::V1_1::CardPowerState state) {
+#if VDBG
+    RLOGD("setSimCardPower_1_1: serial %d state %d", serial, state);
+#endif
+    dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, state);
+    return Void();
+}
+
 Return<void> RadioImpl::responseAcknowledgement() {
     android::releaseWakeLock();
     return Void();
@@ -2350,7 +2758,9 @@ Return<void> RadioImpl::responseAcknowledgement() {
 Return<void> OemHookImpl::setResponseFunctions(
         const ::android::sp<IOemHookResponse>& oemHookResponseParam,
         const ::android::sp<IOemHookIndication>& oemHookIndicationParam) {
+#if VDBG
     RLOGD("OemHookImpl::setResponseFunctions");
+#endif
 
     pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
     int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
@@ -2358,7 +2768,7 @@ Return<void> OemHookImpl::setResponseFunctions(
 
     mOemHookResponse = oemHookResponseParam;
     mOemHookIndication = oemHookIndicationParam;
-    mCounter[mSlotId]++;
+    mCounterOemHook[mSlotId]++;
 
     ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
     assert(ret == 0);
@@ -2367,18 +2777,59 @@ Return<void> OemHookImpl::setResponseFunctions(
 }
 
 Return<void> OemHookImpl::sendRequestRaw(int32_t serial, const hidl_vec<uint8_t>& data) {
+#if VDBG
     RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial);
+#endif
     dispatchRaw(serial, mSlotId, RIL_REQUEST_OEM_HOOK_RAW, data);
     return Void();
 }
 
 Return<void> OemHookImpl::sendRequestStrings(int32_t serial,
         const hidl_vec<hidl_string>& data) {
+#if VDBG
     RLOGD("OemHookImpl::sendRequestStrings: serial %d", serial);
+#endif
     dispatchStrings(serial, mSlotId, RIL_REQUEST_OEM_HOOK_STRINGS, data);
     return Void();
 }
 
+Return<void> RadioImpl::setCarrierInfoForImsiEncryption(int32_t serial,
+        const ::android::hardware::radio::V1_1::ImsiEncryptionInfo& data) {
+    RLOGD("setCarrierInfoForImsiEncryption: serial %d", serial);
+    RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION);
+    RIL_CarrierInfoForImsiEncryption imsiEncryption = {};
+
+    if (!copyHidlStringToRil(&imsiEncryption.mnc, data.mnc, pRI)) {
+        return Void();
+    }
+    if (!copyHidlStringToRil(&imsiEncryption.mcc, data.mcc, pRI)) {
+        memsetAndFreeStrings(1, imsiEncryption.mnc);
+        return Void();
+    }
+    if (!copyHidlStringToRil(&imsiEncryption.keyIdentifier, data.keyIdentifier, pRI)) {
+        memsetAndFreeStrings(2, imsiEncryption.mnc, imsiEncryption.mcc);
+        return Void();
+    }
+    int32_t lSize = data.carrierKey.size();
+    imsiEncryption.carrierKey = new uint8_t[lSize];
+    memcpy(imsiEncryption.carrierKey, data.carrierKey.data(), lSize);
+    imsiEncryption.expirationTime = data.expirationTime;
+    s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &imsiEncryption, sizeof(RIL_CarrierInfoForImsiEncryption), pRI);
+    delete(imsiEncryption.carrierKey);
+    return Void();
+}
+
+Return<void> RadioImpl::startKeepalive(int32_t serial, const KeepaliveRequest& keepalive) {
+    RLOGD("startKeepalive: serial %d", serial);
+    return Void();
+}
+
+Return<void> RadioImpl::stopKeepalive(int32_t serial, int32_t sessionHandle) {
+    RLOGD("stopKeepalive: serial %d", serial);
+    return Void();
+}
+
+
 /***************************************************************************************************
  * RESPONSE FUNCTIONS
  * Functions above are used for requests going from framework to vendor code. The ones below are
@@ -2408,6 +2859,25 @@ void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int respo
     responseInfo.error = (RadioError) e;
 }
 
+int responseIntOrEmpty(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
+               void *response, size_t responseLen) {
+    populateResponseInfo(responseInfo, serial, responseType, e);
+    int ret = -1;
+
+    if (response == NULL && responseLen == 0) {
+        // Earlier RILs did not send a response for some cases although the interface
+        // expected an integer as response. Do not return error if response is empty. Instead
+        // Return -1 in those cases to maintain backward compatibility.
+    } else if (response == NULL || responseLen != sizeof(int)) {
+        RLOGE("responseIntOrEmpty: Invalid response");
+        if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
+    } else {
+        int *p_int = (int *) response;
+        ret = p_int[0];
+    }
+    return ret;
+}
+
 int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
                void *response, size_t responseLen) {
     populateResponseInfo(responseInfo, serial, responseType, e);
@@ -2430,11 +2900,14 @@ int radio::getIccCardStatusResponse(int slotId,
         RadioResponseInfo responseInfo = {};
         populateResponseInfo(responseInfo, serial, responseType, e);
         CardStatus cardStatus = {};
-        if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6)) {
+        RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
+        if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6)
+                || p_cur->gsm_umts_subscription_app_index >= p_cur->num_applications
+                || p_cur->cdma_subscription_app_index >= p_cur->num_applications
+                || p_cur->ims_subscription_app_index >= p_cur->num_applications) {
             RLOGE("getIccCardStatusResponse: Invalid response");
             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
         } else {
-            RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
             cardStatus.cardState = (CardState) p_cur->card_state;
             cardStatus.universalPinState = (PinState) p_cur->universal_pin_state;
             cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index;
@@ -2444,7 +2917,9 @@ int radio::getIccCardStatusResponse(int slotId,
             RIL_AppStatus *rilAppStatus = p_cur->applications;
             cardStatus.applications.resize(p_cur->num_applications);
             AppStatus *appStatus = cardStatus.applications.data();
+#if VDBG
             RLOGD("getIccCardStatusResponse: num_applications %d", p_cur->num_applications);
+#endif
             for (int i = 0; i < p_cur->num_applications; i++) {
                 appStatus[i].appType = (AppType) rilAppStatus[i].app_type;
                 appStatus[i].appState = (AppState) rilAppStatus[i].app_state;
@@ -2471,11 +2946,13 @@ int radio::getIccCardStatusResponse(int slotId,
 int radio::supplyIccPinForAppResponse(int slotId,
                                      int responseType, int serial, RIL_Errno e,
                                      void *response, size_t responseLen) {
+#if VDBG
     RLOGD("supplyIccPinForAppResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
-        int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
+        int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
         Return<void> retStatus = radioService[slotId]->mRadioResponse->
                 supplyIccPinForAppResponse(responseInfo, ret);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -2490,11 +2967,13 @@ int radio::supplyIccPinForAppResponse(int slotId,
 int radio::supplyIccPukForAppResponse(int slotId,
                                      int responseType, int serial, RIL_Errno e,
                                      void *response, size_t responseLen) {
+#if VDBG
     RLOGD("supplyIccPukForAppResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
-        int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
+        int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
         Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse(
                 responseInfo, ret);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -2509,11 +2988,13 @@ int radio::supplyIccPukForAppResponse(int slotId,
 int radio::supplyIccPin2ForAppResponse(int slotId,
                                       int responseType, int serial, RIL_Errno e,
                                       void *response, size_t responseLen) {
+#if VDBG
     RLOGD("supplyIccPin2ForAppResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
-        int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
+        int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
         Return<void> retStatus = radioService[slotId]->mRadioResponse->
                 supplyIccPin2ForAppResponse(responseInfo, ret);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -2528,11 +3009,13 @@ int radio::supplyIccPin2ForAppResponse(int slotId,
 int radio::supplyIccPuk2ForAppResponse(int slotId,
                                       int responseType, int serial, RIL_Errno e,
                                       void *response, size_t responseLen) {
+#if VDBG
     RLOGD("supplyIccPuk2ForAppResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
-        int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
+        int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
         Return<void> retStatus = radioService[slotId]->mRadioResponse->
                 supplyIccPuk2ForAppResponse(responseInfo, ret);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -2547,11 +3030,13 @@ int radio::supplyIccPuk2ForAppResponse(int slotId,
 int radio::changeIccPinForAppResponse(int slotId,
                                      int responseType, int serial, RIL_Errno e,
                                      void *response, size_t responseLen) {
+#if VDBG
     RLOGD("changeIccPinForAppResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
-        int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
+        int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
         Return<void> retStatus = radioService[slotId]->mRadioResponse->
                 changeIccPinForAppResponse(responseInfo, ret);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -2566,11 +3051,13 @@ int radio::changeIccPinForAppResponse(int slotId,
 int radio::changeIccPin2ForAppResponse(int slotId,
                                       int responseType, int serial, RIL_Errno e,
                                       void *response, size_t responseLen) {
+#if VDBG
     RLOGD("changeIccPin2ForAppResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
-        int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
+        int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
         Return<void> retStatus = radioService[slotId]->mRadioResponse->
                 changeIccPin2ForAppResponse(responseInfo, ret);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -2585,11 +3072,13 @@ int radio::changeIccPin2ForAppResponse(int slotId,
 int radio::supplyNetworkDepersonalizationResponse(int slotId,
                                                  int responseType, int serial, RIL_Errno e,
                                                  void *response, size_t responseLen) {
+#if VDBG
     RLOGD("supplyNetworkDepersonalizationResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
-        int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
+        int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
         Return<void> retStatus = radioService[slotId]->mRadioResponse->
                 supplyNetworkDepersonalizationResponse(responseInfo, ret);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -2604,7 +3093,9 @@ int radio::supplyNetworkDepersonalizationResponse(int slotId,
 int radio::getCurrentCallsResponse(int slotId,
                                   int responseType, int serial, RIL_Errno e,
                                   void *response, size_t responseLen) {
+#if VDBG
     RLOGD("getCurrentCallsResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -2658,7 +3149,9 @@ int radio::getCurrentCallsResponse(int slotId,
 int radio::dialResponse(int slotId,
                        int responseType, int serial, RIL_Errno e, void *response,
                        size_t responseLen) {
+#if VDBG
     RLOGD("dialResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -2675,7 +3168,9 @@ int radio::dialResponse(int slotId,
 int radio::getIMSIForAppResponse(int slotId,
                                 int responseType, int serial, RIL_Errno e, void *response,
                                 size_t responseLen) {
+#if VDBG
     RLOGD("getIMSIForAppResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -2694,7 +3189,9 @@ int radio::getIMSIForAppResponse(int slotId,
 int radio::hangupConnectionResponse(int slotId,
                                    int responseType, int serial, RIL_Errno e,
                                    void *response, size_t responseLen) {
+#if VDBG
     RLOGD("hangupConnectionResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -2713,7 +3210,9 @@ int radio::hangupConnectionResponse(int slotId,
 int radio::hangupWaitingOrBackgroundResponse(int slotId,
                                             int responseType, int serial, RIL_Errno e,
                                             void *response, size_t responseLen) {
+#if VDBG
     RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -2733,7 +3232,9 @@ int radio::hangupWaitingOrBackgroundResponse(int slotId,
 int radio::hangupForegroundResumeBackgroundResponse(int slotId, int responseType, int serial,
                                                     RIL_Errno e, void *response,
                                                     size_t responseLen) {
+#if VDBG
     RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -2753,7 +3254,9 @@ int radio::hangupForegroundResumeBackgroundResponse(int slotId, int responseType
 int radio::switchWaitingOrHoldingAndActiveResponse(int slotId, int responseType, int serial,
                                                    RIL_Errno e, void *response,
                                                    size_t responseLen) {
+#if VDBG
     RLOGD("switchWaitingOrHoldingAndActiveResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -2772,7 +3275,9 @@ int radio::switchWaitingOrHoldingAndActiveResponse(int slotId, int responseType,
 
 int radio::conferenceResponse(int slotId, int responseType,
                              int serial, RIL_Errno e, void *response, size_t responseLen) {
+#if VDBG
     RLOGD("conferenceResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -2790,7 +3295,9 @@ int radio::conferenceResponse(int slotId, int responseType,
 
 int radio::rejectCallResponse(int slotId, int responseType,
                              int serial, RIL_Errno e, void *response, size_t responseLen) {
+#if VDBG
     RLOGD("rejectCallResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -2809,7 +3316,9 @@ int radio::rejectCallResponse(int slotId, int responseType,
 int radio::getLastCallFailCauseResponse(int slotId,
                                        int responseType, int serial, RIL_Errno e, void *response,
                                        size_t responseLen) {
+#if VDBG
     RLOGD("getLastCallFailCauseResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -2846,7 +3355,9 @@ int radio::getLastCallFailCauseResponse(int slotId,
 int radio::getSignalStrengthResponse(int slotId,
                                      int responseType, int serial, RIL_Errno e,
                                      void *response, size_t responseLen) {
+#if VDBG
     RLOGD("getSignalStrengthResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3011,11 +3522,7 @@ void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity,
         int numStrings, char** response) {
 
     RIL_CellIdentity_v16 rilCellIdentity;
-    int32_t *tmp = (int32_t*)&rilCellIdentity;
-
-    for (size_t i = 0; i < sizeof(RIL_CellIdentity_v16)/sizeof(int32_t); i++) {
-        tmp[i] = -1;
-    }
+    memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
 
     rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
     switch(rilCellIdentity.cellInfoType) {
@@ -3049,9 +3556,10 @@ void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity,
         case RIL_CELL_INFO_TYPE_CDMA:{
             rilCellIdentity.cellIdentityCdma.basestationId =
                     convertResponseStringEntryToInt(response, 4, numStrings);
-            rilCellIdentity.cellIdentityCdma.longitude =
-                    convertResponseStringEntryToInt(response, 5, numStrings);
+            /* Order of Lat. and Long. swapped between RIL and HIDL interface versions. */
             rilCellIdentity.cellIdentityCdma.latitude =
+                    convertResponseStringEntryToInt(response, 5, numStrings);
+            rilCellIdentity.cellIdentityCdma.longitude =
                     convertResponseStringEntryToInt(response, 6, numStrings);
             rilCellIdentity.cellIdentityCdma.systemId =
                     convertResponseStringEntryToInt(response, 8, numStrings);
@@ -3080,11 +3588,7 @@ void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
         int numStrings, char** response) {
 
     RIL_CellIdentity_v16 rilCellIdentity;
-    int32_t *tmp = (int32_t*)&rilCellIdentity;
-
-    for (size_t i = 0; i < sizeof(RIL_CellIdentity_v16)/sizeof(int32_t); i++) {
-        tmp[i] = -1;
-    }
+    memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
 
     rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
     switch(rilCellIdentity.cellInfoType) {
@@ -3129,7 +3633,9 @@ void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
 int radio::getVoiceRegistrationStateResponse(int slotId,
                                             int responseType, int serial, RIL_Errno e,
                                             void *response, size_t responseLen) {
+#if VDBG
     RLOGD("getVoiceRegistrationStateResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3191,7 +3697,9 @@ int radio::getVoiceRegistrationStateResponse(int slotId,
 int radio::getDataRegistrationStateResponse(int slotId,
                                            int responseType, int serial, RIL_Errno e,
                                            void *response, size_t responseLen) {
+#if VDBG
     RLOGD("getDataRegistrationStateResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3245,7 +3753,9 @@ int radio::getDataRegistrationStateResponse(int slotId,
 int radio::getOperatorResponse(int slotId,
                               int responseType, int serial, RIL_Errno e, void *response,
                               size_t responseLen) {
+#if VDBG
     RLOGD("getOperatorResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3297,7 +3807,9 @@ int radio::setRadioPowerResponse(int slotId,
 int radio::sendDtmfResponse(int slotId,
                            int responseType, int serial, RIL_Errno e, void *response,
                            size_t responseLen) {
+#if VDBG
     RLOGD("sendDtmfResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3334,7 +3846,9 @@ SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int
 int radio::sendSmsResponse(int slotId,
                           int responseType, int serial, RIL_Errno e, void *response,
                           size_t responseLen) {
+#if VDBG
     RLOGD("sendSmsResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3354,7 +3868,9 @@ int radio::sendSmsResponse(int slotId,
 int radio::sendSMSExpectMoreResponse(int slotId,
                                     int responseType, int serial, RIL_Errno e, void *response,
                                     size_t responseLen) {
+#if VDBG
     RLOGD("sendSMSExpectMoreResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3374,7 +3890,9 @@ int radio::sendSMSExpectMoreResponse(int slotId,
 int radio::setupDataCallResponse(int slotId,
                                  int responseType, int serial, RIL_Errno e, void *response,
                                  size_t responseLen) {
+#if VDBG
     RLOGD("setupDataCallResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3426,7 +3944,9 @@ IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int respo
 int radio::iccIOForAppResponse(int slotId,
                       int responseType, int serial, RIL_Errno e, void *response,
                       size_t responseLen) {
+#if VDBG
     RLOGD("iccIOForAppResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3446,7 +3966,9 @@ int radio::iccIOForAppResponse(int slotId,
 int radio::sendUssdResponse(int slotId,
                            int responseType, int serial, RIL_Errno e, void *response,
                            size_t responseLen) {
+#if VDBG
     RLOGD("sendUssdResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3465,7 +3987,9 @@ int radio::sendUssdResponse(int slotId,
 int radio::cancelPendingUssdResponse(int slotId,
                                     int responseType, int serial, RIL_Errno e, void *response,
                                     size_t responseLen) {
+#if VDBG
     RLOGD("cancelPendingUssdResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3484,7 +4008,9 @@ int radio::cancelPendingUssdResponse(int slotId,
 int radio::getClirResponse(int slotId,
                               int responseType, int serial, RIL_Errno e, void *response,
                               size_t responseLen) {
+#if VDBG
     RLOGD("getClirResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3512,7 +4038,9 @@ int radio::getClirResponse(int slotId,
 int radio::setClirResponse(int slotId,
                           int responseType, int serial, RIL_Errno e, void *response,
                           size_t responseLen) {
+#if VDBG
     RLOGD("setClirResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3530,7 +4058,9 @@ int radio::setClirResponse(int slotId,
 int radio::getCallForwardStatusResponse(int slotId,
                                        int responseType, int serial, RIL_Errno e,
                                        void *response, size_t responseLen) {
+#if VDBG
     RLOGD("getCallForwardStatusResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3568,7 +4098,9 @@ int radio::getCallForwardStatusResponse(int slotId,
 int radio::setCallForwardResponse(int slotId,
                                  int responseType, int serial, RIL_Errno e, void *response,
                                  size_t responseLen) {
+#if VDBG
     RLOGD("setCallForwardResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3586,7 +4118,9 @@ int radio::setCallForwardResponse(int slotId,
 int radio::getCallWaitingResponse(int slotId,
                                  int responseType, int serial, RIL_Errno e, void *response,
                                  size_t responseLen) {
+#if VDBG
     RLOGD("getCallWaitingResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3615,7 +4149,9 @@ int radio::getCallWaitingResponse(int slotId,
 int radio::setCallWaitingResponse(int slotId,
                                  int responseType, int serial, RIL_Errno e, void *response,
                                  size_t responseLen) {
+#if VDBG
     RLOGD("setCallWaitingResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3633,7 +4169,9 @@ int radio::setCallWaitingResponse(int slotId,
 int radio::acknowledgeLastIncomingGsmSmsResponse(int slotId,
                                                 int responseType, int serial, RIL_Errno e,
                                                 void *response, size_t responseLen) {
+#if VDBG
     RLOGD("acknowledgeLastIncomingGsmSmsResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3653,7 +4191,9 @@ int radio::acknowledgeLastIncomingGsmSmsResponse(int slotId,
 int radio::acceptCallResponse(int slotId,
                              int responseType, int serial, RIL_Errno e,
                              void *response, size_t responseLen) {
+#if VDBG
     RLOGD("acceptCallResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3672,7 +4212,9 @@ int radio::acceptCallResponse(int slotId,
 int radio::deactivateDataCallResponse(int slotId,
                                                 int responseType, int serial, RIL_Errno e,
                                                 void *response, size_t responseLen) {
+#if VDBG
     RLOGD("deactivateDataCallResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3691,7 +4233,9 @@ int radio::deactivateDataCallResponse(int slotId,
 int radio::getFacilityLockForAppResponse(int slotId,
                                         int responseType, int serial, RIL_Errno e,
                                         void *response, size_t responseLen) {
+#if VDBG
     RLOGD("getFacilityLockForAppResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3710,11 +4254,13 @@ int radio::getFacilityLockForAppResponse(int slotId,
 int radio::setFacilityLockForAppResponse(int slotId,
                                       int responseType, int serial, RIL_Errno e,
                                       void *response, size_t responseLen) {
+#if VDBG
     RLOGD("setFacilityLockForAppResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
-        int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
+        int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
         Return<void> retStatus
                 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo,
                 ret);
@@ -3730,7 +4276,9 @@ int radio::setFacilityLockForAppResponse(int slotId,
 int radio::setBarringPasswordResponse(int slotId,
                              int responseType, int serial, RIL_Errno e,
                              void *response, size_t responseLen) {
+#if VDBG
     RLOGD("acceptCallResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3749,7 +4297,9 @@ int radio::setBarringPasswordResponse(int slotId,
 int radio::getNetworkSelectionModeResponse(int slotId,
                                           int responseType, int serial, RIL_Errno e, void *response,
                                           size_t responseLen) {
+#if VDBG
     RLOGD("getNetworkSelectionModeResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3779,7 +4329,9 @@ int radio::getNetworkSelectionModeResponse(int slotId,
 int radio::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType, int serial,
                                                     RIL_Errno e, void *response,
                                                     size_t responseLen) {
+#if VDBG
     RLOGD("setNetworkSelectionModeAutomaticResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3799,7 +4351,9 @@ int radio::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType
 int radio::setNetworkSelectionModeManualResponse(int slotId,
                              int responseType, int serial, RIL_Errno e,
                              void *response, size_t responseLen) {
+#if VDBG
     RLOGD("setNetworkSelectionModeManualResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3833,7 +4387,9 @@ int convertOperatorStatusToInt(const char *str) {
 int radio::getAvailableNetworksResponse(int slotId,
                               int responseType, int serial, RIL_Errno e, void *response,
                               size_t responseLen) {
+#if VDBG
     RLOGD("getAvailableNetworksResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3873,7 +4429,9 @@ int radio::getAvailableNetworksResponse(int slotId,
 int radio::startDtmfResponse(int slotId,
                             int responseType, int serial, RIL_Errno e,
                             void *response, size_t responseLen) {
+#if VDBG
     RLOGD("startDtmfResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3891,7 +4449,9 @@ int radio::startDtmfResponse(int slotId,
 int radio::stopDtmfResponse(int slotId,
                            int responseType, int serial, RIL_Errno e,
                            void *response, size_t responseLen) {
+#if VDBG
     RLOGD("stopDtmfResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3909,7 +4469,9 @@ int radio::stopDtmfResponse(int slotId,
 int radio::getBasebandVersionResponse(int slotId,
                                      int responseType, int serial, RIL_Errno e,
                                      void *response, size_t responseLen) {
+#if VDBG
     RLOGD("getBasebandVersionResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3928,7 +4490,9 @@ int radio::getBasebandVersionResponse(int slotId,
 int radio::separateConnectionResponse(int slotId,
                                      int responseType, int serial, RIL_Errno e,
                                      void *response, size_t responseLen) {
+#if VDBG
     RLOGD("separateConnectionResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3947,7 +4511,9 @@ int radio::separateConnectionResponse(int slotId,
 int radio::setMuteResponse(int slotId,
                           int responseType, int serial, RIL_Errno e,
                           void *response, size_t responseLen) {
+#if VDBG
     RLOGD("setMuteResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3965,7 +4531,9 @@ int radio::setMuteResponse(int slotId,
 int radio::getMuteResponse(int slotId,
                           int responseType, int serial, RIL_Errno e, void *response,
                           size_t responseLen) {
+#if VDBG
     RLOGD("getMuteResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -3992,7 +4560,9 @@ int radio::getMuteResponse(int slotId,
 int radio::getClipResponse(int slotId,
                           int responseType, int serial, RIL_Errno e,
                           void *response, size_t responseLen) {
+#if VDBG
     RLOGD("getClipResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4010,7 +4580,9 @@ int radio::getClipResponse(int slotId,
 int radio::getDataCallListResponse(int slotId,
                                    int responseType, int serial, RIL_Errno e,
                                    void *response, size_t responseLen) {
+#if VDBG
     RLOGD("getDataCallListResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4037,7 +4609,9 @@ int radio::getDataCallListResponse(int slotId,
 int radio::setSuppServiceNotificationsResponse(int slotId,
                                               int responseType, int serial, RIL_Errno e,
                                               void *response, size_t responseLen) {
+#if VDBG
     RLOGD("setSuppServiceNotificationsResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4057,7 +4631,9 @@ int radio::setSuppServiceNotificationsResponse(int slotId,
 int radio::deleteSmsOnSimResponse(int slotId,
                                  int responseType, int serial, RIL_Errno e,
                                  void *response, size_t responseLen) {
+#if VDBG
     RLOGD("deleteSmsOnSimResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4075,7 +4651,9 @@ int radio::deleteSmsOnSimResponse(int slotId,
 int radio::setBandModeResponse(int slotId,
                               int responseType, int serial, RIL_Errno e,
                               void *response, size_t responseLen) {
+#if VDBG
     RLOGD("setBandModeResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4093,7 +4671,9 @@ int radio::setBandModeResponse(int slotId,
 int radio::writeSmsToSimResponse(int slotId,
                                 int responseType, int serial, RIL_Errno e,
                                 void *response, size_t responseLen) {
+#if VDBG
     RLOGD("writeSmsToSimResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4111,7 +4691,9 @@ int radio::writeSmsToSimResponse(int slotId,
 int radio::getAvailableBandModesResponse(int slotId,
                                         int responseType, int serial, RIL_Errno e, void *response,
                                         size_t responseLen) {
+#if VDBG
     RLOGD("getAvailableBandModesResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4143,7 +4725,9 @@ int radio::getAvailableBandModesResponse(int slotId,
 int radio::sendEnvelopeResponse(int slotId,
                                int responseType, int serial, RIL_Errno e,
                                void *response, size_t responseLen) {
+#if VDBG
     RLOGD("sendEnvelopeResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4162,7 +4746,9 @@ int radio::sendEnvelopeResponse(int slotId,
 int radio::sendTerminalResponseToSimResponse(int slotId,
                                             int responseType, int serial, RIL_Errno e,
                                             void *response, size_t responseLen) {
+#if VDBG
     RLOGD("sendTerminalResponseToSimResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4183,7 +4769,9 @@ int radio::handleStkCallSetupRequestFromSimResponse(int slotId,
                                                    int responseType, int serial,
                                                    RIL_Errno e, void *response,
                                                    size_t responseLen) {
+#if VDBG
     RLOGD("handleStkCallSetupRequestFromSimResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4203,7 +4791,9 @@ int radio::handleStkCallSetupRequestFromSimResponse(int slotId,
 int radio::explicitCallTransferResponse(int slotId,
                                        int responseType, int serial, RIL_Errno e,
                                        void *response, size_t responseLen) {
+#if VDBG
     RLOGD("explicitCallTransferResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4222,7 +4812,9 @@ int radio::explicitCallTransferResponse(int slotId,
 int radio::setPreferredNetworkTypeResponse(int slotId,
                                  int responseType, int serial, RIL_Errno e,
                                  void *response, size_t responseLen) {
+#if VDBG
     RLOGD("setPreferredNetworkTypeResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4243,7 +4835,9 @@ int radio::setPreferredNetworkTypeResponse(int slotId,
 int radio::getPreferredNetworkTypeResponse(int slotId,
                                           int responseType, int serial, RIL_Errno e,
                                           void *response, size_t responseLen) {
+#if VDBG
     RLOGD("getPreferredNetworkTypeResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4263,7 +4857,9 @@ int radio::getPreferredNetworkTypeResponse(int slotId,
 int radio::getNeighboringCidsResponse(int slotId,
                                      int responseType, int serial, RIL_Errno e,
                                      void *response, size_t responseLen) {
+#if VDBG
     RLOGD("getNeighboringCidsResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4298,7 +4894,9 @@ int radio::getNeighboringCidsResponse(int slotId,
 int radio::setLocationUpdatesResponse(int slotId,
                                      int responseType, int serial, RIL_Errno e,
                                      void *response, size_t responseLen) {
+#if VDBG
     RLOGD("setLocationUpdatesResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4317,7 +4915,9 @@ int radio::setLocationUpdatesResponse(int slotId,
 int radio::setCdmaSubscriptionSourceResponse(int slotId,
                                  int responseType, int serial, RIL_Errno e,
                                  void *response, size_t responseLen) {
+#if VDBG
     RLOGD("setCdmaSubscriptionSourceResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4337,7 +4937,9 @@ int radio::setCdmaSubscriptionSourceResponse(int slotId,
 int radio::setCdmaRoamingPreferenceResponse(int slotId,
                                  int responseType, int serial, RIL_Errno e,
                                  void *response, size_t responseLen) {
+#if VDBG
     RLOGD("setCdmaRoamingPreferenceResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4357,7 +4959,9 @@ int radio::setCdmaRoamingPreferenceResponse(int slotId,
 int radio::getCdmaRoamingPreferenceResponse(int slotId,
                                            int responseType, int serial, RIL_Errno e,
                                            void *response, size_t responseLen) {
+#if VDBG
     RLOGD("getCdmaRoamingPreferenceResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4377,7 +4981,9 @@ int radio::getCdmaRoamingPreferenceResponse(int slotId,
 int radio::setTTYModeResponse(int slotId,
                              int responseType, int serial, RIL_Errno e,
                              void *response, size_t responseLen) {
+#if VDBG
     RLOGD("setTTYModeResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4395,7 +5001,9 @@ int radio::setTTYModeResponse(int slotId,
 int radio::getTTYModeResponse(int slotId,
                              int responseType, int serial, RIL_Errno e,
                              void *response, size_t responseLen) {
+#if VDBG
     RLOGD("getTTYModeResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4414,7 +5022,9 @@ int radio::getTTYModeResponse(int slotId,
 int radio::setPreferredVoicePrivacyResponse(int slotId,
                                  int responseType, int serial, RIL_Errno e,
                                  void *response, size_t responseLen) {
+#if VDBG
     RLOGD("setPreferredVoicePrivacyResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4434,7 +5044,9 @@ int radio::setPreferredVoicePrivacyResponse(int slotId,
 int radio::getPreferredVoicePrivacyResponse(int slotId,
                                            int responseType, int serial, RIL_Errno e,
                                            void *response, size_t responseLen) {
+#if VDBG
     RLOGD("getPreferredVoicePrivacyResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4463,7 +5075,9 @@ int radio::getPreferredVoicePrivacyResponse(int slotId,
 int radio::sendCDMAFeatureCodeResponse(int slotId,
                                  int responseType, int serial, RIL_Errno e,
                                  void *response, size_t responseLen) {
+#if VDBG
     RLOGD("sendCDMAFeatureCodeResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4482,7 +5096,9 @@ int radio::sendCDMAFeatureCodeResponse(int slotId,
 int radio::sendBurstDtmfResponse(int slotId,
                                  int responseType, int serial, RIL_Errno e,
                                  void *response, size_t responseLen) {
+#if VDBG
     RLOGD("sendBurstDtmfResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4500,7 +5116,9 @@ int radio::sendBurstDtmfResponse(int slotId,
 int radio::sendCdmaSmsResponse(int slotId,
                               int responseType, int serial, RIL_Errno e, void *response,
                               size_t responseLen) {
+#if VDBG
     RLOGD("sendCdmaSmsResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4520,7 +5138,9 @@ int radio::sendCdmaSmsResponse(int slotId,
 int radio::acknowledgeLastIncomingCdmaSmsResponse(int slotId,
                                                  int responseType, int serial, RIL_Errno e,
                                                  void *response, size_t responseLen) {
+#if VDBG
     RLOGD("acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4540,7 +5160,9 @@ int radio::acknowledgeLastIncomingCdmaSmsResponse(int slotId,
 int radio::getGsmBroadcastConfigResponse(int slotId,
                                         int responseType, int serial, RIL_Errno e,
                                         void *response, size_t responseLen) {
+#if VDBG
     RLOGD("getGsmBroadcastConfigResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4579,7 +5201,9 @@ int radio::getGsmBroadcastConfigResponse(int slotId,
 int radio::setGsmBroadcastConfigResponse(int slotId,
                                         int responseType, int serial, RIL_Errno e,
                                         void *response, size_t responseLen) {
+#if VDBG
     RLOGD("setGsmBroadcastConfigResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4598,7 +5222,9 @@ int radio::setGsmBroadcastConfigResponse(int slotId,
 int radio::setGsmBroadcastActivationResponse(int slotId,
                                             int responseType, int serial, RIL_Errno e,
                                             void *response, size_t responseLen) {
+#if VDBG
     RLOGD("setGsmBroadcastActivationResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4618,7 +5244,9 @@ int radio::setGsmBroadcastActivationResponse(int slotId,
 int radio::getCdmaBroadcastConfigResponse(int slotId,
                                          int responseType, int serial, RIL_Errno e,
                                          void *response, size_t responseLen) {
+#if VDBG
     RLOGD("getCdmaBroadcastConfigResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4655,7 +5283,9 @@ int radio::getCdmaBroadcastConfigResponse(int slotId,
 int radio::setCdmaBroadcastConfigResponse(int slotId,
                                          int responseType, int serial, RIL_Errno e,
                                          void *response, size_t responseLen) {
+#if VDBG
     RLOGD("setCdmaBroadcastConfigResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4675,7 +5305,9 @@ int radio::setCdmaBroadcastConfigResponse(int slotId,
 int radio::setCdmaBroadcastActivationResponse(int slotId,
                                              int responseType, int serial, RIL_Errno e,
                                              void *response, size_t responseLen) {
+#if VDBG
     RLOGD("setCdmaBroadcastActivationResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4695,7 +5327,9 @@ int radio::setCdmaBroadcastActivationResponse(int slotId,
 int radio::getCDMASubscriptionResponse(int slotId,
                                       int responseType, int serial, RIL_Errno e, void *response,
                                       size_t responseLen) {
+#if VDBG
     RLOGD("getCDMASubscriptionResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4733,7 +5367,9 @@ int radio::getCDMASubscriptionResponse(int slotId,
 int radio::writeSmsToRuimResponse(int slotId,
                                  int responseType, int serial, RIL_Errno e,
                                  void *response, size_t responseLen) {
+#if VDBG
     RLOGD("writeSmsToRuimResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4751,7 +5387,9 @@ int radio::writeSmsToRuimResponse(int slotId,
 int radio::deleteSmsOnRuimResponse(int slotId,
                                   int responseType, int serial, RIL_Errno e,
                                   void *response, size_t responseLen) {
+#if VDBG
     RLOGD("deleteSmsOnRuimResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4769,7 +5407,9 @@ int radio::deleteSmsOnRuimResponse(int slotId,
 int radio::getDeviceIdentityResponse(int slotId,
                                     int responseType, int serial, RIL_Errno e, void *response,
                                     size_t responseLen) {
+#if VDBG
     RLOGD("getDeviceIdentityResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4805,7 +5445,9 @@ int radio::getDeviceIdentityResponse(int slotId,
 int radio::exitEmergencyCallbackModeResponse(int slotId,
                                             int responseType, int serial, RIL_Errno e,
                                             void *response, size_t responseLen) {
+#if VDBG
     RLOGD("exitEmergencyCallbackModeResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4825,7 +5467,9 @@ int radio::exitEmergencyCallbackModeResponse(int slotId,
 int radio::getSmscAddressResponse(int slotId,
                                   int responseType, int serial, RIL_Errno e,
                                   void *response, size_t responseLen) {
+#if VDBG
     RLOGD("getSmscAddressResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4844,7 +5488,9 @@ int radio::getSmscAddressResponse(int slotId,
 int radio::setSmscAddressResponse(int slotId,
                                              int responseType, int serial, RIL_Errno e,
                                              void *response, size_t responseLen) {
+#if VDBG
     RLOGD("setSmscAddressResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4862,7 +5508,9 @@ int radio::setSmscAddressResponse(int slotId,
 int radio::reportSmsMemoryStatusResponse(int slotId,
                                         int responseType, int serial, RIL_Errno e,
                                         void *response, size_t responseLen) {
+#if VDBG
     RLOGD("reportSmsMemoryStatusResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4881,7 +5529,9 @@ int radio::reportSmsMemoryStatusResponse(int slotId,
 int radio::reportStkServiceIsRunningResponse(int slotId,
                                              int responseType, int serial, RIL_Errno e,
                                              void *response, size_t responseLen) {
+#if VDBG
     RLOGD("reportStkServiceIsRunningResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4900,7 +5550,9 @@ int radio::reportStkServiceIsRunningResponse(int slotId,
 int radio::getCdmaSubscriptionSourceResponse(int slotId,
                                             int responseType, int serial, RIL_Errno e,
                                             void *response, size_t responseLen) {
+#if VDBG
     RLOGD("getCdmaSubscriptionSourceResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4920,7 +5572,9 @@ int radio::getCdmaSubscriptionSourceResponse(int slotId,
 int radio::requestIsimAuthenticationResponse(int slotId,
                                             int responseType, int serial, RIL_Errno e,
                                             void *response, size_t responseLen) {
+#if VDBG
     RLOGD("requestIsimAuthenticationResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4942,7 +5596,9 @@ int radio::acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
                                                    int responseType,
                                                    int serial, RIL_Errno e, void *response,
                                                    size_t responseLen) {
+#if VDBG
     RLOGD("acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4962,7 +5618,9 @@ int radio::acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
 int radio::sendEnvelopeWithStatusResponse(int slotId,
                                          int responseType, int serial, RIL_Errno e, void *response,
                                          size_t responseLen) {
+#if VDBG
     RLOGD("sendEnvelopeWithStatusResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -4984,7 +5642,9 @@ int radio::sendEnvelopeWithStatusResponse(int slotId,
 int radio::getVoiceRadioTechnologyResponse(int slotId,
                                           int responseType, int serial, RIL_Errno e,
                                           void *response, size_t responseLen) {
+#if VDBG
     RLOGD("getVoiceRadioTechnologyResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5005,7 +5665,9 @@ int radio::getCellInfoListResponse(int slotId,
                                    int responseType,
                                    int serial, RIL_Errno e, void *response,
                                    size_t responseLen) {
+#if VDBG
     RLOGD("getCellInfoListResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5033,7 +5695,9 @@ int radio::setCellInfoListRateResponse(int slotId,
                                        int responseType,
                                        int serial, RIL_Errno e, void *response,
                                        size_t responseLen) {
+#if VDBG
     RLOGD("setCellInfoListRateResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5052,7 +5716,9 @@ int radio::setCellInfoListRateResponse(int slotId,
 int radio::setInitialAttachApnResponse(int slotId,
                                        int responseType, int serial, RIL_Errno e,
                                        void *response, size_t responseLen) {
+#if VDBG
     RLOGD("setInitialAttachApnResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5071,7 +5737,9 @@ int radio::setInitialAttachApnResponse(int slotId,
 int radio::getImsRegistrationStateResponse(int slotId,
                                            int responseType, int serial, RIL_Errno e,
                                            void *response, size_t responseLen) {
+#if VDBG
     RLOGD("getImsRegistrationStateResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5102,7 +5770,9 @@ int radio::getImsRegistrationStateResponse(int slotId,
 int radio::sendImsSmsResponse(int slotId,
                               int responseType, int serial, RIL_Errno e, void *response,
                               size_t responseLen) {
+#if VDBG
     RLOGD("sendImsSmsResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5122,7 +5792,9 @@ int radio::sendImsSmsResponse(int slotId,
 int radio::iccTransmitApduBasicChannelResponse(int slotId,
                                                int responseType, int serial, RIL_Errno e,
                                                void *response, size_t responseLen) {
+#if VDBG
     RLOGD("iccTransmitApduBasicChannelResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5144,7 +5816,9 @@ int radio::iccTransmitApduBasicChannelResponse(int slotId,
 int radio::iccOpenLogicalChannelResponse(int slotId,
                                          int responseType, int serial, RIL_Errno e, void *response,
                                          size_t responseLen) {
+#if VDBG
     RLOGD("iccOpenLogicalChannelResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5178,7 +5852,9 @@ int radio::iccOpenLogicalChannelResponse(int slotId,
 int radio::iccCloseLogicalChannelResponse(int slotId,
                                           int responseType, int serial, RIL_Errno e,
                                           void *response, size_t responseLen) {
+#if VDBG
     RLOGD("iccCloseLogicalChannelResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5198,7 +5874,9 @@ int radio::iccCloseLogicalChannelResponse(int slotId,
 int radio::iccTransmitApduLogicalChannelResponse(int slotId,
                                                  int responseType, int serial, RIL_Errno e,
                                                  void *response, size_t responseLen) {
+#if VDBG
     RLOGD("iccTransmitApduLogicalChannelResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5220,7 +5898,9 @@ int radio::iccTransmitApduLogicalChannelResponse(int slotId,
 int radio::nvReadItemResponse(int slotId,
                               int responseType, int serial, RIL_Errno e,
                               void *response, size_t responseLen) {
+#if VDBG
     RLOGD("nvReadItemResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5239,7 +5919,9 @@ int radio::nvReadItemResponse(int slotId,
 int radio::nvWriteItemResponse(int slotId,
                                int responseType, int serial, RIL_Errno e,
                                void *response, size_t responseLen) {
+#if VDBG
     RLOGD("nvWriteItemResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5257,7 +5939,9 @@ int radio::nvWriteItemResponse(int slotId,
 int radio::nvWriteCdmaPrlResponse(int slotId,
                                   int responseType, int serial, RIL_Errno e,
                                   void *response, size_t responseLen) {
+#if VDBG
     RLOGD("nvWriteCdmaPrlResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5275,7 +5959,9 @@ int radio::nvWriteCdmaPrlResponse(int slotId,
 int radio::nvResetConfigResponse(int slotId,
                                  int responseType, int serial, RIL_Errno e,
                                  void *response, size_t responseLen) {
+#if VDBG
     RLOGD("nvResetConfigResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5293,7 +5979,9 @@ int radio::nvResetConfigResponse(int slotId,
 int radio::setUiccSubscriptionResponse(int slotId,
                                        int responseType, int serial, RIL_Errno e,
                                        void *response, size_t responseLen) {
+#if VDBG
     RLOGD("setUiccSubscriptionResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5312,7 +6000,9 @@ int radio::setUiccSubscriptionResponse(int slotId,
 int radio::setDataAllowedResponse(int slotId,
                                   int responseType, int serial, RIL_Errno e,
                                   void *response, size_t responseLen) {
+#if VDBG
     RLOGD("setDataAllowedResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5330,7 +6020,9 @@ int radio::setDataAllowedResponse(int slotId,
 int radio::getHardwareConfigResponse(int slotId,
                                      int responseType, int serial, RIL_Errno e,
                                      void *response, size_t responseLen) {
+#if VDBG
     RLOGD("getHardwareConfigResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5357,7 +6049,9 @@ int radio::getHardwareConfigResponse(int slotId,
 int radio::requestIccSimAuthenticationResponse(int slotId,
                                                int responseType, int serial, RIL_Errno e,
                                                void *response, size_t responseLen) {
+#if VDBG
     RLOGD("requestIccSimAuthenticationResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5379,7 +6073,9 @@ int radio::requestIccSimAuthenticationResponse(int slotId,
 int radio::setDataProfileResponse(int slotId,
                                   int responseType, int serial, RIL_Errno e,
                                   void *response, size_t responseLen) {
+#if VDBG
     RLOGD("setDataProfileResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5397,7 +6093,9 @@ int radio::setDataProfileResponse(int slotId,
 int radio::requestShutdownResponse(int slotId,
                                   int responseType, int serial, RIL_Errno e,
                                   void *response, size_t responseLen) {
+#if VDBG
     RLOGD("requestShutdownResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5428,7 +6126,9 @@ void responseRadioCapability(RadioResponseInfo& responseInfo, int serial,
 int radio::getRadioCapabilityResponse(int slotId,
                                      int responseType, int serial, RIL_Errno e,
                                      void *response, size_t responseLen) {
+#if VDBG
     RLOGD("getRadioCapabilityResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5448,7 +6148,9 @@ int radio::getRadioCapabilityResponse(int slotId,
 int radio::setRadioCapabilityResponse(int slotId,
                                      int responseType, int serial, RIL_Errno e,
                                      void *response, size_t responseLen) {
+#if VDBG
     RLOGD("setRadioCapabilityResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5484,7 +6186,9 @@ LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial,
 int radio::startLceServiceResponse(int slotId,
                                    int responseType, int serial, RIL_Errno e,
                                    void *response, size_t responseLen) {
+#if VDBG
     RLOGD("startLceServiceResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5505,7 +6209,9 @@ int radio::startLceServiceResponse(int slotId,
 int radio::stopLceServiceResponse(int slotId,
                                   int responseType, int serial, RIL_Errno e,
                                   void *response, size_t responseLen) {
+#if VDBG
     RLOGD("stopLceServiceResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5526,7 +6232,9 @@ int radio::stopLceServiceResponse(int slotId,
 int radio::pullLceDataResponse(int slotId,
                                int responseType, int serial, RIL_Errno e,
                                void *response, size_t responseLen) {
+#if VDBG
     RLOGD("pullLceDataResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5553,7 +6261,9 @@ int radio::pullLceDataResponse(int slotId,
 int radio::getModemActivityInfoResponse(int slotId,
                                         int responseType, int serial, RIL_Errno e,
                                         void *response, size_t responseLen) {
+#if VDBG
     RLOGD("getModemActivityInfoResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5587,7 +6297,9 @@ int radio::getModemActivityInfoResponse(int slotId,
 int radio::setAllowedCarriersResponse(int slotId,
                                       int responseType, int serial, RIL_Errno e,
                                       void *response, size_t responseLen) {
+#if VDBG
     RLOGD("setAllowedCarriersResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5607,15 +6319,23 @@ int radio::setAllowedCarriersResponse(int slotId,
 int radio::getAllowedCarriersResponse(int slotId,
                                       int responseType, int serial, RIL_Errno e,
                                       void *response, size_t responseLen) {
+#if VDBG
     RLOGD("getAllowedCarriersResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
         populateResponseInfo(responseInfo, serial, responseType, e);
         CarrierRestrictions carrierInfo = {};
         bool allAllowed = true;
-        if (response == NULL || responseLen != sizeof(RIL_CarrierRestrictions)) {
-            RLOGE("getAllowedCarriersResponse Invalid response: NULL");
+        if (response == NULL) {
+#if VDBG
+            RLOGD("getAllowedCarriersResponse response is NULL: all allowed");
+#endif
+            carrierInfo.allowedCarriers.resize(0);
+            carrierInfo.excludedCarriers.resize(0);
+        } else if (responseLen != sizeof(RIL_CarrierRestrictions)) {
+            RLOGE("getAllowedCarriersResponse Invalid response");
             if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
         } else {
             RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response;
@@ -5659,7 +6379,9 @@ int radio::getAllowedCarriersResponse(int slotId,
 int radio::sendDeviceStateResponse(int slotId,
                               int responseType, int serial, RIL_Errno e,
                               void *response, size_t responselen) {
+#if VDBG
     RLOGD("sendDeviceStateResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5674,10 +6396,38 @@ int radio::sendDeviceStateResponse(int slotId,
     return 0;
 }
 
+int radio::setCarrierInfoForImsiEncryptionResponse(int slotId,
+                               int responseType, int serial, RIL_Errno e,
+                               void *response, size_t responseLen) {
+    RLOGD("setCarrierInfoForImsiEncryptionResponse: serial %d", serial);
+    if (radioService[slotId]->mRadioResponse != NULL) {
+        RadioResponseInfo responseInfo = {};
+        populateResponseInfo(responseInfo, serial, responseType, e);
+        Return<sp<::android::hardware::radio::V1_1::IRadioResponse>> ret =
+            ::android::hardware::radio::V1_1::IRadioResponse::castFrom(
+            radioService[slotId]->mRadioResponse);
+        if (ret.isOk()) {
+            sp<::android::hardware::radio::V1_1::IRadioResponse> radioResponseV1_1 = ret;
+            Return<void> retStatus
+                   = radioResponseV1_1->setCarrierInfoForImsiEncryptionResponse(responseInfo);
+            radioService[slotId]->checkReturnStatus(retStatus);
+        } else {
+            RLOGE("setCarrierInfoForImsiEncryptionResponse: ret.isOk() == false for "
+                    "radioService[%d]" , slotId);
+        }
+    } else {
+        RLOGE("setCarrierInfoForImsiEncryptionResponse: radioService[%d]->mRadioResponse == NULL",
+                slotId);
+    }
+    return 0;
+}
+
 int radio::setIndicationFilterResponse(int slotId,
                               int responseType, int serial, RIL_Errno e,
                               void *response, size_t responselen) {
+#if VDBG
     RLOGD("setIndicationFilterResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5693,20 +6443,85 @@ int radio::setIndicationFilterResponse(int slotId,
     return 0;
 }
 
-
 int radio::setSimCardPowerResponse(int slotId,
                                    int responseType, int serial, RIL_Errno e,
                                    void *response, size_t responseLen) {
+#if VDBG
     RLOGD("setSimCardPowerResponse: serial %d", serial);
+#endif
 
     if (radioService[slotId]->mRadioResponse != NULL) {
         RadioResponseInfo responseInfo = {};
         populateResponseInfo(responseInfo, serial, responseType, e);
-        Return<void> retStatus
-                = radioService[slotId]->mRadioResponse->setSimCardPowerResponse(responseInfo);
-        radioService[slotId]->checkReturnStatus(retStatus);
+        Return<sp<::android::hardware::radio::V1_1::IRadioResponse>> ret =
+            ::android::hardware::radio::V1_1::IRadioResponse::castFrom(
+            radioService[slotId]->mRadioResponse);
+        if (ret.isOk()) {
+            sp<::android::hardware::radio::V1_1::IRadioResponse> radioResponseV1_1 = ret;
+            Return<void> retStatus
+                   = radioResponseV1_1->setSimCardPowerResponse_1_1(responseInfo);
+            radioService[slotId]->checkReturnStatus(retStatus);
+        } else {
+            RLOGD("setSimCardPowerResponse: ret.isOK() == false for radioService[%d]",
+                    slotId);
+            Return<void> retStatus
+                    = radioService[slotId]->mRadioResponse->setSimCardPowerResponse(responseInfo);
+            radioService[slotId]->checkReturnStatus(retStatus);
+        }
+    } else {
+        RLOGE("setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL",
+                slotId);
+    }
+    return 0;
+}
+
+int radio::startNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
+                                    void *response, size_t responseLen) {
+#if VDBG
+    RLOGD("startNetworkScanResponse: serial %d", serial);
+#endif
+
+    if (radioService[slotId]->mRadioResponse != NULL) {
+        RadioResponseInfo responseInfo = {};
+        populateResponseInfo(responseInfo, serial, responseType, e);
+        Return<sp<::android::hardware::radio::V1_1::IRadioResponse>> ret =
+                ::android::hardware::radio::V1_1::IRadioResponse::castFrom(
+                        radioService[slotId]->mRadioResponse);
+        if (ret.isOk()) {
+            sp<::android::hardware::radio::V1_1::IRadioResponse> radioResponseV1_1 = ret;
+            Return<void> retStatus = radioResponseV1_1->startNetworkScanResponse(responseInfo);
+            radioService[slotId]->checkReturnStatus(retStatus);
+        } else {
+            RLOGD("startNetworkScanResponse: ret.isOK() == false for radioService[%d]", slotId);
+        }
+    } else {
+        RLOGE("startNetworkScanResponse: radioService[%d]->mRadioResponse == NULL", slotId);
+    }
+
+    return 0;
+}
+
+int radio::stopNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
+                                   void *response, size_t responseLen) {
+#if VDBG
+    RLOGD("stopNetworkScanResponse: serial %d", serial);
+#endif
+
+    if (radioService[slotId]->mRadioResponse != NULL) {
+        RadioResponseInfo responseInfo = {};
+        populateResponseInfo(responseInfo, serial, responseType, e);
+        Return<sp<::android::hardware::radio::V1_1::IRadioResponse>> ret =
+                ::android::hardware::radio::V1_1::IRadioResponse::castFrom(
+                        radioService[slotId]->mRadioResponse);
+        if (ret.isOk()) {
+            sp<::android::hardware::radio::V1_1::IRadioResponse> radioResponseV1_1 = ret;
+            Return<void> retStatus = radioResponseV1_1->stopNetworkScanResponse(responseInfo);
+            radioService[slotId]->checkReturnStatus(retStatus);
+        } else {
+            RLOGD("stopNetworkScanResponse: ret.isOK() == false for radioService[%d]", slotId);
+        }
     } else {
-        RLOGE("setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL", slotId);
+        RLOGE("stopNetworkScanResponse: radioService[%d]->mRadioResponse == NULL", slotId);
     }
 
     return 0;
@@ -5715,7 +6530,9 @@ int radio::setSimCardPowerResponse(int slotId,
 int radio::sendRequestRawResponse(int slotId,
                                   int responseType, int serial, RIL_Errno e,
                                   void *response, size_t responseLen) {
+#if VDBG
    RLOGD("sendRequestRawResponse: serial %d", serial);
+#endif
 
     if (oemHookService[slotId]->mOemHookResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5730,7 +6547,7 @@ int radio::sendRequestRawResponse(int slotId,
         }
         Return<void> retStatus = oemHookService[slotId]->mOemHookResponse->
                 sendRequestRawResponse(responseInfo, data);
-        checkReturnStatus(slotId, retStatus);
+        checkReturnStatus(slotId, retStatus, false);
     } else {
         RLOGE("sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL",
                 slotId);
@@ -5742,7 +6559,9 @@ int radio::sendRequestRawResponse(int slotId,
 int radio::sendRequestStringsResponse(int slotId,
                                       int responseType, int serial, RIL_Errno e,
                                       void *response, size_t responseLen) {
+#if VDBG
     RLOGD("sendRequestStringsResponse: serial %d", serial);
+#endif
 
     if (oemHookService[slotId]->mOemHookResponse != NULL) {
         RadioResponseInfo responseInfo = {};
@@ -5763,7 +6582,7 @@ int radio::sendRequestStringsResponse(int slotId,
         Return<void> retStatus
                 = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse(
                 responseInfo, data);
-        checkReturnStatus(slotId, retStatus);
+        checkReturnStatus(slotId, retStatus, false);
     } else {
         RLOGE("sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == "
                 "NULL", slotId);
@@ -5799,7 +6618,9 @@ int radio::callStateChangedInd(int slotId,
                                int indicationType, int token, RIL_Errno e, void *response,
                                size_t responseLen) {
     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
+#if VDBG
         RLOGD("callStateChangedInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
                 convertIntToRadioIndicationType(indicationType));
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -5814,7 +6635,9 @@ int radio::networkStateChangedInd(int slotId,
                                   int indicationType, int token, RIL_Errno e, void *response,
                                   size_t responseLen) {
     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
+#if VDBG
         RLOGD("networkStateChangedInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged(
                 convertIntToRadioIndicationType(indicationType));
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -5878,7 +6701,9 @@ int radio::newSmsInd(int slotId, int indicationType,
 
         hidl_vec<uint8_t> pdu;
         pdu.setToExternal(bytes, responseLen/2);
+#if VDBG
         RLOGD("newSmsInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms(
                 convertIntToRadioIndicationType(indicationType), pdu);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -5907,7 +6732,9 @@ int radio::newSmsStatusReportInd(int slotId,
 
         hidl_vec<uint8_t> pdu;
         pdu.setToExternal(bytes, responseLen/2);
+#if VDBG
         RLOGD("newSmsStatusReportInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport(
                 convertIntToRadioIndicationType(indicationType), pdu);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -5927,7 +6754,9 @@ int radio::newSmsOnSimInd(int slotId, int indicationType,
             return 0;
         }
         int32_t recordNumber = ((int32_t *) response)[0];
+#if VDBG
         RLOGD("newSmsOnSimInd: slotIndex %d", recordNumber);
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim(
                 convertIntToRadioIndicationType(indicationType), recordNumber);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -5949,7 +6778,9 @@ int radio::onUssdInd(int slotId, int indicationType,
         char *mode = strings[0];
         hidl_string msg = convertCharPtrToHidlString(strings[1]);
         UssdModeType modeType = (UssdModeType) atoi(mode);
+#if VDBG
         RLOGD("onUssdInd: mode %s", mode);
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd(
                 convertIntToRadioIndicationType(indicationType), modeType, msg);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -5970,8 +6801,10 @@ int radio::nitzTimeReceivedInd(int slotId,
         }
         hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
         int64_t timeReceived = android::elapsedRealtime();
+#if VDBG
         RLOGD("nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
                 timeReceived);
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived(
                 convertIntToRadioIndicationType(indicationType), nitzTime, timeReceived);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -6038,7 +6871,9 @@ int radio::currentSignalStrengthInd(int slotId,
         SignalStrength signalStrength = {};
         convertRilSignalStrengthToHal(response, responseLen, signalStrength);
 
+#if VDBG
         RLOGD("currentSignalStrengthInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength(
                 convertIntToRadioIndicationType(indicationType), signalStrength);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -6086,7 +6921,9 @@ int radio::dataCallListChangedInd(int slotId,
         }
         hidl_vec<SetupDataCallResult> dcList;
         convertRilDataCallListToHal(response, responseLen, dcList);
+#if VDBG
         RLOGD("dataCallListChangedInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged(
                 convertIntToRadioIndicationType(indicationType), dcList);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -6113,8 +6950,10 @@ int radio::suppSvcNotifyInd(int slotId, int indicationType,
         suppSvc.type = ssn->type;
         suppSvc.number = convertCharPtrToHidlString(ssn->number);
 
+#if VDBG
         RLOGD("suppSvcNotifyInd: isMT %d code %d index %d type %d",
                 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type);
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify(
                 convertIntToRadioIndicationType(indicationType), suppSvc);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -6128,7 +6967,9 @@ int radio::suppSvcNotifyInd(int slotId, int indicationType,
 int radio::stkSessionEndInd(int slotId, int indicationType,
                             int token, RIL_Errno e, void *response, size_t responseLen) {
     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
+#if VDBG
         RLOGD("stkSessionEndInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
                 convertIntToRadioIndicationType(indicationType));
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -6147,7 +6988,9 @@ int radio::stkProactiveCommandInd(int slotId,
             RLOGE("stkProactiveCommandInd: invalid response");
             return 0;
         }
+#if VDBG
         RLOGD("stkProactiveCommandInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand(
                 convertIntToRadioIndicationType(indicationType),
                 convertCharPtrToHidlString((char *) response));
@@ -6166,7 +7009,9 @@ int radio::stkEventNotifyInd(int slotId, int indicationType,
             RLOGE("stkEventNotifyInd: invalid response");
             return 0;
         }
+#if VDBG
         RLOGD("stkEventNotifyInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify(
                 convertIntToRadioIndicationType(indicationType),
                 convertCharPtrToHidlString((char *) response));
@@ -6186,7 +7031,9 @@ int radio::stkCallSetupInd(int slotId, int indicationType,
             return 0;
         }
         int32_t timeout = ((int32_t *) response)[0];
+#if VDBG
         RLOGD("stkCallSetupInd: timeout %d", timeout);
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup(
                 convertIntToRadioIndicationType(indicationType), timeout);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -6201,7 +7048,9 @@ int radio::simSmsStorageFullInd(int slotId,
                                 int indicationType, int token, RIL_Errno e, void *response,
                                 size_t responseLen) {
     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
+#if VDBG
         RLOGD("simSmsStorageFullInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
                 convertIntToRadioIndicationType(indicationType));
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -6227,7 +7076,9 @@ int radio::simRefreshInd(int slotId, int indicationType,
         refreshResult.efId = simRefreshResponse->ef_id;
         refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid);
 
+#if VDBG
         RLOGD("simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId);
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh(
                 convertIntToRadioIndicationType(indicationType), refreshResult);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -6262,7 +7113,9 @@ int radio::callRingInd(int slotId, int indicationType,
             convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record);
         }
 
+#if VDBG
         RLOGD("callRingInd: isGsm %d", isGsm);
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing(
                 convertIntToRadioIndicationType(indicationType), isGsm, record);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -6277,7 +7130,9 @@ int radio::simStatusChangedInd(int slotId,
                                int indicationType, int token, RIL_Errno e, void *response,
                                size_t responseLen) {
     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
+#if VDBG
         RLOGD("simStatusChangedInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
                 convertIntToRadioIndicationType(indicationType));
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -6323,7 +7178,9 @@ int radio::cdmaNewSmsInd(int slotId, int indicationType,
         digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
         msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit);
 
+#if VDBG
         RLOGD("cdmaNewSmsInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms(
                 convertIntToRadioIndicationType(indicationType), msg);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -6345,7 +7202,9 @@ int radio::newBroadcastSmsInd(int slotId,
 
         hidl_vec<uint8_t> data;
         data.setToExternal((uint8_t *) response, responseLen);
+#if VDBG
         RLOGD("newBroadcastSmsInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms(
                 convertIntToRadioIndicationType(indicationType), data);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -6360,7 +7219,9 @@ int radio::cdmaRuimSmsStorageFullInd(int slotId,
                                      int indicationType, int token, RIL_Errno e, void *response,
                                      size_t responseLen) {
     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
+#if VDBG
         RLOGD("cdmaRuimSmsStorageFullInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
                 convertIntToRadioIndicationType(indicationType));
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -6381,7 +7242,9 @@ int radio::restrictedStateChangedInd(int slotId,
             return 0;
         }
         int32_t state = ((int32_t *) response)[0];
+#if VDBG
         RLOGD("restrictedStateChangedInd: state %d", state);
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged(
                 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -6397,7 +7260,9 @@ int radio::enterEmergencyCallbackModeInd(int slotId,
                                          int indicationType, int token, RIL_Errno e, void *response,
                                          size_t responseLen) {
     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
+#if VDBG
         RLOGD("enterEmergencyCallbackModeInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
                 convertIntToRadioIndicationType(indicationType));
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -6429,7 +7294,9 @@ int radio::cdmaCallWaitingInd(int slotId,
         callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type;
         callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan;
 
+#if VDBG
         RLOGD("cdmaCallWaitingInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting(
                 convertIntToRadioIndicationType(indicationType), callWaitingRecord);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -6449,7 +7316,9 @@ int radio::cdmaOtaProvisionStatusInd(int slotId,
             return 0;
         }
         int32_t status = ((int32_t *) response)[0];
+#if VDBG
         RLOGD("cdmaOtaProvisionStatusInd: status %d", status);
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus(
                 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -6626,7 +7495,9 @@ int radio::cdmaInfoRecInd(int slotId,
             }
         }
 
+#if VDBG
         RLOGD("cdmaInfoRecInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec(
                 convertIntToRadioIndicationType(indicationType), records);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -6646,7 +7517,9 @@ int radio::indicateRingbackToneInd(int slotId,
             return 0;
         }
         bool start = ((int32_t *) response)[0];
+#if VDBG
         RLOGD("indicateRingbackToneInd: start %d", start);
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone(
                 convertIntToRadioIndicationType(indicationType), start);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -6661,7 +7534,9 @@ int radio::resendIncallMuteInd(int slotId,
                                int indicationType, int token, RIL_Errno e, void *response,
                                size_t responseLen) {
     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
+#if VDBG
         RLOGD("resendIncallMuteInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
                 convertIntToRadioIndicationType(indicationType));
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -6681,7 +7556,9 @@ int radio::cdmaSubscriptionSourceChangedInd(int slotId,
             return 0;
         }
         int32_t cdmaSource = ((int32_t *) response)[0];
+#if VDBG
         RLOGD("cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource);
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->
                 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType),
                 (CdmaSubscriptionSource) cdmaSource);
@@ -6703,7 +7580,9 @@ int radio::cdmaPrlChangedInd(int slotId,
             return 0;
         }
         int32_t version = ((int32_t *) response)[0];
+#if VDBG
         RLOGD("cdmaPrlChangedInd: version %d", version);
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged(
                 convertIntToRadioIndicationType(indicationType), version);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -6718,7 +7597,9 @@ int radio::exitEmergencyCallbackModeInd(int slotId,
                                         int indicationType, int token, RIL_Errno e, void *response,
                                         size_t responseLen) {
     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
+#if VDBG
         RLOGD("exitEmergencyCallbackModeInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
                 convertIntToRadioIndicationType(indicationType));
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -6754,7 +7635,9 @@ int radio::voiceRadioTechChangedInd(int slotId,
             return 0;
         }
         int32_t rat = ((int32_t *) response)[0];
+#if VDBG
         RLOGD("voiceRadioTechChangedInd: rat %d", rat);
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged(
                 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -6923,7 +7806,9 @@ int radio::cellInfoListInd(int slotId,
         hidl_vec<CellInfo> records;
         convertRilCellInfoListToHal(response, responseLen, records);
 
+#if VDBG
         RLOGD("cellInfoListInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList(
                 convertIntToRadioIndicationType(indicationType), records);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -6938,7 +7823,9 @@ int radio::imsNetworkStateChangedInd(int slotId,
                                      int indicationType, int token, RIL_Errno e, void *response,
                                      size_t responseLen) {
     if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
+#if VDBG
         RLOGD("imsNetworkStateChangedInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
                 convertIntToRadioIndicationType(indicationType));
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -6959,7 +7846,9 @@ int radio::subscriptionStatusChangedInd(int slotId,
             return 0;
         }
         bool activate = ((int32_t *) response)[0];
+#if VDBG
         RLOGD("subscriptionStatusChangedInd: activate %d", activate);
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged(
                 convertIntToRadioIndicationType(indicationType), activate);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -6980,7 +7869,9 @@ int radio::srvccStateNotifyInd(int slotId,
             return 0;
         }
         int32_t state = ((int32_t *) response)[0];
+#if VDBG
         RLOGD("srvccStateNotifyInd: rat %d", state);
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify(
                 convertIntToRadioIndicationType(indicationType), (SrvccState) state);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -7036,7 +7927,9 @@ int radio::hardwareConfigChangedInd(int slotId,
         hidl_vec<HardwareConfig> configs;
         convertRilHardwareConfigListToHal(response, responseLen, configs);
 
+#if VDBG
         RLOGD("hardwareConfigChangedInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged(
                 convertIntToRadioIndicationType(indicationType), configs);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -7069,7 +7962,9 @@ int radio::radioCapabilityIndicationInd(int slotId,
         RadioCapability rc = {};
         convertRilRadioCapabilityToHal(response, responseLen, rc);
 
+#if VDBG
         RLOGD("radioCapabilityIndicationInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication(
                 convertIntToRadioIndicationType(indicationType), rc);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -7112,8 +8007,10 @@ int radio::onSupplementaryServiceIndicationInd(int slotId,
         ss.result = (RadioError) rilSsResponse->result;
 
         if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) {
+#if VDBG
             RLOGD("onSupplementaryServiceIndicationInd CF type, num of Cf elements %d",
                     rilSsResponse->cfData.numValidIndexes);
+#endif
             if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
                 RLOGE("onSupplementaryServiceIndicationInd numValidIndexes is greater than "
                         "max value %d, truncating it to max value", NUM_SERVICE_CLASSES);
@@ -7136,9 +8033,11 @@ int radio::onSupplementaryServiceIndicationInd(int slotId,
                  cfInfo->toa = cf.toa;
                  cfInfo->number = convertCharPtrToHidlString(cf.number);
                  cfInfo->timeSeconds = cf.timeSeconds;
+#if VDBG
                  RLOGD("onSupplementaryServiceIndicationInd: "
                         "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
                         cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
+#endif
             }
         } else {
             ss.ssInfo.resize(1);
@@ -7147,13 +8046,17 @@ int radio::onSupplementaryServiceIndicationInd(int slotId,
             /* each int */
             ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX);
             for (int i = 0; i < SS_INFO_MAX; i++) {
+#if VDBG
                  RLOGD("onSupplementaryServiceIndicationInd: Data: %d",
                         rilSsResponse->ssInfo[i]);
+#endif
                  ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i];
             }
         }
 
+#if VDBG
         RLOGD("onSupplementaryServiceIndicationInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->
                 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType),
                 ss);
@@ -7174,7 +8077,9 @@ int radio::stkCallControlAlphaNotifyInd(int slotId,
             RLOGE("stkCallControlAlphaNotifyInd: invalid response");
             return 0;
         }
+#if VDBG
         RLOGD("stkCallControlAlphaNotifyInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify(
                 convertIntToRadioIndicationType(indicationType),
                 convertCharPtrToHidlString((char *) response));
@@ -7205,7 +8110,9 @@ int radio::lceDataInd(int slotId,
 
         LceDataInfo lce = {};
         convertRilLceDataInfoToHal(response, responseLen, lce);
+#if VDBG
         RLOGD("lceDataInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData(
                 convertIntToRadioIndicationType(indicationType), lce);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -7232,7 +8139,9 @@ int radio::pcoDataInd(int slotId,
         pco.pcoId = rilPcoData->pco_id;
         pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length);
 
+#if VDBG
         RLOGD("pcoDataInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData(
                 convertIntToRadioIndicationType(indicationType), pco);
         radioService[slotId]->checkReturnStatus(retStatus);
@@ -7251,7 +8160,9 @@ int radio::modemResetInd(int slotId,
             RLOGE("modemResetInd: invalid response");
             return 0;
         }
+#if VDBG
         RLOGD("modemResetInd");
+#endif
         Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset(
                 convertIntToRadioIndicationType(indicationType),
                 convertCharPtrToHidlString((char *) response));
@@ -7263,6 +8174,79 @@ int radio::modemResetInd(int slotId,
     return 0;
 }
 
+int radio::networkScanResultInd(int slotId,
+                                int indicationType, int token, RIL_Errno e, void *response,
+                                size_t responseLen) {
+#if VDBG
+    RLOGD("networkScanResultInd");
+#endif
+    if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
+        if (response == NULL || responseLen == 0) {
+            RLOGE("networkScanResultInd: invalid response");
+            return 0;
+        }
+        RLOGD("networkScanResultInd");
+
+#if VDBG
+        RLOGD("networkScanResultInd");
+#endif
+
+        Return<sp<::android::hardware::radio::V1_1::IRadioIndication>> ret =
+            ::android::hardware::radio::V1_1::IRadioIndication::castFrom(
+            radioService[slotId]->mRadioIndication);
+        if (ret.isOk()) {
+            RIL_NetworkScanResult *networkScanResult = (RIL_NetworkScanResult *) response;
+
+            ::android::hardware::radio::V1_1::NetworkScanResult result;
+            result.status =
+                    (::android::hardware::radio::V1_1::ScanStatus) networkScanResult->status;
+            result.error = (RadioError) e;
+            convertRilCellInfoListToHal(
+                    networkScanResult->network_infos,
+                    networkScanResult->network_infos_length * sizeof(RIL_CellInfo_v12),
+                    result.networkInfos);
+
+            sp<::android::hardware::radio::V1_1::IRadioIndication> radioIndicationV1_1 = ret;
+            Return<void> retStatus = radioIndicationV1_1->networkScanResult(
+                    convertIntToRadioIndicationType(indicationType), result);
+            radioService[slotId]->checkReturnStatus(retStatus);
+        } else {
+            RLOGE("networkScanResultInd: ret.isOk() == false for radioService[%d]", slotId);
+        }
+    } else {
+        RLOGE("networkScanResultInd: radioService[%d]->mRadioIndication == NULL", slotId);
+    }
+    return 0;
+}
+
+int radio::carrierInfoForImsiEncryption(int slotId,
+                                  int indicationType, int token, RIL_Errno e, void *response,
+                                  size_t responseLen) {
+    if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
+        if (response == NULL || responseLen == 0) {
+            RLOGE("carrierInfoForImsiEncryption: invalid response");
+            return 0;
+        }
+        RLOGD("carrierInfoForImsiEncryption");
+        Return<sp<::android::hardware::radio::V1_1::IRadioIndication>> ret =
+            ::android::hardware::radio::V1_1::IRadioIndication::castFrom(
+            radioService[slotId]->mRadioIndication);
+        if (ret.isOk()) {
+            sp<::android::hardware::radio::V1_1::IRadioIndication> radioIndicationV1_1 = ret;
+            Return<void> retStatus = radioIndicationV1_1->carrierInfoForImsiEncryption(
+                    convertIntToRadioIndicationType(indicationType));
+            radioService[slotId]->checkReturnStatus(retStatus);
+        } else {
+            RLOGE("carrierInfoForImsiEncryptionResponse: ret.isOk() == false for radioService[%d]",
+                    slotId);
+        }
+    } else {
+        RLOGE("carrierInfoForImsiEncryption: radioService[%d]->mRadioIndication == NULL", slotId);
+    }
+
+    return 0;
+}
+
 int radio::oemHookRawInd(int slotId,
                          int indicationType, int token, RIL_Errno e, void *response,
                          size_t responseLen) {
@@ -7274,10 +8258,12 @@ int radio::oemHookRawInd(int slotId,
 
         hidl_vec<uint8_t> data;
         data.setToExternal((uint8_t *) response, responseLen);
+#if VDBG
         RLOGD("oemHookRawInd");
+#endif
         Return<void> retStatus = oemHookService[slotId]->mOemHookIndication->oemHookRaw(
                 convertIntToRadioIndicationType(indicationType), data);
-        checkReturnStatus(slotId, retStatus);
+        checkReturnStatus(slotId, retStatus, false);
     } else {
         RLOGE("oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId);
     }
@@ -7289,26 +8275,13 @@ void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands
     using namespace android::hardware;
     int simCount = 1;
     const char *serviceNames[] = {
-            android::RIL_getRilSocketName()
-            #if (SIM_COUNT >= 2)
-            , SOCKET2_NAME_RIL
-            #if (SIM_COUNT >= 3)
-            , SOCKET3_NAME_RIL
-            #if (SIM_COUNT >= 4)
-            , SOCKET4_NAME_RIL
-            #endif
-            #endif
-            #endif
-            };
-
-    const char *oemHookServiceNames[] = {
-            OEM_HOOK_SERVICE_NAME
+            android::RIL_getServiceName()
             #if (SIM_COUNT >= 2)
-            , OEM_HOOK2_SERVICE_NAME
+            , RIL2_SERVICE_NAME
             #if (SIM_COUNT >= 3)
-            , OEM_HOOK3_SERVICE_NAME
+            , RIL3_SERVICE_NAME
             #if (SIM_COUNT >= 4)
-            , OEM_HOOK4_SERVICE_NAME
+            , RIL4_SERVICE_NAME
             #endif
             #endif
             #endif
@@ -7328,9 +8301,10 @@ void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands
         radioService[i]->mSlotId = i;
         oemHookService[i] = new OemHookImpl;
         oemHookService[i]->mSlotId = i;
-        RLOGD("registerService: starting IRadio %s", serviceNames[i]);
+        RLOGD("registerService: starting android::hardware::radio::V1_1::IRadio %s",
+                serviceNames[i]);
         android::status_t status = radioService[i]->registerAsService(serviceNames[i]);
-        status = oemHookService[i]->registerAsService(oemHookServiceNames[i]);
+        status = oemHookService[i]->registerAsService(serviceNames[i]);
 
         ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
         assert(ret == 0);