Exemplo n.º 1
0
DSME_HANDLER(DSM_MSGTYPE_SET_BATTERY_STATE, conn, battery)
{
  dsme_log(LOG_NOTICE,
           PFIX"battery %s state received",
           battery->empty ? "empty" : "not empty");

  if (battery->empty) {
      /* we have to shut down; first send the notification */
      DSM_MSGTYPE_BATTERY_EMPTY_IND battery_empty_ind =
          DSME_MSG_INIT(DSM_MSGTYPE_BATTERY_EMPTY_IND);

      broadcast(&battery_empty_ind);

      /* then set up a delayed shutdown */
      if (!dsme_create_timer(DSME_BATTERY_EMPTY_SHUTDOWN_TIMER,
                             delayed_battery_empty_fn,
                             NULL))
      {
          dsme_log(LOG_ERR,
                   PFIX"Cannot create timer; battery empty shutdown immediately!");
          delayed_battery_empty_fn(0);
      } else {
          dsme_log(LOG_CRIT,
                   PFIX"Battery empty shutdown in %d seconds",
                   DSME_BATTERY_EMPTY_SHUTDOWN_TIMER);
      }
  }
}
Exemplo n.º 2
0
Arquivo: mce-dsme.c Projeto: g7/mce
/**
 * Request powerup
 */
void mce_dsme_request_powerup(void)
{
	/* Set up the message */
	DSM_MSGTYPE_POWERUP_REQ msg = DSME_MSG_INIT(DSM_MSGTYPE_POWERUP_REQ);

	/* Send the message */
	mce_dsme_send(&msg, "DSM_MSGTYPE_POWERUP_REQ");
}
Exemplo n.º 3
0
static int delayed_shutdown_fn(void* unused)
{
  DSM_MSGTYPE_SHUTDOWN msg = DSME_MSG_INIT(DSM_MSGTYPE_SHUTDOWN);
  msg.runlevel = state2runlevel(current_state);
  broadcast_internally(&msg);

  return 0; /* stop the interval */
}
Exemplo n.º 4
0
Arquivo: mce-dsme.c Projeto: g7/mce
/**
 * Send system state inquiry
 */
static void mce_dsme_query_system_state(void)
{
	/* Set up the message */
	DSM_MSGTYPE_STATE_QUERY msg = DSME_MSG_INIT(DSM_MSGTYPE_STATE_QUERY);

	/* Send the message */
	mce_dsme_send(&msg, "DSM_MSGTYPE_STATE_QUERY");
}
Exemplo n.º 5
0
static gboolean send_dsme_empty(gpointer data G_GNUC_UNUSED)
{
  DSM_MSGTYPE_SET_BATTERY_STATE msg =
    DSME_MSG_INIT(DSM_MSGTYPE_SET_BATTERY_STATE);
  msg.empty = 1;
  if (!global_is_charging)
    dsmesock_send(dsme_conn, &msg);
  return FALSE;
}
Exemplo n.º 6
0
static void send_emergency_call_status(bool ongoing)
{
    DSM_MSGTYPE_SET_EMERGENCY_CALL_STATE msg =
      DSME_MSG_INIT(DSM_MSGTYPE_SET_EMERGENCY_CALL_STATE);

    msg.ongoing = ongoing;

    broadcast_internally(&msg);
}
Exemplo n.º 7
0
static void get_state(const DsmeDbusMessage* request, DsmeDbusMessage** reply)
{
    // first create a reply and append it to the list of yet unsent replies
    state_replies = g_slist_append(state_replies, dsme_dbus_reply_new(request));

    // then proxy the query to the internal message queue
    DSM_MSGTYPE_STATE_QUERY query = DSME_MSG_INIT(DSM_MSGTYPE_STATE_QUERY);
    broadcast_internally(&query);
}
Exemplo n.º 8
0
DSME_HANDLER(DSM_MSGTYPE_GET_VERSION, client, ind)
{
	static const char*       version = STRINGIFY(PRG_VERSION);
	DSM_MSGTYPE_DSME_VERSION msg     =
          DSME_MSG_INIT(DSM_MSGTYPE_DSME_VERSION);

        dsme_log(LOG_DEBUG, "version requested, sending '%s'", version);
	endpoint_send_with_extra(client, &msg, strlen(version) + 1, version);
}
Exemplo n.º 9
0
/**
 * Send system state inquiry
 */
