Bluez HID

144 views
Skip to first unread message

Johan Zander

unread,
Mar 24, 2011, 12:07:30 PM3/24/11
to Android Linux Kernel Development
Hello,

I'm working on adding support for our Bluetooth HID device to the
AOSP. It is a non-keyboard/mouse device which ends up as a /dev/
hidraw0 device on ubuntu/bluez. I guess what I'm trying to achieve is
to get /dev/hidraw0 created when my device connects, as in my ubuntu/
bluez case.

I've come to the point where the socket() call in ioctl_connadd() in
bluez/input/device.c fails. I really don't know where this call takes
me :-)

static int ioctl_connadd(struct hidp_connadd_req *req)
{
int ctl, err = 0;

ctl = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HIDP);
if (ctl < 0)
return -errno;
...
}

I've added the line
/dev/hidraw0 0660 system bluetooth
in ueventd.rc but that didn't help. I've considered adding a hid
service in init.rc in a similar way as opush, pbap, etc, but it works
fine on my ubuntu without this service so I'm not sure if this would
help...

Any idea on how to proceed?

system: Ubuntu 10.10
device: Google Nexus S
code: android-2.3.3_r1 + HID enhancements from omapzoom.

Kenneth Skovhede

unread,
Apr 9, 2011, 10:38:47 AM4/9/11
to Android Linux Kernel Development
I have struck on the same problem, from another angle.

The problem for me is permissions.
If I run the same line as root, all works fine.

I have tried a number of different permission settings,
but to no avail.

Most of the stuff works if I set BLUETOOTH
and BLUETOOTH_ADMIN, but not the raw socket
call.

I get error code 13 - Permission Denied.

Any hints to a permission I can set that makes it
work without root is appreciated.

Regards, Kenneth

Pavan Savoy

unread,
Apr 13, 2011, 4:55:08 AM4/13/11
to android...@googlegroups.com, Kenneth Skovhede
On Sat, Apr 9, 2011 at 8:08 PM, Kenneth Skovhede <ken...@hexad.dk> wrote:
> I have struck on the same problem, from another angle.
>
> The problem for me is permissions.
> If I run the same line as root, all works fine.
>
> I have tried a number of different permission settings,
> but to no avail.

isn't this because of the ANDROID PARANOID NETWORK security options?
All of BT HID implementations I've seen till date on android go via
DBus, so you should consider writing your program via Dbus...

> Most of the stuff works if I set BLUETOOTH
> and BLUETOOTH_ADMIN, but not the raw socket
> call.
>
> I get error code 13 - Permission Denied.
>
> Any hints to a permission I can set that makes it
> work without root is appreciated.
>
> Regards, Kenneth
>
> On 24 Mar., 18:07, Johan Zander <johanzan...@gmail.com> wrote:
>>
>> static int ioctl_connadd(struct hidp_connadd_req *req)
>> {
>>         int ctl, err = 0;
>>
>>         ctl = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HIDP);
>>         if (ctl < 0)
>>                 return -errno;
>> ...
>>
>> }
>>
>

> --
> unsubscribe: android-kerne...@googlegroups.com
> website: http://groups.google.com/group/android-kernel

--
--Pavan Savoy

Kenneth Skovhede

unread,
Apr 13, 2011, 5:19:19 AM4/13/11
to Android Linux Kernel Development
Yes, that must be it.

Can I request AID_NET_RAW permission
from a manifest file? And if so, how?

I looked at the permissions, but none seem to map to AID_NET_RAW:
http://developer.android.com/reference/android/Manifest.permission.htm

Regards, Kenneth

Pavan Savoy

unread,
Apr 13, 2011, 5:32:17 AM4/13/11
to android...@googlegroups.com, Kenneth Skovhede
On Wed, Apr 13, 2011 at 2:49 PM, Kenneth Skovhede <ken...@hexad.dk> wrote:
> Yes, that must be it.
>
> Can I request AID_NET_RAW permission
> from a manifest file? And if so, how?

But you must request it for the hci0 interface isn't it ....
Can you do that ?

> I looked at the permissions, but none seem to map to AID_NET_RAW:
> http://developer.android.com/reference/android/Manifest.permission.htm
>
> Regards, Kenneth
>

Kenneth Skovhede

unread,
Apr 13, 2011, 7:20:10 AM4/13/11
to Android Linux Kernel Development

> > Can I request AID_NET_RAW permission
> > from a manifest file? And if so, how?
>
> But you must request it for the hci0 interface isn't it ....
> Can you do that ?

I'm not sure what you mean, I would like the caller
(i.e. my app user) to be a member of the
AID_NET_RAW / "net_raw" group so it gets
permission to create a raw socket.

Regards, Kenneth

venkata

unread,
Jan 11, 2016, 12:30:20 PM1/11/16
to android...@googlegroups.com
Dear Kenneth

Were you able to add NET_RAW permission int he manifest. Was your
application able to access network devices ?

Regards,
Venkata


Reply all
Reply to author
Forward
0 new messages