Change batch behavior when display state changed 27/66127/1 accepted/tizen/common/20160419.143558 accepted/tizen/ivi/20160420.043614 accepted/tizen/mobile/20160420.043535 accepted/tizen/wearable/20160420.043558 submit/tizen/20160419.102151
authorkj7.sung <kj7.sung@samsung.com>
Fri, 15 Apr 2016 09:36:27 +0000 (18:36 +0900)
committerkj7.sung <kj7.sung@samsung.com>
Fri, 15 Apr 2016 09:36:27 +0000 (18:36 +0900)
Change-Id: I5efe4a439d8eae5c4c80c33d775af12229ea8d6d
Signed-off-by: kj7.sung <kj7.sung@samsung.com>
gps-plugin/src/gps_plugin_replay.c
packaging/lbs-server-plugin-replay.spec

index 37eafe7a282153767cf58b1ae2b0e857e5752c10..95895ff04592a990160e33dff101d6fa162ab00c 100644 (file)
@@ -49,11 +49,14 @@ typedef struct {
        FILE *batch_fd;
        int interval;
        int replay_mode;
+       int lcd_mode;
 
        int batch_mode;
+       int batch_interval;
        int batch_period;
        int num_of_batch;
        time_t batch_start_time;
+       gboolean is_flush;
 
        pos_data_t *pos_data;
        batch_data_t *batch_data;
@@ -147,13 +150,24 @@ void gps_plugin_replay_batch_event(pos_data_t *data, replay_timeout *timer)
                }
        }
 
-       if ((timestamp - timer->batch_start_time) >= timer->batch_period) {
+       if (timer->lcd_mode == VCONFKEY_PM_STATE_NORMAL) {
+               if ((timestamp - timer->batch_start_time) >= timer->batch_interval) {
+                       timer->is_flush = TRUE;
+               }
+       } else {
+               if ((timestamp - timer->batch_start_time) >= timer->batch_period) {
+                       timer->is_flush = TRUE;
+               }
+       }
+
+       if (timer->is_flush) {
                LOG_PLUGIN(DBG_LOW, "Batch invoked, Batch interval is expired or Batch stopped");
                gps_event_info_t gps_event;
                memset(&gps_event, 0, sizeof(gps_event_info_t));
 
                gps_event.event_id = GPS_EVENT_REPORT_BATCH;
                timer->batch_start_time = timestamp;
+               timer->is_flush = FALSE;
 
                if (timer->num_of_batch < 1) {
                        LOG_PLUGIN(DBG_ERR, "There is no Batch data");
@@ -588,6 +602,7 @@ gboolean gps_plugin_start_batch_mode(replay_timeout *timer, int batch_interval,
        gps_plugin_respond_start_session(ret);
 
        timer->batch_mode = BATCH_MODE_ON;
+       timer->batch_interval = batch_interval;
        timer->batch_period = batch_period;
        timer->batch_start_time = timestamp;
 
@@ -626,6 +641,20 @@ static void replay_mode_changed_cb(keynode_t *key, void *data)
        return;
 }
 
+static void display_mode_changed_cb(keynode_t * key, void *data)
+{
+       if (setting_get_int(VCONFKEY_PM_STATE, &g_replay_timer->lcd_mode) == FALSE) {
+               LOG_PLUGIN(DBG_ERR, "Fail to get lcd state");
+               g_replay_timer->lcd_mode = VCONFKEY_PM_STATE_LCDOFF;
+       }
+
+       if (g_replay_timer->lcd_mode == VCONFKEY_PM_STATE_NORMAL) {
+               g_replay_timer->is_flush = TRUE;
+       }
+
+       return;
+}
+
 replay_timeout *gps_plugin_replay_timer_init()
 {
        replay_timeout *timer = NULL;
@@ -642,12 +671,18 @@ replay_timeout *gps_plugin_replay_timer_init()
        timer->batch_fd = NULL;
        timer->num_of_batch = 0;
        timer->batch_mode = BATCH_MODE_OFF;
+       timer->is_flush = FALSE;
 
        if (setting_get_int(VCONFKEY_LOCATION_REPLAY_MODE, &timer->replay_mode) == FALSE) {
                timer->replay_mode = REPLAY_OFF;
        }
        setting_notify_key_changed(VCONFKEY_LOCATION_REPLAY_MODE, replay_mode_changed_cb);
 
+       if (setting_get_int(VCONFKEY_PM_STATE, &timer->lcd_mode) == FALSE) {
+               timer->lcd_mode = VCONFKEY_PM_STATE_LCDOFF;
+       }
+       setting_notify_key_changed(VCONFKEY_PM_STATE, display_mode_changed_cb);
+
        timer->pos_data = (pos_data_t *) malloc(sizeof(pos_data_t));
        if (timer->pos_data == NULL) {
                LOG_PLUGIN(DBG_ERR, "pos_data allocation is failed.");
index 85f9e75ce7143bbe25833d71548d2d7638d393fb..2066e4b3dd3f74ad1639f379efacbf19aadc6423 100644 (file)
@@ -1,6 +1,6 @@
 Name:       lbs-server-plugin-replay
 Summary:    LBS Server plugin library for replay mode
-Version:    0.2.2
+Version:    0.2.3
 Release:    1
 Group:      Location/Libraries
 License:    Apache-2.0