[TBT][runtime-info][Non-ACR][TSAM-5470][Fixed gps functionality of runtime info] 49/77149/3
authorNibha Sharma <nibha.sharma@samsung.com>
Wed, 29 Jun 2016 01:25:26 +0000 (10:25 +0900)
committerNibha Sharma <nibha.sharma@samsung.com>
Wed, 29 Jun 2016 01:42:53 +0000 (10:42 +0900)
Change-Id: I9f76f3337bfeb62a0b414c68c76f672544edd348
Signed-off-by: Nibha Sharma <nibha.sharma@samsung.com>
release/binary-armv7l/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 8f7ab1538ddc4207e4ab89f93edb8455ffdfc569..5b90dde09ebb102490f4ad737cc51a062d3929f0 100644 (file)
Binary files a/release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk and b/release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk differ
index 17fc49ae005b4bdb5a454b5c38167b7c2c934c2e..3b569d06d36d479b01b4977f7ad47ccf617cb347 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 64634ae43d2d8f63df40186e5cbe9e1d502648f7..98cb774e3ebcb1fa858ead81da69189c6a4acbaa 100644 (file)
@@ -38,6 +38,7 @@
 struct _runtimeinfo_view
 {
        common_view* view;
+       location_manager_h manager;
 
        Evas_Object *info_label;
        Evas_Object *vibrate_label;
@@ -61,6 +62,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);
+
 static bool is_audiojack_not_supported = false;
 static bool is_gps_not_supported = false;
 static bool is_bluetooth_not_supported = false;
@@ -279,6 +283,35 @@ runtimeinfo_view *runtimeinfo_view_add(Evas_Object *navi, tbt_info *tbt_info, El
        else
        {
 
+                       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));
 
@@ -603,6 +636,34 @@ static void _app_destroy_cb(void* this)
                elm_genlist_item_update(view->view->item);
        }
 
+       if(is_gps_not_supported == false)
+               {
+
+                 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);
 }
@@ -967,5 +1028,40 @@ 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