1ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/* Copyright (c) 2009-2013, The Linux Foundation. All rights reserved. 2ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * 3ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * Redistribution and use in source and binary forms, with or without 4ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * modification, are permitted provided that the following conditions are 5ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * met: 6ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * * Redistributions of source code must retain the above copyright 7ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * notice, this list of conditions and the following disclaimer. 8ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * * Redistributions in binary form must reproduce the above 9ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * copyright notice, this list of conditions and the following 10ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * disclaimer in the documentation and/or other materials provided 11ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * with the distribution. 12ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * * Neither the name of The Linux Foundation, nor the names of its 13ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * contributors may be used to endorse or promote products derived 14ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * from this software without specific prior written permission. 15ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * 16ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo * 28ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo */ 29ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 30ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOG_NDDEBUG 0 31ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#define LOG_TAG "LocSvc_eng" 32ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 33ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#include <loc_eng.h> 34ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#include <MsgTask.h> 35ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#include "log_util.h" 36ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo#include "platform_lib_includes.h" 37ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 38ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russousing namespace loc_core; 39ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 40ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russostruct LocEngRequestXtraServer : public LocMsg { 41ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo LocEngAdapter* mAdapter; 42ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo inline LocEngRequestXtraServer(LocEngAdapter* adapter) : 43ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo LocMsg(), mAdapter(adapter) 44ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo { 45ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo locallog(); 46ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo } 47ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo inline virtual void proc() const { 48ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo mAdapter->requestXtraServer(); 49ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo } 50ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo inline void locallog() const { 51ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo LOC_LOGV("LocEngRequestXtraServer"); 52ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo } 53ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo inline virtual void log() const { 54ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo locallog(); 55ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo } 56ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo}; 57ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 58ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russostruct LocEngInjectXtraData : public LocMsg { 59ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo LocEngAdapter* mAdapter; 60ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo char* mData; 61ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo const int mLen; 62ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo inline LocEngInjectXtraData(LocEngAdapter* adapter, 63ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo char* data, int len): 64ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo LocMsg(), mAdapter(adapter), 65ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo mData(new char[len]), mLen(len) 66ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo { 67ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo memcpy((void*)mData, (void*)data, len); 68ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo locallog(); 69ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo } 70ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo inline ~LocEngInjectXtraData() 71ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo { 72ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo delete[] mData; 73ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo } 74ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo inline virtual void proc() const { 75ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo mAdapter->setXtraData(mData, mLen); 76ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo } 77ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo inline void locallog() const { 78ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo LOC_LOGV("length: %d\n data: %p", mLen, mData); 79ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo } 80ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo inline virtual void log() const { 81ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo locallog(); 82ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo } 83ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo}; 84ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 85ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/*=========================================================================== 86ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoFUNCTION loc_eng_xtra_init 87ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 88ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoDESCRIPTION 89ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo Initialize XTRA module. 90ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 91ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoDEPENDENCIES 92ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo N/A 93ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 94ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoRETURN VALUE 95ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 0: success 96ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 97ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoSIDE EFFECTS 98ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo N/A 99ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 100ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo===========================================================================*/ 101ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russoint loc_eng_xtra_init (loc_eng_data_s_type &loc_eng_data, 102ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo GpsXtraExtCallbacks* callbacks) 103ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo{ 104ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo int ret_val = -1; 105ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo loc_eng_xtra_data_s_type *xtra_module_data_ptr; 106ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 107ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo if(callbacks == NULL) { 108ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo LOC_LOGE("loc_eng_xtra_init: failed, cb is NULL"); 109ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo } else { 110ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo xtra_module_data_ptr = &loc_eng_data.xtra_module_data; 111ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo xtra_module_data_ptr->download_request_cb = callbacks->download_request_cb; 112ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo xtra_module_data_ptr->report_xtra_server_cb = callbacks->report_xtra_server_cb; 113ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 114ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo ret_val = 0; 115ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo } 116ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo return ret_val; 117ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo} 118ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 119ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/*=========================================================================== 120ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoFUNCTION loc_eng_xtra_inject_data 121ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 122ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoDESCRIPTION 123ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo Injects XTRA file into the engine but buffers the data if engine is busy. 124ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 125ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoDEPENDENCIES 126ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo N/A 127ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 128ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoRETURN VALUE 129ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 0: success 130ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo >0: failure 131ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 132ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoSIDE EFFECTS 133ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo N/A 134ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 135ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo===========================================================================*/ 136ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russoint loc_eng_xtra_inject_data(loc_eng_data_s_type &loc_eng_data, 137ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo char* data, int length) 138ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo{ 139ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo LocEngAdapter* adapter = loc_eng_data.adapter; 140ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo adapter->sendMsg(new LocEngInjectXtraData(adapter, data, length)); 141ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 142ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo return 0; 143ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo} 144ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo/*=========================================================================== 145ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoFUNCTION loc_eng_xtra_request_server 146ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 147ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoDESCRIPTION 148ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo Request the Xtra server url from the modem 149ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 150ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoDEPENDENCIES 151ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo N/A 152ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 153ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoRETURN VALUE 154ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo length of server string 155ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 156ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante RussoSIDE EFFECTS 157ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo N/A 158ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 159ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo===========================================================================*/ 160ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russoint loc_eng_xtra_request_server(loc_eng_data_s_type &loc_eng_data) 161ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo{ 162ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo LocEngAdapter* adapter = loc_eng_data.adapter; 163ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo adapter->sendMsg(new LocEngRequestXtraServer(adapter)); 164ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 165ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo return 0; 166ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo 167ec6e5d3a2597d37d5b1d98911cb06218cdf19bf1Dante Russo} 168