Merge lp:~thomas-voss/location-service/fix-1347887 into lp:location-service/trunk

Proposed by Thomas Voß
Status: Merged
Approved by: Ricardo Salveti
Approved revision: 74
Merged at revision: 78
Proposed branch: lp:~thomas-voss/location-service/fix-1347887
Merge into: lp:location-service/trunk
Diff against target: 129 lines (+60/-6)
5 files modified
debian/libubuntu-location-service2.install.with-gps (+3/-0)
debian/source/format (+1/-1)
src/location_service/com/ubuntu/location/providers/gps/CMakeLists.txt (+4/-0)
src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.cpp (+42/-5)
src/location_service/com/ubuntu/location/providers/gps/gps.conf (+10/-0)
To merge this branch: bzr merge lp:~thomas-voss/location-service/fix-1347887
Reviewer Review Type Date Requested Status
Ricardo Salveti (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+228561@code.launchpad.net

Commit message

Add a vanilla gps.conf file and install it to /etc/gps.conf.
Make sure that expections thrown while trying to download GPS Xtra data do not abort the service.

Description of the change

Add a vanilla gps.conf file and install it to /etc/gps.conf.
Make sure that expections thrown while trying to download GPS Xtra data do not abort the service.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ricardo Salveti (rsalveti) wrote :

Looks good.

review: Approve
75. By Thomas Voß

Make sure that /etc/gps.conf is only opened for reading when the HAL is actually instantiated.

76. By Thomas Voß

Only install /etc/gps.conf on architectures that support it.

77. By Thomas Voß

Switch to dpkg-source 3.0.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added symlink 'debian/libubuntu-location-service2.install.amd64'
2=== target is u'libubuntu-location-service2.install.with-gps'
3=== added symlink 'debian/libubuntu-location-service2.install.armhf'
4=== target is u'libubuntu-location-service2.install.with-gps'
5=== added symlink 'debian/libubuntu-location-service2.install.i386'
6=== target is u'libubuntu-location-service2.install.with-gps'
7=== added file 'debian/libubuntu-location-service2.install.with-gps'
8--- debian/libubuntu-location-service2.install.with-gps 1970-01-01 00:00:00 +0000
9+++ debian/libubuntu-location-service2.install.with-gps 2014-07-30 14:15:59 +0000
10@@ -0,0 +1,3 @@
11+usr/lib/*/libubuntu-location-service.so.*
12+usr/lib/*/libubuntu-location-service-connectivity.so.*
13+/etc/gps.conf
14
15=== modified file 'debian/source/format'
16--- debian/source/format 2013-05-28 14:20:45 +0000
17+++ debian/source/format 2014-07-30 14:15:59 +0000
18@@ -1,1 +1,1 @@
19-1.0
20+3.0 (quilt)
21
22=== modified file 'src/location_service/com/ubuntu/location/providers/gps/CMakeLists.txt'
23--- src/location_service/com/ubuntu/location/providers/gps/CMakeLists.txt 2014-06-12 11:10:17 +0000
24+++ src/location_service/com/ubuntu/location/providers/gps/CMakeLists.txt 2014-07-30 14:15:59 +0000
25@@ -16,6 +16,8 @@
26 add_library(
27 gps
28
29+ gps.conf
30+
31 android_hardware_abstraction_layer.h
32 android_hardware_abstraction_layer.cpp
33
34@@ -37,5 +39,7 @@
35 -DCOM_UBUNTU_LOCATION_SERVICE_PROVIDERS_GPS ${ENABLED_PROVIDER_TARGETS_DEFINITIONS}
36 PARENT_SCOPE
37 )
38+
39+ install(FILES gps.conf DESTINATION /etc/)
40 endif (UBUNTU_HARDWARE_GPS_H)
41 endif (LOCATION_SERVICE_ENABLE_GPS_PROVIDER)
42
43=== modified file 'src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.cpp'
44--- src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.cpp 2014-07-11 12:56:40 +0000
45+++ src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.cpp 2014-07-30 14:15:59 +0000
46@@ -147,9 +147,19 @@
47
48 auto thiz = static_cast<android::HardwareAbstractionLayer*>(context);
49
50- auto xtra_gps_data = thiz->impl.gps_xtra_downloader->download_xtra_data(thiz->impl.gps_xtra_configuration);
51- if (not xtra_gps_data.empty())
52- u_hardware_gps_inject_xtra_data(thiz->impl.gps_handle, &xtra_gps_data.front(), xtra_gps_data.size());
53+ try
54+ {
55+ auto xtra_gps_data = thiz->impl.gps_xtra_downloader->download_xtra_data(thiz->impl.gps_xtra_configuration);
56+ if (not xtra_gps_data.empty())
57+ u_hardware_gps_inject_xtra_data(thiz->impl.gps_handle, &xtra_gps_data.front(), xtra_gps_data.size());
58+ } catch(const std::exception& e)
59+ {
60+ LOG(ERROR) << "Error downloading GPS Xtra data: " << e.what();
61+ } catch(...)
62+ {
63+ LOG(ERROR) << "Error downloading GPS Xtra data.";
64+ }
65+
66 }
67
68 void android::HardwareAbstractionLayer::on_gps_ni_notify(UHardwareGpsNiNotification* notification, void* context)
69@@ -607,16 +617,43 @@
70
71 namespace
72 {
73-std::ifstream etc_gps_conf{"/etc/gps.conf"};
74+android::GpsXtraDownloader::Configuration gps_xtra_downloader_configuration(std::istream& in)
75+{
76+ android::GpsXtraDownloader::Configuration config;
77+
78+ try
79+ {
80+ config = android::GpsXtraDownloader::Configuration::from_gps_conf_ini_file(in);
81+ return config;
82+ } catch(const std::exception& e)
83+ {
84+ // TODO(tvoss): We should log the error here
85+ // For now, we silently fallback to a set of default options.
86+ } catch(...)
87+ {
88+ // For now, we silently fallback to a set of default options.
89+ }
90+
91+ config.xtra_hosts =
92+ {
93+ "http://xtra1.gpsonextra.net/xtra2.bin",
94+ "http://xtra2.gpsonextra.net/xtra2.bin",
95+ "http://xtra3.gpsonextra.net/xtra2.bin"
96+ };
97+
98+ return config;
99+}
100 }
101
102 std::shared_ptr<gps::HardwareAbstractionLayer> gps::HardwareAbstractionLayer::create_default_instance()
103 {
104+ static std::ifstream in{"/etc/gps.conf"};
105+
106 static android::HardwareAbstractionLayer::Configuration config
107 {
108 {
109 create_xtra_downloader(),
110- android::GpsXtraDownloader::Configuration::from_gps_conf_ini_file(etc_gps_conf)
111+ gps_xtra_downloader_configuration(in)
112 }
113 };
114
115
116=== added file 'src/location_service/com/ubuntu/location/providers/gps/gps.conf'
117--- src/location_service/com/ubuntu/location/providers/gps/gps.conf 1970-01-01 00:00:00 +0000
118+++ src/location_service/com/ubuntu/location/providers/gps/gps.conf 2014-07-30 14:15:59 +0000
119@@ -0,0 +1,10 @@
120+# XTRA_SERVER_QUERY (1=on, 0=off)
121+# If XTRA_SERVER_QUERY is on, the XTRA_SERVERs listed
122+# below will be ignored, and instead the servers will
123+# be queried from the modem.
124+XTRA_SERVER_QUERY=0
125+# XTRA_SERVERs below are used only if XTRA_SERVER_QUERY
126+# is off.
127+XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra2.bin
128+XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra2.bin
129+XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra2.bin

Subscribers

People subscribed via source and target branches