Merge sc-dev-plus-aosp-without-vendor@7634622

Merged-In: I914766c7f155468a250afe5b8f42a16c57b1ea35
Change-Id: I6f522d6d244351a294cfa10defa2744cf5f16564
diff --git a/libril/Android.mk b/libril/Android.mk
index 92e9a6f..12b58cf 100644
--- a/libril/Android.mk
+++ b/libril/Android.mk
@@ -20,7 +20,6 @@
     librilutils \
     android.hardware.radio@1.0 \
     android.hardware.radio@1.1 \
-    android.hardware.radio.deprecated@1.0 \
     libhidlbase \
 
 LOCAL_STATIC_LIBRARIES := \
diff --git a/libril/ril.cpp b/libril/ril.cpp
index 214fa10..074a858 100644
--- a/libril/ril.cpp
+++ b/libril/ril.cpp
@@ -1081,8 +1081,6 @@
         case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "LAST_DATA_CALL_FAIL_CAUSE";
         case RIL_REQUEST_DATA_CALL_LIST: return "DATA_CALL_LIST";
         case RIL_REQUEST_RESET_RADIO: return "RESET_RADIO";
-        case RIL_REQUEST_OEM_HOOK_RAW: return "OEM_HOOK_RAW";
-        case RIL_REQUEST_OEM_HOOK_STRINGS: return "OEM_HOOK_STRINGS";
         case RIL_REQUEST_SCREEN_STATE: return "SCREEN_STATE";
         case RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION: return "SET_SUPP_SVC_NOTIFICATION";
         case RIL_REQUEST_WRITE_SMS_TO_SIM: return "WRITE_SMS_TO_SIM";
diff --git a/libril/ril_commands.h b/libril/ril_commands.h
index 94c2a26..bd0f6f7 100644
--- a/libril/ril_commands.h
+++ b/libril/ril_commands.h
@@ -73,8 +73,8 @@
     {RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE, NULL},
     {RIL_REQUEST_DATA_CALL_LIST, radio::getDataCallListResponse},
     {RIL_REQUEST_RESET_RADIO, NULL},
-    {RIL_REQUEST_OEM_HOOK_RAW, radio::sendRequestRawResponse},
-    {RIL_REQUEST_OEM_HOOK_STRINGS, radio::sendRequestStringsResponse},
+    {RIL_REQUEST_OEM_HOOK_RAW, NULL},
+    {RIL_REQUEST_OEM_HOOK_STRINGS, NULL},
     {RIL_REQUEST_SCREEN_STATE, radio::sendDeviceStateResponse},   // Note the response function is different.
     {RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, radio::setSuppServiceNotificationsResponse},
     {RIL_REQUEST_WRITE_SMS_TO_SIM, radio::writeSmsToSimResponse},
diff --git a/libril/ril_service.cpp b/libril/ril_service.cpp
index 77c2e61..8009d47 100755
--- a/libril/ril_service.cpp
+++ b/libril/ril_service.cpp
@@ -21,8 +21,6 @@
 #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>
 #include <hwbinder/ProcessState.h>
 #include <telephony/ril.h>
@@ -37,7 +35,6 @@
 
 using namespace android::hardware::radio;
 using namespace android::hardware::radio::V1_0;
-using namespace android::hardware::radio::deprecated::V1_0;
 using ::android::hardware::configureRpcThreadpool;
 using ::android::hardware::joinRpcThreadpool;
 using ::android::hardware::Return;
@@ -63,32 +60,21 @@
 #define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest()
 #endif
 
-#ifdef OEM_HOOK_DISABLED
-constexpr bool kOemHookEnabled = false;
-#else
-constexpr bool kOemHookEnabled = true;
-#endif
-
 RIL_RadioFunctions *s_vendorFunctions = NULL;
 static CommandInfo *s_commands;
 
 struct RadioImpl;
-struct OemHookImpl;
 
 #if (SIM_COUNT >= 2)
 sp<RadioImpl> radioService[SIM_COUNT];
-sp<OemHookImpl> oemHookService[SIM_COUNT];
 int64_t nitzTimeReceived[SIM_COUNT];
 // counter used for synchronization. It is incremented every time response callbacks are updated.
 volatile int32_t mCounterRadio[SIM_COUNT];
-volatile int32_t mCounterOemHook[SIM_COUNT];
 #else
 sp<RadioImpl> radioService[1];
