soundtrigger: add size check on sound model and recogntion data

Bug: 30148546

Change-Id: I082f535a853c96571887eeea37c6d41ecee7d8c0
(cherry picked from commit bb00d8f139ff51336ab3c810d35685003949bcf8)
(cherry picked from commit ef0c91518446e65533ca8bab6726a845f27c73fd)

void SoundTriggerHwService::sendRecognitionEvent(struct sound_trigger_recognition_event *event,
 Module *module)
 {
 AutoMutex lock(mServiceLock);
 if (module == NULL) {
 return;
 }
     sp<IMemory> eventMemory = prepareRecognitionEvent_l(event);
 if (eventMemory == 0) {
 return;
 }
     sp<Module> strongModule;
 for (size_t i = 0; i < mModules.size(); i++) {
 if (mModules.valueAt(i).get() == module) {
             strongModule = mModules.valueAt(i);
 break;
 }
 }
 if (strongModule == 0) {
 return;
 }

     sendCallbackEvent_l(new CallbackEvent(CallbackEvent::TYPE_RECOGNITION,
                                                  eventMemory, strongModule));
}

void SoundTriggerHwService::sendRecognitionEvent(struct sound_trigger_recognition_event *event,
 Module *module)
 {
 AutoMutex lock(mServiceLock);
 if (module == NULL) {
 return;
 }
     sp<IMemory> eventMemory = prepareRecognitionEvent_l(event);
 if (eventMemory == 0) {
 return;
 }
     sp<Module> strongModule;
 for (size_t i = 0; i < mModules.size(); i++) {
 if (mModules.valueAt(i).get() == module) {
             strongModule = mModules.valueAt(i);
 break;
 }
 }
 if (strongModule == 0) {
 return;
 }

     sendCallbackEvent_l(new CallbackEvent(CallbackEvent::TYPE_RECOGNITION,
                                                  eventMemory, strongModule));
}
