1/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 *     * Redistributions of source code must retain the above copyright
7 *       notice, this list of conditions and the following disclaimer.
8 *     * Redistributions in binary form must reproduce the above
9 *       copyright notice, this list of conditions and the following
10 *       disclaimer in the documentation and/or other materials provided
11 *       with the distribution.
12 *     * Neither the name of Code Aurora Forum, Inc. nor the names of its
13 *       contributors may be used to endorse or promote products derived
14 *       from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 */
29
30#define LOG_NDDEBUG 0
31#define LOG_TAG "LocSvc_afw"
32
33#include <hardware/gps.h>
34#include <loc_eng.h>
35#include <loc_log.h>
36
37static gps_location_callback gps_loc_cb = NULL;
38static gps_sv_status_callback gps_sv_cb = NULL;
39
40static void loc_cb(GpsLocation* location, void* locExt);
41static void sv_cb(GpsSvStatus* sv_status, void* svExt);
42
43// Function declarations for sLocEngInterface
44static int  loc_init(GpsCallbacks* callbacks);
45static int  loc_start();
46static int  loc_stop();
47static void loc_cleanup();
48static int  loc_inject_time(GpsUtcTime time, int64_t timeReference, int uncertainty);
49static int  loc_inject_location(double latitude, double longitude, float accuracy);
50static void loc_delete_aiding_data(GpsAidingData f);
51static int  loc_set_position_mode(GpsPositionMode mode, GpsPositionRecurrence recurrence,
52                                  uint32_t min_interval, uint32_t preferred_accuracy,
53                                  uint32_t preferred_time);
54static const void* loc_get_extension(const char* name);
55#ifdef QCOM_FEATURE_ULP
56static int  loc_update_criteria(UlpLocationCriteria criteria);
57#endif
58
59// Defines the GpsInterface in gps.h
60static const GpsInterface sLocEngInterface =
61{
62   sizeof(GpsInterface),
63   loc_init,
64   loc_start,
65   loc_stop,
66   loc_cleanup,
67   loc_inject_time,
68   loc_inject_location,
69   loc_delete_aiding_data,
70   loc_set_position_mode,
71   loc_get_extension
72#ifdef QCOM_FEATURE_ULP
73   ,loc_update_criteria
74#endif
75};
76
77// Function declarations for sLocEngAGpsInterface
78static void loc_agps_init(AGpsCallbacks* callbacks);
79#ifdef QCOM_FEATURE_IPV6
80static int  loc_agps_open(AGpsType agpsType,
81                          const char* apn, AGpsBearerType bearerType);
82static int  loc_agps_closed(AGpsType agpsType);
83static int  loc_agps_open_failed(AGpsType agpsType);
84#else
85static int  loc_agps_open(const char* apn);
86static int  loc_agps_closed();
87static int  loc_agps_open_failed();
88#endif
89static int  loc_agps_set_server(AGpsType type, const char *hostname, int port);
90
91static const AGpsInterface sLocEngAGpsInterface =
92{
93   sizeof(AGpsInterface),
94   loc_agps_init,
95   loc_agps_open,
96   loc_agps_closed,
97   loc_agps_open_failed,
98   loc_agps_set_server
99};
100
101static int loc_xtra_init(GpsXtraCallbacks* callbacks);
102static int loc_xtra_inject_data(char* data, int length);
103
104static const GpsXtraInterface sLocEngXTRAInterface =
105{
106    sizeof(GpsXtraInterface),
107    loc_xtra_init,
108    loc_xtra_inject_data
109};
110
111static void loc_ni_init(GpsNiCallbacks *callbacks);
112static void loc_ni_respond(int notif_id, GpsUserResponseType user_response);
113
114const GpsNiInterface sLocEngNiInterface =
115{
116   sizeof(GpsNiInterface),
117   loc_ni_init,
118   loc_ni_respond,
119};
120
121static void loc_agps_ril_init( AGpsRilCallbacks* callbacks );
122static void loc_agps_ril_set_ref_location(const AGpsRefLocation *agps_reflocation, size_t sz_struct);
123static void loc_agps_ril_set_set_id(AGpsSetIDType type, const char* setid);
124static void loc_agps_ril_ni_message(uint8_t *msg, size_t len);
125static void loc_agps_ril_update_network_state(int connected, int type, int roaming, const char* extra_info);
126static void loc_agps_ril_update_network_availability(int avaiable, const char* apn);
127
128static const AGpsRilInterface sLocEngAGpsRilInterface =
129{
130   sizeof(AGpsRilInterface),
131   loc_agps_ril_init,
132   loc_agps_ril_set_ref_location,
133   loc_agps_ril_set_set_id,
134   loc_agps_ril_ni_message,
135   loc_agps_ril_update_network_state,
136   loc_agps_ril_update_network_availability
137};
138
139#ifdef QCOM_FEATURE_ULP
140static bool loc_inject_raw_command(char* command, int length);
141
142static const InjectRawCmdInterface sLocEngInjectRawCmdInterface =
143{
144   sizeof(InjectRawCmdInterface),
145   loc_inject_raw_command
146};
147#endif
148
149static loc_eng_data_s_type loc_afw_data;
150
151/*===========================================================================
152FUNCTION    gps_get_hardware_interface
153
154DESCRIPTION
155   Returns the GPS hardware interaface based on LOC API
156   if GPS is enabled.
157
158DEPENDENCIES
159   None
160
161RETURN VALUE
162   0: success
163
164SIDE EFFECTS
165   N/A
166
167===========================================================================*/
168const GpsInterface* gps_get_hardware_interface ()
169{
170    ENTRY_LOG_CALLFLOW();
171    const GpsInterface* ret_val;
172
173    char propBuf[PROPERTY_VALUE_MAX];
174
175    // check to see if GPS should be disabled
176    property_get("gps.disable", propBuf, "");
177    if (propBuf[0] == '1')
178    {
179        LOC_LOGD("gps_get_interface returning NULL because gps.disable=1\n");
180        ret_val = NULL;
181    } else {
182        ret_val = &sLocEngInterface;
183    }
184
185    EXIT_LOG(%p, ret_val);
186    return ret_val;
187}
188
189// for gps.c
190extern "C" const GpsInterface* get_gps_interface()
191{
192    return &sLocEngInterface;
193}
194/*===========================================================================
195FUNCTION    loc_init
196
197DESCRIPTION
198   Initialize the location engine, this include setting up global datas
199   and registers location engien with loc api service.
200
201DEPENDENCIES
202   None
203
204RETURN VALUE
205   0: success
206
207SIDE EFFECTS
208   N/Ax
209
210===========================================================================*/
211static int loc_init(GpsCallbacks* callbacks)
212{
213    ENTRY_LOG();
214    LOC_API_ADAPTER_EVENT_MASK_T event =
215        LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT |
216        LOC_API_ADAPTER_BIT_SATELLITE_REPORT |
217        LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST |
218        LOC_API_ADAPTER_BIT_ASSISTANCE_DATA_REQUEST |
219        LOC_API_ADAPTER_BIT_IOCTL_REPORT |
220        LOC_API_ADAPTER_BIT_STATUS_REPORT |
221        LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT |
222        LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST;
223    LocCallbacks clientCallbacks = {loc_cb, /* location_cb */
224                                    callbacks->status_cb, /* status_cb */
225                                    sv_cb, /* sv_status_cb */
226                                    callbacks->nmea_cb, /* nmea_cb */
227                                    callbacks->set_capabilities_cb, /* set_capabilities_cb */
228                                    callbacks->acquire_wakelock_cb, /* acquire_wakelock_cb */
229                                    callbacks->release_wakelock_cb, /* release_wakelock_cb */
230                                    callbacks->create_thread_cb, /* create_thread_cb */
231                                    NULL, /* location_ext_parser */
232                                    NULL  /* sv_ext_parser */};
233    gps_loc_cb = callbacks->location_cb;
234    gps_sv_cb = callbacks->sv_status_cb;
235
236    int ret_val = loc_eng_init(loc_afw_data, &clientCallbacks, event);
237
238    EXIT_LOG(%d, ret_val);
239    return ret_val;
240}
241
242/*===========================================================================
243FUNCTION    loc_cleanup
244
245DESCRIPTION
246   Cleans location engine. The location client handle will be released.
247
248DEPENDENCIES
249   None
250
251RETURN VALUE
252   None
253
254SIDE EFFECTS
255   N/A
256
257===========================================================================*/
258static void loc_cleanup()
259{
260    ENTRY_LOG();
261    loc_eng_cleanup(loc_afw_data);
262    gps_loc_cb = NULL;
263    gps_sv_cb = NULL;
264    EXIT_LOG(%s, VOID_RET);
265}
266
267/*===========================================================================
268FUNCTION    loc_start
269
270DESCRIPTION
271   Starts the tracking session
272
273DEPENDENCIES
274   None
275
276RETURN VALUE
277   0: success
278
279SIDE EFFECTS
280   N/A
281
282===========================================================================*/
283static int loc_start()
284{
285    ENTRY_LOG();
286    int ret_val = loc_eng_start(loc_afw_data);
287
288    EXIT_LOG(%d, ret_val);
289    return ret_val;
290}
291
292/*===========================================================================
293FUNCTION    loc_stop
294
295DESCRIPTION
296   Stops the tracking session
297
298DEPENDENCIES
299   None
300
301RETURN VALUE
302   0: success
303
304SIDE EFFECTS
305   N/A
306
307===========================================================================*/
308static int loc_stop()
309{
310    ENTRY_LOG();
311    int ret_val = loc_eng_stop(loc_afw_data);
312
313    EXIT_LOG(%d, ret_val);
314    return ret_val;
315}
316
317/*===========================================================================
318FUNCTION    loc_set_position_mode
319
320DESCRIPTION
321   Sets the mode and fix frequency for the tracking session.
322
323DEPENDENCIES
324   None
325
326RETURN VALUE
327   0: success
328
329SIDE EFFECTS
330   N/A
331
332===========================================================================*/
333static int  loc_set_position_mode(GpsPositionMode mode,
334                                  GpsPositionRecurrence recurrence,
335                                  uint32_t min_interval,
336                                  uint32_t preferred_accuracy,
337                                  uint32_t preferred_time)
338{
339    ENTRY_LOG();
340    LocPositionMode locMode;
341    switch (mode) {
342    case GPS_POSITION_MODE_MS_BASED:
343        locMode = LOC_POSITION_MODE_MS_BASED;
344        break;
345    case GPS_POSITION_MODE_MS_ASSISTED:
346        locMode = LOC_POSITION_MODE_MS_ASSISTED;
347        break;
348    default:
349        locMode = LOC_POSITION_MODE_STANDALONE;
350        break;
351    }
352    int ret_val = loc_eng_set_position_mode(loc_afw_data, locMode,
353                                            recurrence, min_interval,
354                                            preferred_accuracy, preferred_time);
355
356    EXIT_LOG(%d, ret_val);
357    return ret_val;
358}
359
360/*===========================================================================
361FUNCTION    loc_inject_time
362
363DESCRIPTION
364   This is used by Java native function to do time injection.
365
366DEPENDENCIES
367   None
368
369RETURN VALUE
370   0
371
372SIDE EFFECTS
373   N/A
374
375===========================================================================*/
376static int loc_inject_time(GpsUtcTime time, int64_t timeReference, int uncertainty)
377{
378    ENTRY_LOG();
379    int ret_val = loc_eng_inject_time(loc_afw_data, time, timeReference, uncertainty);
380
381    EXIT_LOG(%d, ret_val);
382    return ret_val;
383}
384
385
386/*===========================================================================
387FUNCTION    loc_inject_location
388
389DESCRIPTION
390   This is used by Java native function to do location injection.
391
392DEPENDENCIES
393   None
394
395RETURN VALUE
396   0          : Successful
397   error code : Failure
398
399SIDE EFFECTS
400   N/A
401===========================================================================*/
402static int loc_inject_location(double latitude, double longitude, float accuracy)
403{
404    ENTRY_LOG();
405    int ret_val = loc_eng_inject_location(loc_afw_data, latitude, longitude, accuracy);
406
407    EXIT_LOG(%d, ret_val);
408    return ret_val;
409}
410
411
412/*===========================================================================
413FUNCTION    loc_delete_aiding_data
414
415DESCRIPTION
416   This is used by Java native function to delete the aiding data. The function
417   updates the global variable for the aiding data to be deleted. If the GPS
418   engine is off, the aiding data will be deleted. Otherwise, the actual action
419   will happen when gps engine is turned off.
420
421DEPENDENCIES
422   Assumes the aiding data type specified in GpsAidingData matches with
423   LOC API specification.
424
425RETURN VALUE
426   None
427
428SIDE EFFECTS
429   N/A
430
431===========================================================================*/
432static void loc_delete_aiding_data(GpsAidingData f)
433{
434    ENTRY_LOG();
435    loc_eng_delete_aiding_data(loc_afw_data, f);
436
437    EXIT_LOG(%s, VOID_RET);
438}
439
440#ifdef QCOM_FEATURE_ULP
441/*===========================================================================
442FUNCTION    loc_update_criteria
443
444DESCRIPTION
445   This is used to inform the ULP module of new unique criteria that are passed
446   in by the applications
447DEPENDENCIES
448   N/A
449
450RETURN VALUE
451   0: success
452
453SIDE EFFECTS
454   N/A
455
456===========================================================================*/
457static int loc_update_criteria(UlpLocationCriteria criteria)
458{
459    ENTRY_LOG();
460    int ret_val = loc_eng_update_criteria(loc_afw_data, criteria);
461
462    EXIT_LOG(%d, ret_val);
463    return ret_val;
464}
465#endif
466
467/*===========================================================================
468FUNCTION    loc_get_extension
469
470DESCRIPTION
471   Get the gps extension to support XTRA.
472
473DEPENDENCIES
474   N/A
475
476RETURN VALUE
477   The GPS extension interface.
478
479SIDE EFFECTS
480   N/A
481
482===========================================================================*/
483static const void* loc_get_extension(const char* name)
484{
485    ENTRY_LOG();
486    const void* ret_val = NULL;
487
488   if (strcmp(name, GPS_XTRA_INTERFACE) == 0)
489   {
490      ret_val = &sLocEngXTRAInterface;
491   }
492
493   else if (strcmp(name, AGPS_INTERFACE) == 0)
494   {
495      ret_val = &sLocEngAGpsInterface;
496   }
497
498   else if (strcmp(name, GPS_NI_INTERFACE) == 0)
499   {
500      ret_val = &sLocEngNiInterface;
501   }
502
503   else if (strcmp(name, AGPS_RIL_INTERFACE) == 0)
504   {
505      ret_val = &sLocEngAGpsRilInterface;
506   }
507#ifdef QCOM_FEATURE_ULP
508   else if (strcmp(name, ULP_RAW_CMD_INTERFACE) == 0)
509   {
510      ret_val = &sLocEngInjectRawCmdInterface;
511   }
512#endif
513   else
514   {
515      LOC_LOGE ("get_extension: Invalid interface passed in\n");
516   }
517
518    EXIT_LOG(%p, ret_val);
519    return ret_val;
520}
521
522/*===========================================================================
523FUNCTION    loc_agps_init
524
525DESCRIPTION
526   Initialize the AGps interface.
527
528DEPENDENCIES
529   NONE
530
531RETURN VALUE
532   0
533
534SIDE EFFECTS
535   N/A
536
537===========================================================================*/
538static void loc_agps_init(AGpsCallbacks* callbacks)
539{
540    ENTRY_LOG();
541    loc_eng_agps_init(loc_afw_data, callbacks);
542    EXIT_LOG(%s, VOID_RET);
543}
544
545/*===========================================================================
546FUNCTION    loc_agps_open
547
548DESCRIPTION
549   This function is called when on-demand data connection opening is successful.
550It should inform ARM 9 about the data open result.
551
552DEPENDENCIES
553   NONE
554
555RETURN VALUE
556   0
557
558SIDE EFFECTS
559   N/A
560
561===========================================================================*/
562#ifdef QCOM_FEATURE_IPV6
563static int loc_agps_open(AGpsType agpsType,
564                         const char* apn, AGpsBearerType bearerType)
565{
566    ENTRY_LOG();
567    int ret_val = loc_eng_agps_open(loc_afw_data, agpsType, apn, bearerType);
568
569    EXIT_LOG(%d, ret_val);
570    return ret_val;
571}
572#else
573static int loc_agps_open(const char* apn)
574{
575    ENTRY_LOG();
576    int ret_val = loc_eng_agps_open(loc_afw_data, apn);
577
578    EXIT_LOG(%d, ret_val);
579    return ret_val;
580}
581#endif
582
583/*===========================================================================
584FUNCTION    loc_agps_closed
585
586DESCRIPTION
587   This function is called when on-demand data connection closing is done.
588It should inform ARM 9 about the data close result.
589
590DEPENDENCIES
591   NONE
592
593RETURN VALUE
594   0
595
596SIDE EFFECTS
597   N/A
598
599===========================================================================*/
600#ifdef QCOM_FEATURE_IPV6
601static int loc_agps_closed(AGpsType agpsType)
602{
603    ENTRY_LOG();
604    int ret_val = loc_eng_agps_closed(loc_afw_data, agpsType);
605
606    EXIT_LOG(%d, ret_val);
607    return ret_val;
608}
609#else
610static int loc_agps_closed()
611{
612    ENTRY_LOG();
613    int ret_val = loc_eng_agps_closed(loc_afw_data);
614
615    EXIT_LOG(%d, ret_val);
616    return ret_val;
617}
618#endif
619
620/*===========================================================================
621FUNCTION    loc_agps_open_failed
622
623DESCRIPTION
624   This function is called when on-demand data connection opening has failed.
625It should inform ARM 9 about the data open result.
626
627DEPENDENCIES
628   NONE
629
630RETURN VALUE
631   0
632
633SIDE EFFECTS
634   N/A
635
636===========================================================================*/
637#ifdef QCOM_FEATURE_IPV6
638int loc_agps_open_failed(AGpsType agpsType)
639{
640    ENTRY_LOG();
641    int ret_val = loc_eng_agps_open_failed(loc_afw_data, agpsType);
642
643    EXIT_LOG(%d, ret_val);
644    return ret_val;
645}
646#else
647int loc_agps_open_failed()
648{
649    ENTRY_LOG();
650    int ret_val = loc_eng_agps_open_failed(loc_afw_data);
651
652    EXIT_LOG(%d, ret_val);
653    return ret_val;
654}
655#endif
656
657/*===========================================================================
658FUNCTION    loc_agps_set_server
659
660DESCRIPTION
661   If loc_eng_set_server is called before loc_eng_init, it doesn't work. This
662   proxy buffers server settings and calls loc_eng_set_server when the client is
663   open.
664
665DEPENDENCIES
666   NONE
667
668RETURN VALUE
669   0
670
671SIDE EFFECTS
672   N/A
673
674===========================================================================*/
675static int loc_agps_set_server(AGpsType type, const char* hostname, int port)
676{
677    ENTRY_LOG();
678    LocServerType serverType;
679    switch (type) {
680    case AGPS_TYPE_SUPL:
681        serverType = LOC_AGPS_SUPL_SERVER;
682        break;
683    case AGPS_TYPE_C2K:
684        serverType = LOC_AGPS_CDMA_PDE_SERVER;
685        break;
686    }
687    int ret_val = loc_eng_set_server_proxy(loc_afw_data, serverType, hostname, port);
688
689    EXIT_LOG(%d, ret_val);
690    return ret_val;
691}
692
693/*===========================================================================
694FUNCTION    loc_xtra_init
695
696DESCRIPTION
697   Initialize XTRA module.
698
699DEPENDENCIES
700   None
701
702RETURN VALUE
703   0: success
704
705SIDE EFFECTS
706   N/A
707
708===========================================================================*/
709static int loc_xtra_init(GpsXtraCallbacks* callbacks)
710{
711    ENTRY_LOG();
712    int ret_val = loc_eng_xtra_init(loc_afw_data, callbacks);
713
714    EXIT_LOG(%d, ret_val);
715    return ret_val;
716}
717
718
719/*===========================================================================
720FUNCTION    loc_xtra_inject_data
721
722DESCRIPTION
723   Initialize XTRA module.
724
725DEPENDENCIES
726   None
727
728RETURN VALUE
729   0: success
730
731SIDE EFFECTS
732   N/A
733
734===========================================================================*/
735static int loc_xtra_inject_data(char* data, int length)
736{
737    ENTRY_LOG();
738    int ret_val = loc_eng_xtra_inject_data(loc_afw_data, data, length);
739
740    EXIT_LOG(%d, ret_val);
741    return ret_val;
742}
743
744/*===========================================================================
745FUNCTION    loc_ni_init
746
747DESCRIPTION
748   This function initializes the NI interface
749
750DEPENDENCIES
751   NONE
752
753RETURN VALUE
754   None
755
756SIDE EFFECTS
757   N/A
758
759===========================================================================*/
760void loc_ni_init(GpsNiCallbacks *callbacks)
761{
762    ENTRY_LOG();
763    loc_eng_ni_init(loc_afw_data, callbacks);
764    EXIT_LOG(%s, VOID_RET);
765}
766
767/*===========================================================================
768FUNCTION    loc_ni_respond
769
770DESCRIPTION
771   This function sends an NI respond to the modem processor
772
773DEPENDENCIES
774   NONE
775
776RETURN VALUE
777   None
778
779SIDE EFFECTS
780   N/A
781
782===========================================================================*/
783void loc_ni_respond(int notif_id, GpsUserResponseType user_response)
784{
785    ENTRY_LOG();
786    loc_eng_ni_respond(loc_afw_data, notif_id, user_response);
787    EXIT_LOG(%s, VOID_RET);
788}
789
790// Below stub functions are members of sLocEngAGpsRilInterface
791static void loc_agps_ril_init( AGpsRilCallbacks* callbacks ) {}
792static void loc_agps_ril_set_ref_location(const AGpsRefLocation *agps_reflocation, size_t sz_struct) {}
793static void loc_agps_ril_set_set_id(AGpsSetIDType type, const char* setid) {}
794static void loc_agps_ril_ni_message(uint8_t *msg, size_t len) {}
795static void loc_agps_ril_update_network_state(int connected, int type, int roaming, const char* extra_info) {}
796
797/*===========================================================================
798FUNCTION    loc_agps_ril_update_network_availability
799
800DESCRIPTION
801   Sets data call allow vs disallow flag to modem
802   This is the only member of sLocEngAGpsRilInterface implemented.
803
804DEPENDENCIES
805   None
806
807RETURN VALUE
808   0: success
809
810SIDE EFFECTS
811   N/A
812
813===========================================================================*/
814static void loc_agps_ril_update_network_availability(int available, const char* apn)
815{
816    ENTRY_LOG();
817    loc_eng_agps_ril_update_network_availability(loc_afw_data, available, apn);
818    EXIT_LOG(%s, VOID_RET);
819}
820
821#ifdef QCOM_FEATURE_ULP
822/*===========================================================================
823FUNCTION    loc_inject_raw_command
824
825DESCRIPTION
826   This is used to send special test modem commands from the applications
827   down into the HAL
828DEPENDENCIES
829   N/A
830
831RETURN VALUE
832   0: success
833
834SIDE EFFECTS
835   N/A
836
837===========================================================================*/
838static bool loc_inject_raw_command(char* command, int length)
839{
840    ENTRY_LOG();
841    int ret_val = loc_eng_inject_raw_command(loc_afw_data, command, length);
842    EXIT_LOG(%s, loc_logger_boolStr[ret_val!=0]);
843    return ret_val;
844}
845#endif
846
847
848static void loc_cb(GpsLocation* location, void* locExt)
849{
850    ENTRY_LOG();
851    if (NULL != gps_loc_cb && NULL != location) {
852#ifdef QCOM_FEATURE_ULP
853        CALLBACK_LOG_CALLFLOW("location_cb - from", %d, location->position_source);
854#else
855        CALLBACK_LOG_CALLFLOW("location_cb - at", %llu, location->timestamp);
856#endif
857        gps_loc_cb(location);
858    }
859    EXIT_LOG(%s, VOID_RET);
860}
861
862static void sv_cb(GpsSvStatus* sv_status, void* svExt)
863{
864    ENTRY_LOG();
865    if (NULL != gps_sv_cb) {
866        CALLBACK_LOG_CALLFLOW("sv_status_cb -", %d, sv_status->num_svs);
867        gps_sv_cb(sv_status);
868    }
869    EXIT_LOG(%s, VOID_RET);
870}
871