static void query_system_state(void)
{
	/* Set up the message */
	DSM_MSGTYPE_STATE_QUERY msg = DSME_MSG_INIT(DSM_MSGTYPE_STATE_QUERY);

	/* Send the message */
	mce_dsme_send(&msg);
	mce_log(LL_DEBUG,
		"DSM_MSGTYPE_STATE_QUERY sent to DSME");
}
Exemplo n.º 10
0
/**
 * Request powerup
 */
void request_powerup(void)
{
	/* Set up the message */
	DSM_MSGTYPE_POWERUP_REQ msg = DSME_MSG_INIT(DSM_MSGTYPE_POWERUP_REQ);

	/* Send the message */
	mce_dsme_send(&msg);
	mce_log(LL_DEBUG,
		"DSM_MSGTYPE_POWERUP_REQ sent to DSME");
}
Exemplo n.º 11
0
static void subscribe_to_wakeup(void)
{
    DSM_MSGTYPE_WAIT msg = DSME_MSG_INIT(DSM_MSGTYPE_WAIT);
    msg.req.mintime = 24;
    msg.req.maxtime = 30;
    msg.req.pid     = 0;
    msg.data        = 0;

    broadcast_internally(&msg);
}
Exemplo n.º 12
0
Arquivo: mce-dsme.c Projeto: g7/mce
/**
 * Register to DSME process watchdog
 */
static void mce_dsme_init_processwd(void)
{
	/* Set up the message */
	DSM_MSGTYPE_PROCESSWD_CREATE msg =
	  DSME_MSG_INIT(DSM_MSGTYPE_PROCESSWD_CREATE);
	msg.pid = getpid();

	/* Send the message */
	mce_dsme_send(&msg, "DSM_MSGTYPE_PROCESSWD_CREATE");
}
Exemplo n.º 13
0
/**
 * Request reboot
 */
void request_reboot(void)
{
	/* Set up the message */
	DSM_MSGTYPE_REBOOT_REQ msg = DSME_MSG_INIT(DSM_MSGTYPE_REBOOT_REQ);

	/* Send the message */
	mce_dsme_send(&msg);
	mce_log(LL_DEBUG,
		"DSM_MSGTYPE_REBOOT_REQ sent to DSME");
}
Exemplo n.º 14
0
DSME_HANDLER(DSM_MSGTYPE_STATE_QUERY, client, msg)
{
  DSM_MSGTYPE_STATE_CHANGE_IND ind_msg =
    DSME_MSG_INIT(DSM_MSGTYPE_STATE_CHANGE_IND);

  dsme_log(LOG_DEBUG, PFIX"state_query, state: %s", state_name(current_state));

  ind_msg.state = current_state;
  endpoint_send(client, &ind_msg);
}
Exemplo n.º 15
0
static void send_usb_status(bool mounted_to_pc)
{
    DSM_MSGTYPE_SET_USB_STATE msg = DSME_MSG_INIT(DSM_MSGTYPE_SET_USB_STATE);

    msg.mounted_to_pc = mounted_to_pc;

    dsme_log(LOG_DEBUG,
             "usbtracker: broadcasting usb state:%s mounted to PC",
             msg.mounted_to_pc ? "" : " not");
    broadcast_internally(&msg);
}
Exemplo n.º 16
0
static void req_reboot(const DsmeDbusMessage* request, DsmeDbusMessage** reply)
{
  char* sender = dsme_dbus_endpoint_name(request);
  dsme_log(LOG_CRIT,
           "reboot request received over D-Bus from %s",
           sender ? sender : "(unknown)");
  free(sender);

  DSM_MSGTYPE_REBOOT_REQ req = DSME_MSG_INIT(DSM_MSGTYPE_REBOOT_REQ);
  broadcast_internally(&req);
}
Exemplo n.º 17
0
static void req_powerup(const DsmeDbusMessage* request, DsmeDbusMessage** reply)
{
  char* sender = dsme_dbus_endpoint_name(request);
  dsme_log(LOG_NOTICE,
           "powerup request received over D-Bus from %s",
           sender ? sender : "(unknown)");
  free(sender);

  DSM_MSGTYPE_POWERUP_REQ req = DSME_MSG_INIT(DSM_MSGTYPE_POWERUP_REQ);
  broadcast_internally(&req);
}
Exemplo n.º 18
0
/**
 * Request normal shutdown
 */
