1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375
| diff --git a/libgps/Android.mk b/libgps/Android.mk index 0a96c4b..56bc3d6 100755 --- a/libgps/Android.mk +++ b/libgps/Android.mk @@ -8,9 +8,9 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/halheader \ #LOCAL_MODULE_RELATIVE_PATH := hw LOCAL_VENDOR_MODULE:= true -LOCAL_SHARED_LIBRARIES := liblog libcutils libhardware libc libutils +LOCAL_SHARED_LIBRARIES := liblog libcutils libhardware libc libutils libutilscallstack -LOCAL_SRC_FILES := unicore_gps.c unicore_geoid.c unicore_agnss.c cJSON.c unicore_fw_update.c unicore_fw.c +LOCAL_SRC_FILES := unicore_gps.c unicore_geoid.c unicore_agnss.c cJSON.c unicore_fw_update.c unicore_fw.c callstack.cpp LOCAL_C_FLAGS += -Wno-unused-parameter -D__NO_XPRINTF__ diff --git a/libgps/unicore_config.c b/libgps/unicore_config.c index af919f6..fd5bbcc 100755 --- a/libgps/unicore_config.c +++ b/libgps/unicore_config.c @@ -23,11 +23,8 @@ #define DFR(...) ALOGD(__VA_ARGS__) -#ifdef GPS_DEBUG -# define D(...) ALOGD(__VA_ARGS__) -#else -# define D(...) ((void)0) -#endif +#define D(...) ALOGD(__VA_ARGS__) + #define NR_LOGS 10 #define LOG_FILESIZE (100*1024*1024) diff --git a/libgps/unicore_config.h b/libgps/unicore_config.h index bd1425d..e0344a2 100755 --- a/libgps/unicore_config.h +++ b/libgps/unicore_config.h @@ -35,9 +35,9 @@ #define GPS_DEVICE "/dev/ttyHS2" #endif -static int current_bps = 115200; +static int current_bps = 460800; -static int default_bps = 9600; +static int default_bps = 460800; #define UDP_PORT 5744 #define TCP_PORT 5744 diff --git a/libgps/unicore_gps.c b/libgps/unicore_gps.c index d0b6cb8..0165ec6 100755 --- a/libgps/unicore_gps.c +++ b/libgps/unicore_gps.c @@ -51,9 +51,32 @@ #include <hardware/hardware.h> #include "unicore_agnss.h" #include "unicore_config.h" - - - +#include "callstack.h" + + + + + + + + + + + + + + +static char* testNmeaError = "$GPGSA,A,2,01,02,03,06,09,14,17,19,22,28,30,,1.0,0.7,0.7*3F\n\ +$GPGSV,4,1,16,01,09,049,30,02,15,253,36,03,35,052,43,06,45,268,35,1*6F\n\ +$GPGSV,4,2,16,09,05,136,24,14,64,172,34,17,57,012,47,22,11,040,31,1*6D\n\ +$GPGSV,4,3,16,28,79,234,40,04,04,104,,19,45,330,,24,02,299,,1*6B\n\ +$GPGSV,4,4,16,30,06,194,,39,,,34,41,,,39,50,,,38,1*56\n\ +$GPGGA,055957.00,2846.901314,N,11551.149287,E,1,11,0.7,55.4,M,-5.0,M,,*4A\n\ +$GPVTG,76.0,T,79.6,M,24.9,N,46.1,K,A*26\n\ +$GPRMC,055957.00,A,2846.901314,N,11551.149287,E,24.9,76.0,020621,3.5,W,A*25\n\ +$BDGSA,A,2,01,02,03,07,08,10,13,14,,,,,1.0,0.7,0.7,4*32\n\ +$BDGSV,3,1,11,01,43,130,38,02,40,230,37,03,55,189,48,04,31,115,36,0,4*6B\n\ +$BDGSV,3,2,11,05,18,251,42,07,67,154,44,08293,39,10,77,281,39,0,4*6D"; static struct serial_icounter_struct icount, icount0; time_t icount_seconds; @@ -213,7 +236,7 @@ static int bGetFormalNMEA = 1; static int started = 0; static int continue_thread = 1; static int bOrionShutdown = 0; -static int agnss_thread = 0; +static int agnss_thread = 1; static char isNmeaThreadExited = 0; static char isTimerThreadExited = 0; @@ -2101,8 +2124,13 @@ static void gps_nmea_thread( void* arg ) #endif gps_log_write(buf, ret); tcp_write(tcp_fd, buf, ret); - for (nn = 0; nn < ret; nn++) - nmea_reader_addc(reader, buf[nn]); + + + + int realsize = strlen(testNmeaError); + for (nn = 0; nn < realsize; nn++) { + nmea_reader_addc(reader, testNmeaError[nn]); + } } else { DFR("Error on NMEA read :%s",strerror(errno)); if(errno != EAGAIN && errno != EINTR) { @@ -2420,15 +2448,14 @@ int gps_opentty(GpsState *state) if(strlen(prop) <= 0) { - state->fd = -1; - return state->fd; + + } - if(state->fd != -1) gps_closetty(state); do { - state->fd = open( prop, O_RDWR | O_NOCTTY | O_NONBLOCK); + state->fd = open( GPS_DEVICE, O_RDWR | O_NOCTTY | O_NONBLOCK); } while (state->fd < 0 && errno == EINTR); if (state->fd < 0) { @@ -2441,7 +2468,7 @@ int gps_opentty(GpsState *state) } do { - state->fd = open( device, O_RDWR | O_NOCTTY | O_NONBLOCK); + state->fd = open( GPS_DEVICE, O_RDWR | O_NOCTTY | O_NONBLOCK); } while (state->fd < 0 && errno == EINTR); if (state->fd < 0) @@ -2450,14 +2477,12 @@ int gps_opentty(GpsState *state) return -1; } } - D("gps will read from %s(fd=%d)", prop, state->fd); - load_config(); - if ( isatty( state->fd ) ) { + init_serial(state->fd, current_bps); - } + epoll_register( epoll_nmeafd, state->fd ); @@ -2607,6 +2632,7 @@ static int unicore_gps_init(GpsCallbacks* callbacks) GpsState* s = _gps_state; D("gps state initializing %d",s->init); + dumping_callstack("unicore_gps::unicore_gps_init"); s->callbacks = *callbacks; if (!s->init) @@ -2621,6 +2647,7 @@ static int unicore_gps_init(GpsCallbacks* callbacks) static void unicore_gps_cleanup(void) { GpsState* s = _gps_state; + dumping_callstack("unicore_gps::unicore_gps_cleanup"); D("%s: called", __FUNCTION__); @@ -2633,6 +2660,7 @@ static int unicore_gps_start() GpsState* s = _gps_state; D("%s: called", __FUNCTION__ ); + dumping_callstack("unicore_gps::unicore_gps_start"); if (!s->init) gps_state_init(s); @@ -2664,6 +2692,7 @@ static int unicore_gps_stop() GpsState* s = _gps_state; D("%s: called", __FUNCTION__ ); + dumping_callstack("unicore_gps::unicore_gps_stop"); if(gps_checkstate(s) == -1) { @@ -2708,6 +2737,7 @@ static void unicore_gps_set_fix_frequency(int freq) static int unicore_gps_inject_time(GpsUtcTime time, int64_t timeReference, int uncertainty) { D("__%s:%d__", __FUNCTION__, __LINE__); + dumping_callstack("unicore_gps::unicore_gps_inject_time"); (void)time; (void)timeReference; (void)uncertainty; @@ -2720,6 +2750,7 @@ static void unicore_gps_delete_aiding_data(GpsAidingData flags) int v; char cmd[32]; unsigned char sum, bits = 0; + dumping_callstack("unicore_gps::unicore_gps_delete_aiding_data"); if(flags == GPS_DELETE_ALL) { bits |= 0x95; @@ -2750,6 +2781,7 @@ static void unicore_gps_delete_aiding_data(GpsAidingData flags) static int unicore_gps_inject_location(double latitude, double longitude, float accuracy) { D("__%s:%d__", __FUNCTION__, __LINE__); + dumping_callstack("unicore_gps::unicore_gps_inject_location"); (void)latitude; (void)longitude; (void)accuracy; @@ -2762,6 +2794,7 @@ static int unicore_gps_set_position_mode(GpsPositionMode mode, GpsPositionRecurr GpsState* s = _gps_state; int v = (mode >> 4)&0x3; + dumping_callstack("unicore_gps::unicore_gps_set_position_mode"); (void)recurrence; (void)preferred_accuracy; @@ -2995,6 +3028,7 @@ static const void* unicore_gps_get_extension(const char* name) #endif } + dumping_callstack("unicore_gps::unicore_gps_get_extension"); D("%s: no GPS extension for %s is found", __FUNCTION__, name); return NULL; } @@ -3328,6 +3362,7 @@ static int open_gps(const struct hw_module_t* module, char const* name, struct gps_device_t *dev = malloc(sizeof(struct gps_device_t)); (void)name; + dumping_callstack("unicore_gps::open_gps"); memset(dev, 0, sizeof(*dev)); diff --git a/sepolicy/hal_gnss_unicore.te b/sepolicy/hal_gnss_unicore.te index dc0dcb4..d32bcd9 100755 --- a/sepolicy/hal_gnss_unicore.te +++ b/sepolicy/hal_gnss_unicore.te @@ -63,4 +63,7 @@ allow hal_gnss_unicore sdcard_type:file {create_file_perms rw_file_perms}; allow hal_gnss_unicore vendor_data_file:dir write; allow hal_gnss_unicore vendor_data_file:dir add_name; allow hal_gnss_unicore vendor_data_file:dir {rw_dir_perms create_dir_perms}; -allow hal_gnss_unicore vendor_data_file:file {create_file_perms rw_file_perms}; \ No newline at end of file +allow hal_gnss_unicore vendor_data_file:file {create_file_perms rw_file_perms}; + +allow hal_gnss_unicore vendor_file:file { entrypoint }; + diff --git a/service2_0/Android.mk b/service2_0/Android.mk index ee9b036..633559b 100755 --- a/service2_0/Android.mk +++ b/service2_0/Android.mk @@ -20,11 +20,12 @@ LOCAL_SHARED_LIBRARIES += \ libhidltransport \ libutils \ libhardware \ + libutilscallstack \ android.hardware.gnss@1.0 \ android.hardware.gnss@1.1 \ - android.hardware.gnss@2.0 \ - android.hardware.gnss.measurement_corrections@1.0 \ - android.hardware.gnss.visibility_control@1.0 + android.hardware.gnss@2.0 \ + android.hardware.gnss.measurement_corrections@1.0 \ + android.hardware.gnss.visibility_control@1.0 LOCAL_HEADER_LIBRARIES += \ diff --git a/service2_0/Gnss.cpp b/service2_0/Gnss.cpp index 9cc6bad..277c99f 100755 --- a/service2_0/Gnss.cpp +++ b/service2_0/Gnss.cpp @@ -31,6 +31,17 @@ #include <hardware/gps.h> #include <GnssUtils.h> #include "unicore.hpp" +#include <utils/CallStack.h> + +#define ALOGD_CALLSTACK(...) \ + do { \ + ALOGD(__VA_ARGS__); \ + android::CallStack callstack; \ + callstack.update(); \ + callstack.log(LOG_TAG, ANDROID_LOG_DEBUG, " "); \ + }while (false) + + using ::android::hardware::Status; using ::android::hardware::gnss::measurement_corrections::V1_0::implementation:: @@ -119,6 +130,7 @@ void Gnss::locationCb(GpsLocation* location) { ALOGE("%s: GNSS Callback Interface configured incorrectly", __func__); return; } + ALOGD_CALLSTACK("locationCb"); if (location == nullptr) { ALOGE("%s: Invalid location from GNSS HAL", __func__); @@ -287,6 +299,7 @@ void Gnss::nmeaCb(GpsUtcTime timestamp, const char* nmea, int length) { ALOGE("%s: GNSS Callback Interface configured incorrectly", __func__); return; } + android::hardware::hidl_string nmeaString; nmeaString.setToExternal(nmea, length); @@ -431,6 +444,7 @@ Return<bool> Gnss::start() { ALOGE("%s: Gnss interface is unavailable", __func__); return false; } + ALOGD_CALLSTACK("start"); return (mGnssIface->start() == 0); } @@ -440,11 +454,14 @@ Return<bool> Gnss::stop() { ALOGE("%s: Gnss interface is unavailable", __func__); return false; } + ALOGD_CALLSTACK("stop"); return (mGnssIface->stop() == 0); } Return<void> Gnss::cleanup() { + ALOGD_CALLSTACK("cleanup"); + if (mGnssIface == nullptr) { ALOGE("%s: Gnss interface is unavailable", __func__); } else { @@ -719,6 +736,7 @@ Return<bool> Gnss::setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) { ALOGE("%s: Gnss interface is unavailable", __func__); return false; } + ALOGD_CALLSTACK("setCallback_2_0"); if (callback == nullptr) { ALOGE("%s: Null callback ignored", __func__); @@ -765,6 +783,8 @@ Return<bool> Gnss::setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) { Return<void> Gnss::reportLocation(const V2_0::GnssLocation& location) const { std::unique_lock<std::mutex> lock(mMutex); + ALOGD_CALLSTACK("reportLocation"); + if (sGnssCallback_2_0 == nullptr) { ALOGE("%s: sGnssCallback 2.0 is null.", __func__); return Void(); diff --git a/service2_0/android.hardware.gnss@2.0-service-unicore.rc b/service2_0/android.hardware.gnss@2.0-service-unicore.rc index 11e8128..41330af 100755 --- a/service2_0/android.hardware.gnss@2.0-service-unicore.rc +++ b/service2_0/android.hardware.gnss@2.0-service-unicore.rc @@ -1,5 +1,5 @@ service gnss_service /vendor/bin/hw/android.hardware.gnss@2.0-service-unicore class hal user root - group root + group gps system root seclabel u:r:hal_gnss_unicore:s0
Z:\newcc\lagvm\lagvm\LINUX\android\vendor\unicore_gnss\libgps\callstack.cpp #include <utils/CallStack.h> extern "C" void dumping_callstack(const char* string);
void dumping_callstack(const char* string){ android::CallStack stack; stack.update(); stack.log(string); } Z:\newcc\lagvm\lagvm\LINUX\android\vendor\unicore_gnss\libgps\callstack.h void dumping_callstack();
|