power: change order of signal subscription 53/276353/2
authorYoungjae Cho <y0.cho@samsung.com>
Wed, 15 Jun 2022 05:16:57 +0000 (14:16 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Thu, 16 Jun 2022 00:50:21 +0000 (09:50 +0900)
Subscribe signal after calling AddChangeStateWait dbus method. It
prevents signal subscription when the dbus methods fail.

Change-Id: Ie194db05dbad5e784a6e4c3c211b8b45acc178b0
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
src/power-internal.c

index bd2c461..90d18b1 100644 (file)
@@ -104,11 +104,6 @@ int device_power_add_change_state_wait_callback(uint64_t state_bits, change_stat
                return DEVICE_ERROR_OPERATION_FAILED;
        }
 
-       // subscribe signal
-       for (int index = 0; index < POWER_STATE_MAX_INDEX; ++index)
-               if((state_bits & (1ULL << index)) && (change_state_signal_id[index] == 0))
-                       __device_power_add_change_state_wait_callback(connection, index, cb, data);
-
        // add change state wait
        retgv = g_dbus_connection_call_sync(connection,
                        DEVICED_BUS_NAME,
@@ -127,6 +122,12 @@ int device_power_add_change_state_wait_callback(uint64_t state_bits, change_stat
                return DEVICE_ERROR_OPERATION_FAILED;
        }
 
+       // subscribe signal
+       for (int index = 0; index < POWER_STATE_MAX_INDEX; ++index)
+               if((state_bits & (1ULL << index)) && (change_state_signal_id[index] == 0))
+                       __device_power_add_change_state_wait_callback(connection, index, cb, data);
+
+
        return DEVICE_ERROR_NONE;
 }