void request_normal_shutdown(void)
{
	/* Set up the message */
	DSM_MSGTYPE_SHUTDOWN_REQ msg = DSME_MSG_INIT(DSM_MSGTYPE_SHUTDOWN_REQ);

	/* Send the message */
	mce_dsme_send(&msg);
	mce_log(LL_DEBUG,
		"DSM_MSGTYPE_SHUTDOWN_REQ (DSME_NORMAL_SHUTDOWN) "
		"sent to DSME");
}
Exemplo n.º 19
0
int send_kick_wd(void) {

	int ret = 0;
	DSM_MSGTYPE_HWWD_KICK msg =
          DSME_MSG_INIT(DSM_MSGTYPE_HWWD_KICK);

	ret = dsmesock_send(conn, &msg);
	printf("Message sent to DSME!");

	return ret;
}
Exemplo n.º 20
0
void module_init(module_t* handle)
{
  /* get dsme version so that we can report it over D-Bus if asked to */
  DSM_MSGTYPE_GET_VERSION req = DSME_MSG_INIT(DSM_MSGTYPE_GET_VERSION);
  broadcast_internally(&req);

  /* Do not connect to D-Bus; it is probably not started yet.
   * Instead, wait for DSM_MSGTYPE_DBUS_CONNECT.
   */

  dsme_log(LOG_DEBUG, "libdbusproxy.so loaded");
}
Exemplo n.º 21
0
static void send_charger_status(bool charger_state)
{
    DSM_MSGTYPE_SET_CHARGER_STATE msg = DSME_MSG_INIT(DSM_MSGTYPE_SET_CHARGER_STATE);

    msg.connected = charger_state;

    dsme_log(LOG_DEBUG,
             "usbtracker: broadcasting usb charger state:%s connected",
             msg.connected ? "" : " not");

    broadcast_internally(&msg);
}
Exemplo n.º 22
0
static void deny_state_change_request(dsme_state_t denied_state,
                                      const char*  reason)
{
  DSM_MSGTYPE_STATE_REQ_DENIED_IND ind =
      DSME_MSG_INIT(DSM_MSGTYPE_STATE_REQ_DENIED_IND);

  ind.state = denied_state;
  broadcast_with_extra(&ind, strlen(reason) + 1, reason);
  dsme_log(LOG_CRIT,
           PFIX"%s denied due to: %s",
           (denied_state == DSME_STATE_SHUTDOWN ? "shutdown" : "reboot"),
           reason);
}
Exemplo n.º 23
0
Arquivo: mce-dsme.c Projeto: g7/mce
/**
 * Unregister from DSME process watchdog
 */
static void mce_dsme_exit_processwd(void)
{
	mce_log(LL_DEBUG,
		"Disabling DSME process watchdog");

	/* Set up the message */
	DSM_MSGTYPE_PROCESSWD_DELETE msg =
	  DSME_MSG_INIT(DSM_MSGTYPE_PROCESSWD_DELETE);
	msg.pid = getpid();

	/* Send the message */
	mce_dsme_send(&msg, "DSM_MSGTYPE_PROCESSWD_DELETE");
}
Exemplo n.º 24
0
Arquivo: mce-dsme.c Projeto: g7/mce
/**
 * Send pong message to the DSME process watchdog
 */
static void mce_dsme_send_pong(void)
{
	/* Set up the message */
	DSM_MSGTYPE_PROCESSWD_PONG msg =
	  DSME_MSG_INIT(DSM_MSGTYPE_PROCESSWD_PONG);
	msg.pid = getpid();

	/* Send the message */
	mce_dsme_send(&msg, "DSM_MSGTYPE_PROCESSWD_PONG");

	/* Execute hearbeat actions even if ping-pong ipc failed */
	execute_datapipe(&heartbeat_pipe, GINT_TO_POINTER(0),
			 USE_INDATA, DONT_CACHE_INDATA);
}
Exemplo n.º 25
0
/**
 * This function sends a message to clients to notify about state change.
 * SAVE_DATA message is also sent when going down.
 * @param state State that is being activated
 */
