Example #1
0
static void input_device_enter_reconnect_mode(struct input_device *idev)
{
    DBG("path=%s reconnect_mode=%s", idev->path,
        reconnect_mode_to_string(idev->reconnect_mode));

    /* Only attempt an auto-reconnect when the device is required to accept
     * reconnections from the host. */
    if (idev->reconnect_mode != RECONNECT_ANY &&
            idev->reconnect_mode != RECONNECT_HOST)
        return;

    /* If the device is temporary we are not required to reconnect with the
     * device. This is likely the case of a removing device. */
    if (device_is_temporary(idev->device) ||
            btd_device_is_connected(idev->device))
        return;

    if (idev->reconnect_timer > 0)
        g_source_remove(idev->reconnect_timer);

    DBG("registering auto-reconnect");
    idev->reconnect_attempt = 0;
    idev->reconnect_timer = g_timeout_add_seconds(30,
                            input_device_auto_reconnect, idev);

}
Example #2
0
static gboolean input_device_auto_reconnect(gpointer user_data)
{
    struct input_device *idev = user_data;

    DBG("path=%s, attempt=%d", idev->path, idev->reconnect_attempt);

    /* Stop the recurrent reconnection attempts if the device is reconnected
     * or is marked for removal. */
    if (device_is_temporary(idev->device) ||
            btd_device_is_connected(idev->device))
        return FALSE;

    /* Only attempt an auto-reconnect for at most 3 minutes (6 * 30s). */
    if (idev->reconnect_attempt >= 6)
        return FALSE;

    /* Check if the profile is already connected. */
    if (idev->ctrl_io)
        return FALSE;

    if (is_connected(idev))
        return FALSE;

    idev->reconnect_attempt++;
    dev_connect(idev);

    return TRUE;
}
Example #3
0
static int agent_call_authorize(struct agent_request *req,
//				const char *device_path,
				const struct btd_device *device, //CTS VERI
				const char *uuid)
{
	struct agent *agent = req->agent;
        const gchar *device_path = device_get_path(device); //CTS VERI
        gboolean bTemporary = device_is_temporary(device);   //CTS VERI

	req->msg = dbus_message_new_method_call(agent->name, agent->path,
				"org.bluez.Agent", "Authorize");
	if (!req->msg) {
		error("Couldn't allocate D-Bus message");
		return -ENOMEM;
	}

	dbus_message_append_args(req->msg,
				DBUS_TYPE_OBJECT_PATH, &device_path,
				DBUS_TYPE_STRING, &uuid,
                                DBUS_TYPE_BOOLEAN, &bTemporary, //CTS VERI
				DBUS_TYPE_INVALID);

	if (dbus_connection_send_with_reply(connection, req->msg,
#ifdef BT_ALT_STACK // CSP 273229 reply to the auhorization request within 52 secs to stay connected to BMW carkit
                                        &req->call, 52 * 1000  ) == FALSE) {
#else
					&req->call, REQUEST_TIMEOUT) == FALSE) {
#endif
		error("D-Bus send failed");
		return -EIO;
	}

	dbus_pending_call_set_notify(req->call, simple_agent_reply, req, NULL);
	return 0;
}
Example #4
0
int input_device_disconnect(struct btd_service *service)
{
	struct input_device *idev;
	int err, flags;

	DBG("");

	idev = btd_service_get_user_data(service);

	flags = device_is_temporary(idev->device) ?
					(1 << HIDP_VIRTUAL_CABLE_UNPLUG) : 0;

	err = connection_disconnect(idev, flags);
	if (err < 0)
		return err;

	return 0;
}
Example #5
0
static gboolean input_device_auto_reconnect(gpointer user_data)
{
	struct input_device *idev = user_data;
	struct input_conn *iconn;
	GError *err = NULL;

	DBG("idev %p", idev);

	DBG("path=%s, attempt=%d", idev->path, idev->reconnect_attempt);

	/* Stop the recurrent reconnection attempts if the device is reconnected
	 * or is marked for removal. */
	if (device_is_temporary(idev->device) ||
					device_is_connected(idev->device))
		return FALSE;

	/* Only attempt an auto-reconnect for at most 3 minutes (6 * 30s). */
	if (idev->reconnect_attempt >= 6)
		return FALSE;

	iconn = find_connection(idev->connections, HID_UUID);
	if (iconn == NULL)
		return FALSE;

	if (iconn->ctrl_io)
		return FALSE;

	if (is_connected(iconn))
		return FALSE;

	idev->reconnect_attempt++;

	dev_connect(idev, iconn, &err);
	if (err != NULL) {
		error("%s", err->message);
		g_error_free(err);
		return FALSE;
	}

	return TRUE;
}