-sp<OemHookImpl> oemHookService[1];
 int64_t nitzTimeReceived[1];
 // counter used for synchronization. It is incremented every time response callbacks are updated.
 volatile int32_t mCounterRadio[1];
-volatile int32_t mCounterOemHook[1];
 #endif
 
 static pthread_rwlock_t radioServiceRwlock = PTHREAD_RWLOCK_INITIALIZER;
@@ -465,22 +451,6 @@
     void checkReturnStatus(Return<void>& ret);
 };
 
-struct OemHookImpl : public IOemHook {
-    int32_t mSlotId;
-    sp<IOemHookResponse> mOemHookResponse;
-    sp<IOemHookIndication> mOemHookIndication;
-
-    Return<void> setResponseFunctions(
-            const ::android::sp<IOemHookResponse>& oemHookResponse,
-            const ::android::sp<IOemHookIndication>& oemHookIndication);
-
-    Return<void> sendRequestRaw(int32_t serial,
-            const ::android::hardware::hidl_vec<uint8_t>& data);
-
-    Return<void> sendRequestStrings(int32_t serial,
-            const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data);
-};
-
 void memsetAndFreeStrings(int numPointers, ...) {
     va_list ap;
     va_start(ap, numPointers);
@@ -762,7 +732,7 @@
         // 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 = isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId];
+        int counter = mCounterRadio[slotId];
         pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(slotId);
         int ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
         assert(ret == 0);
@@ -772,17 +742,12 @@
         assert(ret == 0);
 
         // make sure the counter value has not changed
-        if (counter == (isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId])) {
-            if (isRadioService) {
-                radioService[slotId]->mRadioResponse = NULL;
-                radioService[slotId]->mRadioIndication = NULL;
-                radioService[slotId]->mRadioResponseV1_1 = NULL;
-                radioService[slotId]->mRadioIndicationV1_1 = NULL;
-            } else {
-                oemHookService[slotId]->mOemHookResponse = NULL;
-                oemHookService[slotId]->mOemHookIndication = NULL;
-            }
-            isRadioService ? mCounterRadio[slotId]++ : mCounterOemHook[slotId]++;
+        if (counter == mCounterRadio[slotId]) {
+            radioService[slotId]->mRadioResponse = NULL;
+            radioService[slotId]->mRadioIndication = NULL;
+            radioService[slotId]->mRadioResponseV1_1 = NULL;
+            radioService[slotId]->mRadioIndicationV1_1 = NULL;
+            mCounterRadio[slotId]++;
         } else {
             RLOGE("checkReturnStatus: not resetting responseFunctions as they likely "
                     "got updated on another thread");
@@ -2927,44 +2892,6 @@
     return Void();
 }
 
-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);
-    assert(ret == 0);
-
-    mOemHookResponse = oemHookResponseParam;
-    mOemHookIndication = oemHookIndicationParam;
-    mCounterOemHook[mSlotId]++;
-
-    ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
-    assert(ret == 0);
-
-    return Void();
-}
-
-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();
-}
-
 /***************************************************************************************************
  * RESPONSE FUNCTIONS
  * Functions above are used for requests going from framework to vendor code. The ones below are
@@ -6800,74 +6727,6 @@
     return 0;
 }
 
-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 (!kOemHookEnabled) return 0;
-
-    if (oemHookService[slotId]->mOemHookResponse != NULL) {
-        RadioResponseInfo responseInfo = {};
-        populateResponseInfo(responseInfo, serial, responseType, e);
-        hidl_vec<uint8_t> data;
-
-        if (response == NULL) {
-            RLOGE("sendRequestRawResponse: Invalid response");
-            if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
-        } else {
-            data.setToExternal((uint8_t *) response, responseLen);
-        }
-        Return<void> retStatus = oemHookService[slotId]->mOemHookResponse->
-                sendRequestRawResponse(responseInfo, data);
-        checkReturnStatus(slotId, retStatus, false);
-    } else {
-        RLOGE("sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL",
-                slotId);
-    }
-
-    return 0;
-}
-
-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 (!kOemHookEnabled) return 0;
-
-    if (oemHookService[slotId]->mOemHookResponse != NULL) {
-        RadioResponseInfo responseInfo = {};
-        populateResponseInfo(responseInfo, serial, responseType, e);
-        hidl_vec<hidl_string> data;
-
-        if ((response == NULL && responseLen != 0) || responseLen % sizeof(char *) != 0) {
-            RLOGE("sendRequestStringsResponse Invalid response: NULL");
-            if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
-        } else {
-            char **resp = (char **) response;
-            int numStrings = responseLen / sizeof(char *);
-            data.resize(numStrings);
-            for (int i = 0; i < numStrings; i++) {
-                data[i] = convertCharPtrToHidlString(resp[i]);
-            }
-        }
-        Return<void> retStatus
-                = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse(
-                responseInfo, data);
-        checkReturnStatus(slotId, retStatus, false);
-    } else {
-        RLOGE("sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == "
-                "NULL", slotId);
-    }
-
-    return 0;
-}
-
 /***************************************************************************************************
  * INDICATION FUNCTIONS
  * The below function handle unsolicited messages coming from the Radio
@@ -8553,32 +8412,6 @@
     return 0;
 }
 
-int radio::oemHookRawInd(int slotId,
-                         int indicationType, int token, RIL_Errno e, void *response,
-                         size_t responseLen) {
-    if (!kOemHookEnabled) return 0;
-
-    if (oemHookService[slotId] != NULL && oemHookService[slotId]->mOemHookIndication != NULL) {
-        if (response == NULL || responseLen == 0) {
-            RLOGE("oemHookRawInd: invalid response");
-            return 0;
-        }
-
-        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, false);
-    } else {
-        RLOGE("oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId);
-    }
-
-    return 0;
-}
-
 void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
     using namespace android::hardware;
     int simCount = 1;
@@ -8612,13 +8445,7 @@
         radioService[i]->mSlotId = i;
         RLOGD("registerService: starting android::hardware::radio::V1_1::IRadio %s",
                 serviceNames[i]);
-        android::status_t status = radioService[i]->registerAsService(serviceNames[i]);
-
-        if (kOemHookEnabled) {
-            oemHookService[i] = new OemHookImpl;
-            oemHookService[i]->mSlotId = i;
-            status = oemHookService[i]->registerAsService(serviceNames[i]);
-        }
+        (void) radioService[i]->registerAsService(serviceNames[i]);
 
         ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
         assert(ret == 0);
diff --git a/libril/ril_service.h b/libril/ril_service.h
index 77ea28b..b98dd3e 100644
--- a/libril/ril_service.h
+++ b/libril/ril_service.h
@@ -641,10 +641,6 @@
                    int indicationType, int token, RIL_Errno e, void *response,
                    size_t responselen);
 
-int oemHookRawInd(int slotId,
-                  int indicationType, int token, RIL_Errno e, void *response,
-                  size_t responselen);
-
 int indicateRingbackToneInd(int slotId,
                             int indicationType, int token, RIL_Errno e, void *response,
                             size_t responselen);
@@ -725,14 +721,6 @@
                        int indicationType, int token, RIL_Errno e, void *response,
                        size_t responselen);
 
-int sendRequestRawResponse(int slotId,
-                           int responseType, int serial, RIL_Errno e,
-                           void *response, size_t responseLen);
-
-int sendRequestStringsResponse(int slotId,
-                               int responseType, int serial, RIL_Errno e,
-                               void *response, size_t responseLen);
-
 int setCarrierInfoForImsiEncryptionResponse(int slotId,
                                             int responseType, int serial, RIL_Errno e,
                                             void *response, size_t responseLen);
diff --git a/libril/ril_unsol_commands.h b/libril/ril_unsol_commands.h
index 831f5fb..dab15ee 100644
--- a/libril/ril_unsol_commands.h
+++ b/libril/ril_unsol_commands.h
@@ -42,7 +42,7 @@
     {RIL_UNSOL_CDMA_CALL_WAITING, radio::cdmaCallWaitingInd, WAKE_PARTIAL},
     {RIL_UNSOL_CDMA_OTA_PROVISION_STATUS, radio::cdmaOtaProvisionStatusInd, WAKE_PARTIAL},
     {RIL_UNSOL_CDMA_INFO_REC, radio::cdmaInfoRecInd, WAKE_PARTIAL},
-    {RIL_UNSOL_OEM_HOOK_RAW, radio::oemHookRawInd, WAKE_PARTIAL},
+    {RIL_UNSOL_OEM_HOOK_RAW, NULL, WAKE_PARTIAL},
     {RIL_UNSOL_RINGBACK_TONE, radio::indicateRingbackToneInd, WAKE_PARTIAL},
     {RIL_UNSOL_RESEND_INCALL_MUTE, radio::resendIncallMuteInd, WAKE_PARTIAL},
     {RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED, radio::cdmaSubscriptionSourceChangedInd, WAKE_PARTIAL},