From: Nibha Sharma Date: Wed, 29 Jun 2016 02:07:09 +0000 (+0900) Subject: [TBT][runtime-info][Non-ACR][TSAM-5470][Fixed gps functionality of runtime info] X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F56%2F77156%2F1;p=test%2Ftct%2Fnative%2Fbehavior.git [TBT][runtime-info][Non-ACR][TSAM-5470][Fixed gps functionality of runtime info] Change-Id: I183fa05359d63dabc982d83a07b5e9de46732b87 Signed-off-by: Nibha Sharma --- diff --git a/release/binary-arm/org.tizen.tbtcoreapp-1.0.0-arm.tpk b/release/binary-arm/org.tizen.tbtcoreapp-1.0.0-arm.tpk index 82dbcdc..7598d09 100644 Binary files a/release/binary-arm/org.tizen.tbtcoreapp-1.0.0-arm.tpk and b/release/binary-arm/org.tizen.tbtcoreapp-1.0.0-arm.tpk differ diff --git a/release/binary-x86/org.tizen.tbtcoreapp-1.0.0-i386.tpk b/release/binary-x86/org.tizen.tbtcoreapp-1.0.0-i386.tpk index b0e2486..9ae79b8 100644 Binary files a/release/binary-x86/org.tizen.tbtcoreapp-1.0.0-i386.tpk and b/release/binary-x86/org.tizen.tbtcoreapp-1.0.0-i386.tpk differ diff --git a/tbtcoreapp/src/view/tbt-runtimeinfo-view.c b/tbtcoreapp/src/view/tbt-runtimeinfo-view.c index 2b44f74..a4bd899 100644 --- a/tbtcoreapp/src/view/tbt-runtimeinfo-view.c +++ b/tbtcoreapp/src/view/tbt-runtimeinfo-view.c @@ -38,6 +38,7 @@ struct _runtimeinfo_view { common_view* view; + location_manager_h manager; Evas_Object *info_label; }; @@ -55,6 +56,9 @@ static void _rotate_state_changed_cb(runtime_info_key_e key, void *user_data); static void _location_state_changed_cb(runtime_info_key_e key, void *user_data); static void _wifi_state_changed_cb(runtime_info_key_e key, void *user_data); +static void _position_updated_cb(double latitude, double longitude, double altitude, time_t timestamp, void *data); +static void _gps_state_changed_gps_cb(location_service_state_e state, void *data); + /** * @function get_runtime_info_error * @since_tizen 2.3 @@ -278,6 +282,35 @@ runtimeinfo_view *runtimeinfo_view_add(Evas_Object *navi, tbt_info *tbt_info, El this->info_label = ui_utils_label_add(this->view->layout, "GPS: "); elm_label_line_wrap_set(this->info_label, ELM_WRAP_WORD); + ret = location_manager_create(LOCATIONS_METHOD_GPS, &this->manager); + RETVM_IF(ret != LOCATIONS_ERROR_NONE, NULL, "location_manager_create fail > Error = %d", ret); + + ret = location_manager_set_service_state_changed_cb(this->manager, _gps_state_changed_gps_cb, this); + if(ret != LOCATIONS_ERROR_NONE) + { + location_manager_destroy(this->manager); + ERR("location_manager_set_service_state_changed_cb fail > Error = %d", ret); + return NULL; + } + + ret = location_manager_set_position_updated_cb(this->manager, _position_updated_cb, 1, this); + if(ret != LOCATIONS_ERROR_NONE) + { + location_manager_unset_service_state_changed_cb( this->manager); + location_manager_destroy(this->manager); + ERR("location_manager_set_position_updated_cb fail > Error = %d", ret); + return NULL; + } + + ret = location_manager_start(this->manager); + if(ret != LOCATIONS_ERROR_NONE) + { + location_manager_unset_service_state_changed_cb( this->manager); + location_manager_unset_position_updated_cb( this->manager); + location_manager_destroy(this->manager); + ERR("location_manager_start fail > Error = %d", ret); + } + ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_GPS_STATUS , _gps_state_changed_cb, this); RETVM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED, NULL, "runtime_info_set_changed_cb failed : %s", get_runtime_info_error(ret)); @@ -581,6 +614,32 @@ static void _app_destroy_cb(void* this) view->view->tbt_info->result = TBT_INFO_RESULT_NOT_SUPPORTED; elm_genlist_item_update(view->view->item); } + if (view->view->tbt_info->apptype == TBT_APP_GPS_STATUS) + { + int err = location_manager_unset_service_state_changed_cb(view->manager); + if(err != LOCATIONS_ERROR_NONE) + { + DBG( "location_manager_unset_service_state_changed_cb fail > Error = %d", err); + } + + location_manager_unset_position_updated_cb(view->manager); + if(err != LOCATIONS_ERROR_NONE) + { + DBG( "location_manager_unset_position_updated_cb fail > Error = %d", err); + } + + err = location_manager_stop(view->manager); + if(err != LOCATIONS_ERROR_NONE) + { + DBG( "location_manager_stop fail > Error = %d", err); + } + + err= location_manager_destroy(view->manager); + if(err != LOCATIONS_ERROR_NONE) + { + DBG( "location_manager_destroy fail > Error = %d", err); + } + } SAFE_DELETE(view->view); SAFE_DELETE(view); @@ -946,5 +1005,42 @@ static void _wifi_state_changed_cb(runtime_info_key_e key, void *user_data) } +static void _position_updated_cb(double latitude, double longitude, double altitude, time_t timestamp, void *data){ + + runtimeinfo_view *this = NULL; + this = (runtimeinfo_view*) data; + + char buf[MAX_LENGTH] = {'\0'}; + snprintf(buf, MAX_LENGTH, "Latitude: %f", latitude); + snprintf(buf, MAX_LENGTH, "Longitude: %f", longitude); +} + + +/** + * @function _gps_state_changed_gps_cb + * @since_tizen 2.3 + * @description Gps State Changed Cb + * @parameter location_service_state_e: Location Service State E, void*: Void Pointer + * @return static void + */ +static void _gps_state_changed_gps_cb(location_service_state_e state, void *data) +{ + + runtimeinfo_view *this = NULL; + this = (runtimeinfo_view*) data; + + int err; + double dbLatitute, dbAltitute,dbLongitude,dbDirection,dbSpeed,dbClimb,dbHorizontal,dbVertical; + time_t timestamp; + location_accuracy_level_e level; + err = location_manager_get_location(this->manager,&dbAltitute,&dbLatitute,&dbLongitude,&dbClimb,&dbDirection,&dbSpeed,&level,&dbHorizontal,&dbVertical,×tamp); + RETM_IF(err != LOCATIONS_ERROR_NONE, "location_manager_get_location fail > Error = %d", err); + + char buf[MAX_LENGTH] = {'\0'}; + snprintf(buf, MAX_LENGTH, "Latitude: %f", dbLatitute); + snprintf(buf, MAX_LENGTH, "Longitude: %f", dbLongitude); +} + #endif +