static void change_state(dsme_state_t new_state)
{
  if (new_state == DSME_STATE_SHUTDOWN ||
      new_state == DSME_STATE_ACTDEAD  || 
      new_state == DSME_STATE_REBOOT)
  {
      DSM_MSGTYPE_SAVE_DATA_IND save_msg =
        DSME_MSG_INIT(DSM_MSGTYPE_SAVE_DATA_IND);

      dsme_log(LOG_DEBUG, PFIX"sending SAVE_DATA");
      broadcast(&save_msg);
  }

  DSM_MSGTYPE_STATE_CHANGE_IND ind_msg =
    DSME_MSG_INIT(DSM_MSGTYPE_STATE_CHANGE_IND);

  ind_msg.state = new_state;
  dsme_log(LOG_DEBUG, PFIX"STATE_CHANGE_IND sent (%s)", state_name(new_state));
  broadcast(&ind_msg);

  dsme_log(LOG_NOTICE, PFIX"new state: %s", state_name(new_state));
  current_state = new_state;
}
Exemplo n.º 26
0
static void poweron_update_cb(void)
{
  // update cal data without forcing write
  pot_update_cal(in_user_mode, false);

  // schedule the next update wakeup
  DSM_MSGTYPE_WAIT msg = DSME_MSG_INIT(DSM_MSGTYPE_WAIT);
  msg.req.mintime = 10;
  msg.req.maxtime = 60;
  msg.req.pid     = 0;
  msg.data        = 0;

  broadcast_internally(&msg);
}
Exemplo n.º 27
0
static DBusHandlerResult
dsme_dbus_filter(DBusConnection *con, DBusMessage *msg, void *aptr)
{
    FILE* f;

    if( dbus_message_is_signal(msg, DBUS_INTERFACE_LOCAL, "Disconnected") ) {
      dsme_log(LOG_CRIT, "Disconnected from system bus; rebooting");
      /* mark failure and request reboot */
      if ((f = fopen(DBUS_FAILED_FILE, "w+")) != NULL)
	  fclose(f);
      DSM_MSGTYPE_REBOOT_REQ req = DSME_MSG_INIT(DSM_MSGTYPE_REBOOT_REQ);
      broadcast_internally(&req);
    }
    return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
Exemplo n.º 28
0
Arquivo: mce-dsme.c Projeto: g7/mce
/**
 * Request normal shutdown
 */
void mce_dsme_request_normal_shutdown(void)
{
	if( datapipe_get_gint(update_mode_pipe) ) {
		mce_log(LL_WARN, "shutdown blocked; os update in progress");
		goto EXIT;
	}

	/* Set up the message */
	DSM_MSGTYPE_SHUTDOWN_REQ msg = DSME_MSG_INIT(DSM_MSGTYPE_SHUTDOWN_REQ);

	/* Send the message */
	mce_dsme_send(&msg, "DSM_MSGTYPE_SHUTDOWN_REQ(DSME_NORMAL_SHUTDOWN)");
EXIT:
	return;
}
Exemplo n.º 29
0
Arquivo: mce-dsme.c Projeto: g7/mce
/**
 * Request reboot
 */
void mce_dsme_request_reboot(void)
{
	if( datapipe_get_gint(update_mode_pipe) ) {
		mce_log(LL_WARN, "reboot blocked; os update in progress");
		goto EXIT;
	}

	/* Set up the message */
	DSM_MSGTYPE_REBOOT_REQ msg = DSME_MSG_INIT(DSM_MSGTYPE_REBOOT_REQ);

	/* Send the message */
	mce_dsme_send(&msg, "DSM_MSGTYPE_REBOOT_REQ");
EXIT:
	return;
}
Exemplo n.º 30
0
/**
 * Send pong message to the DSME process watchdog
 */
static void dsme_send_pong(void)
{
	/* Set up the message */
	DSM_MSGTYPE_PROCESSWD_PONG msg =
          DSME_MSG_INIT(DSM_MSGTYPE_PROCESSWD_PONG);
	msg.pid = getpid();

	/* Send the message */
	mce_dsme_send(&msg);
	mce_log(LL_DEBUG,
		"DSM_MSGTYPE_PROCESSWD_PONG sent to DSME");

	execute_datapipe(&heartbeat_pipe, GINT_TO_POINTER(0),
			 USE_INDATA, DONT_CACHE_INDATA);
}