[TBT][runtime-info][Non-ACR][TSAM-5470][Fixed gps functionality of runtime info] 56/77156/1
authorNibha Sharma <nibha.sharma@samsung.com>
Wed, 29 Jun 2016 02:07:09 +0000 (11:07 +0900)
committerNibha Sharma <nibha.sharma@samsung.com>
Wed, 29 Jun 2016 02:07:09 +0000 (11:07 +0900)
Change-Id: I183fa05359d63dabc982d83a07b5e9de46732b87
Signed-off-by: Nibha Sharma <nibha.sharma@samsung.com>
release/binary-arm/org.tizen.tbtcoreapp-1.0.0-arm.tpk
release/binary-x86/org.tizen.tbtcoreapp-1.0.0-i386.tpk
tbtcoreapp/src/view/tbt-runtimeinfo-view.c

index 82dbcdc4165301224fd4ba581b11d68fb1cf21fb..7598d09ecac234cef9a398e5337cc99fa2599a1c 100644 (file)
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
index b0e24860b043fc15265e713d4cff58a10d402a93..9ae79b83790fb56515214c22d4ec7d3d122c1225 100644 (file)
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
index 2b44f745b816652ca5d6408a37a9a0a3c16994d3..a4bd899cf3cb006ad89fcb76172d8cefba1b2253 100644 (file)
@@ -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,&timestamp);
+       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
+