How to add system event listener to detect that vibration mode was ON/OFF

void extract_bundle_keyval_cb(const char *key, const int type, const bundle_keyval_t *kv, void *user_data)
{
   if(BUNDLE_TYPE_STR == type && strcmp(key,EVENT_KEY_VIBRATION_STATE) == 0 )
   {
      void *val;
      size_t size;
      bundle_keyval_get_basic_val((bundle_keyval_t *)kv, &val, &size);
      if (strncmp(val,EVENT_VAL_VIBRATION_ON,size-1) == 0)
      {
         dlog_print(DLOG_INFO, LOG_TAG, "Vibrarion mode is on");
      }
      else if (strncmp(val,EVENT_VAL_VIBRATION_OFF,size-1) == 0)
      {
          dlog_print(DLOG_INFO, LOG_TAG, "Vibrarion mode is off");
      }
   }
}

void vibration_state_event_cb(const char *event_name, bundle *event_data, void *user_data)
{
    bundle_foreach (event_data, extract_bundle_keyval_cb, NULL);
}

//...
{
//...
	event_handler_h handler;
	event_add_event_handler(SYSTEM_EVENT_VIBRATION_STATE,
	                                  (event_cb)vibration_state_event_cb, NULL, &handler);
//...
}

Responses

0 Replies