#define METHOD_SET_BRIGHTNESS "SetBrightness"
#define METHOD_PLAY_CUSTOM "playcustom"
#define METHOD_GET_LED_NUMBER "GetNumOfLeds"
-#define METHOD_MULTI_PLAY_CUSTOM "multi_playcustom"
-#define METHOD_MULTI_STOP_CUSTOM "multi_stopcustom"
+#define METHOD_MULTI_LED_CONTROL "multi_led_control"
#define METHOD_STOP_CUSTOM "stopcustom"
#define FRONT_LED_FEATURE "tizen.org/feature/led"
static bool support_front_led;
static bool support_camera_led;
-static int number_of_devices;
+static int number_of_devices = -1;
static void __CONSTRUCTOR__ init(void)
{
if (!num_of_leds)
return DEVICE_ERROR_INVALID_PARAMETER;
- ret = dbus_method_sync(DEVICED_BUS_NAME,
- DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
- METHOD_GET_LED_NUMBER, NULL, NULL);
- if (ret < 0)
- return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
+ if (number_of_devices < 0) {
+ ret = dbus_method_sync(DEVICED_BUS_NAME,
+ DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
+ METHOD_GET_LED_NUMBER, NULL, NULL);
+ if (ret < 0)
+ return errno_to_device_error(ret); //LCOV_EXCL_LINE System Error
+ number_of_devices = ret;
+ }
+
+ *num_of_leds = number_of_devices;
- *num_of_leds = ret;
- number_of_devices = ret;
return DEVICE_ERROR_NONE;
}
-int device_multi_led_play_custom(unsigned int color[])
+int device_multi_led_control(unsigned int color[])
{
GVariantBuilder *builder = NULL;
GVariant *var = NULL;
- int i;
+ int i, ret;
if (!support_front_led)
return DEVICE_ERROR_NOT_SUPPORTED;
if (color == NULL)
return DEVICE_ERROR_INVALID_PARAMETER;
+ if (number_of_devices < 0) {
+ ret = device_multi_led_get_number(&number_of_devices);
+ if (ret != DEVICE_ERROR_NONE) //LCOV_EXCL_LINE System Error
+ return ret;
+ }
+
builder = g_variant_builder_new(G_VARIANT_TYPE("au"));
for (i = 0; i < number_of_devices; i++)
g_variant_builder_add(builder, "u", color[i]);
g_variant_builder_unref(builder);
return dbus_method_sync_var(DEVICED_BUS_NAME, DEVICED_PATH_LED,
- DEVICED_INTERFACE_LED, METHOD_MULTI_PLAY_CUSTOM, var);
+ DEVICED_INTERFACE_LED, METHOD_MULTI_LED_CONTROL, var);
}
//LCOV_EXCL_STOP