Fix not to send duplcated reply 02/206102/5 accepted/tizen/unified/20190606.220040 submit/tizen/20190605.092841
authorlokilee73 <changjoo.lee@samsung.com>
Tue, 14 May 2019 08:40:35 +0000 (17:40 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Tue, 14 May 2019 11:41:05 +0000 (20:41 +0900)
When ok, cancel or back button is pressed,
power_lock_expired_terminate runs first.
It causes duplicated reply.
Current problem is as below.
1. User press cancel button
   ex) send_result(CLOSE_APP) is executed by power_lock_expired_terminate
       send_result(ALLOW_APP) is executed by power_lock_expired_allow_app
2. User choose ok button
   ex) send_result(CLOSE_APP) is executed by power_lock_expired_terminate
       send_result(CLOSE_APP) is executed by power_lock_expired_close_app

So, add button_id to fix duplicated reply.
1. User press cancel button
   ex) send_result(CLOSE_APP) is not executed because button_id is ALLOW_APP
       send_result(ALLOW_APP) is executed by power_lock_expired_allow_app
2. User choose ok button
   ex) send_result(CLOSE_APP) is not executed because button_id is CLOSE_APP
       send_result(CLOSE_APP) is executed by power_lock_expired_close_app

Finally, remove result_sended.
Because result_sended does not work properly.

Change-Id: I43cc267ccc1825cb6f8726645492fc8c6a3c1044
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
src/power/power.c

index 20e3231..d546f49 100644 (file)
@@ -30,7 +30,7 @@
 #define METHOD_LOCK_TIMEOUT_INPUT "LockTimeoutInput"
 
 static const struct popup_ops power_lock_expired_ops;
-static bool result_sended;
+static int button_id = -1;
 static char *request_id;
 
 enum button_selected {
@@ -45,11 +45,6 @@ static void send_result(int result)
        char buf[8];
        char *param[2];
 
-       if (result_sended)
-               return;
-
-       result_sended = true;
-
        param[0] = request_id;
        snprintf(buf, sizeof(buf), "%d", result);
        param[1] = buf;
@@ -113,6 +108,7 @@ static void power_lock_expired_allow_app(const struct popup_ops *ops)
 {
        _I("Allow is selected.");
 
+       button_id = ALLOW_APP;
        unload_simple_popup(ops);
 
        send_result(ALLOW_APP);
@@ -124,6 +120,7 @@ static void power_lock_expired_close_app(const struct popup_ops *ops)
 {
        _I("Close is selected.");
 
+       button_id = CLOSE_APP;
        unload_simple_popup(ops);
 
        send_result(CLOSE_APP);
@@ -133,8 +130,8 @@ static void power_lock_expired_close_app(const struct popup_ops *ops)
 
 static void power_lock_expired_terminate(const struct popup_ops *ops)
 {
-       send_result(CLOSE_APP);
-       result_sended = false;
+       if (button_id == -1)
+               send_result(CLOSE_APP);
 }
 
 static const struct popup_ops power_lock_expired_ops = {