From 115162ec011e49ea985ffad5615d926eb0f50fdb Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Sat, 13 Aug 2011 00:00:52 +0100 Subject: [PATCH] leo: gps, and some overlay config updates * Updated libgps to v2.0 NMEA (tytung) * Fixed leo.mk, so that custom gps.conf is included * removed duplicate entry in frameworks config.xml * enabled allow_in_call_touch_ui in the phone app Change-Id: I07bb3512954a6457d46a2d63a35498bfd08ed57b --- gps.conf | 34 +++++++++++++ gps_eu.conf | 51 +++++++++++++++++++ leo.mk | 9 ++-- leo_eu.mk | 4 +- libgps/leo-gps-rpc.c | 45 +++++++++++----- libgps/leo-gps.c | 17 +------ .../base/core/res/res/values/config.xml | 3 +- .../packages/apps/Phone/res/values/config.xml | 2 +- 8 files changed, 129 insertions(+), 36 deletions(-) create mode 100644 gps_eu.conf diff --git a/gps.conf b/gps.conf index 674147d..2628719 100644 --- a/gps.conf +++ b/gps.conf @@ -15,3 +15,37 @@ SUPL_HOST=FQDN SUPL_PORT=7275 SUPL_TLS_HOST=FQDN SUPL_TLS_CERT=/etc/SuplRootCert + +########################################### +# Enable/disable automatic (periodic) # +# download requests of gpsOneXTRA # +# assistance data to client # +# Range: 0 to 1 # +# Default: 0 (Disabled) # +########################################### +GPS1_XTRA_AUTO_DOWNLOAD_ENABLED=0 + +########################################### +# Time (in hours) between automatic # +# download requests of gpsOneXTRA # +# assistance data to client # +# Range: 1 to 168 (168 = hr in a week) # +# Default: 24 hr # +########################################### +GPS1_XTRA_DOWNLOAD_INTERVAL=24 + +########################################### +# Enable/disable to shutdown the gpsOne # +# engine properly on GPS off # +# Range: 0 to 1 # +# Default: 1 (Enabled) # +########################################### +GPS1_CLEANUP_ENABLED=1 + +########################################### +# Time (in seconds) between invoking # +# pdsm_get_position() # +# Range: 2 to 120 # +# Default: 2 seconds # +########################################### +GPS1_SESSION_TIMEOUT=2 diff --git a/gps_eu.conf b/gps_eu.conf new file mode 100644 index 0000000..f865419 --- /dev/null +++ b/gps_eu.conf @@ -0,0 +1,51 @@ +NTP_SERVER=europe.pool.ntp.org +XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra.bin +XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra.bin +XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra.bin +NTP_SERVER=0.europe.pool.ntp.org +NTP_SERVER=1.europe.pool.ntp.org +NTP_SERVER=2.europe.pool.ntp.org +NTP_SERVER=3.europe.pool.ntp.org +XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra.bin +XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra.bin +XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra.bin +SUPL_HOST=supl.google.com +SUPL_PORT=7276 +SUPL_HOST=FQDN +SUPL_PORT=7275 +SUPL_TLS_HOST=FQDN +SUPL_TLS_CERT=/etc/SuplRootCert + +########################################### +# Enable/disable automatic (periodic) # +# download requests of gpsOneXTRA # +# assistance data to client # +# Range: 0 to 1 # +# Default: 0 (Disabled) # +########################################### +GPS1_XTRA_AUTO_DOWNLOAD_ENABLED=0 + +########################################### +# Time (in hours) between automatic # +# download requests of gpsOneXTRA # +# assistance data to client # +# Range: 1 to 168 (168 = hr in a week) # +# Default: 24 hr # +########################################### +GPS1_XTRA_DOWNLOAD_INTERVAL=24 + +########################################### +# Enable/disable to shutdown the gpsOne # +# engine properly on GPS off # +# Range: 0 to 1 # +# Default: 1 (Enabled) # +########################################### +GPS1_CLEANUP_ENABLED=1 + +########################################### +# Time (in seconds) between invoking # +# pdsm_get_position() # +# Range: 2 to 120 # +# Default: 2 seconds # +########################################### +GPS1_SESSION_TIMEOUT=2 diff --git a/leo.mk b/leo.mk index daac961..38968ea 100755 --- a/leo.mk +++ b/leo.mk @@ -34,12 +34,12 @@ PRODUCT_PROPERTY_OVERRIDES += \ ro.ril.enable.a53.HTC-ITA=1 \ ro.ril.enable.a52=0 \ ro.ril.enable.a53=1 \ - ro.ril.enable.dtm = 1 \ - ro.ril.gprsclass = 12 \ + ro.ril.enable.dtm=1 \ + ro.ril.gprsclass=12 \ ro.ril.hsdpa.category=8 \ ro.ril.hsupa.category=5 \ ro.ril.hsxpa=2 \ - mobiledata.interfaces=rmnet0,rmnet1,rmnet2,ppp \ + mobiledata.interfaces=rmnet0,rmnet1,rmnet2,ppp0 \ wifi.interface=eth0 \ wifi.supplicant_scan_interval=15 @@ -148,7 +148,8 @@ LOCAL_KERNEL := $(TARGET_PREBUILT_KERNEL) endif # The gps config appropriate for this device -$(call inherit-product, device/common/gps/gps_as_supl.mk) +PRODUCT_COPY_FILES += \ + device/htc/leo/gps.conf:system/etc/gps.conf PRODUCT_COPY_FILES += \ $(LOCAL_KERNEL):kernel diff --git a/leo_eu.mk b/leo_eu.mk index cf53683..83d2236 100755 --- a/leo_eu.mk +++ b/leo_eu.mk @@ -20,7 +20,9 @@ # # The gps config appropriate for this device -$(call inherit-product, device/common/gps/gps_eu_supl.mk) +PRODUCT_COPY_FILES += \ + device/htc/leo/gps_eu.conf:system/etc/gps.conf + # The rest of the configuration is inherited from a generic config $(call inherit-product, device/htc/leo/leo.mk) diff --git a/libgps/leo-gps-rpc.c b/libgps/leo-gps-rpc.c index 7052a1b..3cd1c9d 100644 --- a/libgps/leo-gps-rpc.c +++ b/libgps/leo-gps-rpc.c @@ -86,7 +86,7 @@ struct SVCXPRT { } while(0); static uint32_t client_IDs[16];//highest known value is 0xb -static uint32_t has_fix=0; +static uint32_t no_fix=1; #if ENABLE_NMEA static uint32_t use_nmea=1; #else @@ -646,7 +646,7 @@ void dispatch_pdsm_pd(uint32_t *data) { } if(event&PDSM_PD_EVENT_GPS_DONE) { D("PDSM_PD_EVENT_GPS_DONE"); - has_fix = 0; + no_fix = 1; } GpsLocation fix; fix.flags = 0; @@ -686,7 +686,7 @@ void dispatch_pdsm_pd(uint32_t *data) { fix.timestamp *= 1000; //ms fix.flags |= GPS_LOCATION_HAS_LAT_LONG; - has_fix = 1; + no_fix = 0; if (ntohl(data[75])) { fix.flags |= GPS_LOCATION_HAS_ACCURACY; @@ -749,7 +749,10 @@ void dispatch_pdsm_ext(uint32_t *data) { int i; if (use_nmea) return; - if (has_fix) return; + + no_fix++; + if (no_fix < 2) return; + if (no_fix == UINT32_MAX) no_fix = 2; // avoid overflow ret.num_svs=ntohl(data[8]); D("%s() is called. num_svs=%d", __FUNCTION__, ret.num_svs); @@ -771,9 +774,7 @@ void dispatch_pdsm_ext(uint32_t *data) { } //ret.used_in_fix_mask=ntohl(data[9]); ret.used_in_fix_mask=0; - if (ret.num_svs) { - update_gps_svstatus(&ret); - } + update_gps_svstatus(&ret); } void dispatch_pdsm_xtra_req(uint8_t *data) { @@ -837,10 +838,11 @@ void dispatch(struct svc_req* a, registered_server* svc) { svc_sendreply(svc, xdr_int, &result); } -static uint8_t CHECKED[3] = {0}; +static uint8_t CHECKED[4] = {0}; static uint8_t XTRA_AUTO_DOWNLOAD_ENABLED = 0; -static uint8_t XTRA_DOWNLOAD_INTERVAL = 24; +static uint8_t XTRA_DOWNLOAD_INTERVAL = 24; // hours static uint8_t CLEANUP_ENABLED = 1; +static uint8_t SESSION_TIMEOUT = 2; // seconds uint8_t get_cleanup_value() { D("%s() is called: %d", __FUNCTION__, CLEANUP_ENABLED); @@ -857,12 +859,13 @@ int parse_gps_conf() { char *check_auto_download = "GPS1_XTRA_AUTO_DOWNLOAD_ENABLED"; char *check_interval = "GPS1_XTRA_DOWNLOAD_INTERVAL"; char *check_cleanup = "GPS1_CLEANUP_ENABLED"; + char *check_timeout = "GPS1_SESSION_TIMEOUT"; char *result; char str[256]; int i = -1; while (fscanf(file, "%s", str) != EOF) { - //printf("%s (%d)\n", str, strlen(str)); + //D("%s (%d)\n", str, strlen(str)); if (!CHECKED[1]) { result = strstr(str, check_auto_download); if (result != NULL) { @@ -892,6 +895,16 @@ int parse_gps_conf() { CHECKED[2] = 1; } } + if (!CHECKED[3]) { + result = strstr(str, check_timeout); + if (result != NULL) { + result = result+strlen(check_timeout)+1; + i = atoi(result); + if (i>1 && i<121) + SESSION_TIMEOUT = i; + CHECKED[3] = 1; + } + } } fclose(file); return 0; @@ -994,9 +1007,15 @@ int gps_xtra_inject_time_info(GpsUtcTime time, int64_t timeReference, int uncert return res; } -void gps_get_position(int timeout) +void gps_get_position() { - D("%s() is called", __FUNCTION__); +#if GPS_DEBUG + struct tm tm; + time_t now = time(NULL); + gmtime_r( &now, &tm ); + long time = mktime(&tm); + D("%s() is called: %ld", __FUNCTION__, time); +#endif pdsm_get_position(_clnt, 0, 0, 1, @@ -1008,7 +1027,7 @@ void gps_get_position(int timeout) 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 50, timeout, + 1, 50, SESSION_TIMEOUT, client_IDs[2]); } diff --git a/libgps/leo-gps.c b/libgps/leo-gps.c index b47894d..12005ff 100644 --- a/libgps/leo-gps.c +++ b/libgps/leo-gps.c @@ -967,12 +967,6 @@ Exit: return NULL; } -uint64_t get_usleep_time(int fix_freq) { - uint64_t microseconds; - microseconds = (fix_freq * 1000000) - 500000; - return microseconds; -} - #if ENABLE_NMEA static void* gps_timer_thread( void* arg ) { D("%s() running", __FUNCTION__); @@ -1008,7 +1002,7 @@ static void* gps_timer_thread( void* arg ) { GPS_STATE_UNLOCK_FIX(state); - uint64_t microseconds = get_usleep_time(state->fix_freq); + uint64_t microseconds = (state->fix_freq * 1000000) - 500000; usleep(microseconds); //D("%s() usleep(%ld)", __FUNCTION__, microseconds); @@ -1020,13 +1014,6 @@ static void* gps_timer_thread( void* arg ) { #endif void pdsm_pd_callback() { -#if DUMP_DATA - struct tm tm; - time_t now = time(NULL); - gmtime_r( &now, &tm ); - long time = mktime(&tm); - D("%s() is called: %ld", __FUNCTION__, time); -#endif pthread_cond_signal(&get_pos_ready_cond); } @@ -1037,7 +1024,7 @@ static void* gps_get_position_thread( void* arg ) { { while(started) { - gps_get_position(s->fix_freq); + gps_get_position(); pthread_mutex_lock(&get_pos_ready_mutex); pthread_cond_wait(&get_pos_ready_cond, &get_pos_ready_mutex); pthread_mutex_unlock(&get_pos_ready_mutex); diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml index bf38847..7f224d7 100644 --- a/overlay/frameworks/base/core/res/res/values/config.xml +++ b/overlay/frameworks/base/core/res/res/values/config.xml @@ -32,8 +32,6 @@ true - false - true @@ -182,6 +180,7 @@ false + true false false diff --git a/overlay/packages/apps/Phone/res/values/config.xml b/overlay/packages/apps/Phone/res/values/config.xml index 268df63..f4a5d45 100644 --- a/overlay/packages/apps/Phone/res/values/config.xml +++ b/overlay/packages/apps/Phone/res/values/config.xml @@ -19,7 +19,7 @@ true - false + true