openharmony 3.2release中蓝牙鼠标适配适配​

# 目标

在openharmony 3.2release完成蓝牙鼠标的适配。

备注:此蓝牙鼠标为BR设备,非BLE设备。

# 准备工作

在蓝牙列表里配对并连接蓝牙鼠标,并取出对应的hilog和kmsg

# 一、在输入设备中添加蓝牙鼠标

1. 首先查看对应的hilog,在hilog中发现

行 9620: 01-01 08:04:17.049   397  1663 E C02800/PointerDrawingManager: in GetSurfaceBuffer, Request buffer ret:<504 binder occur error>
行 9757: 01-01 08:04:17.055   397  1663 E C02800/PointerDrawingManager: in InitLayer, Init layer is failed, buffer or virAddr is nullptr

   根据layer初始化失败判断设备input没适配;

2. 在输入设备中添加蓝牙鼠标

   首先,查看蓝牙鼠标对应的设备。使用 cat /proc/bus/input/devices找到蓝牙鼠标对应的设备。比如,这里蓝牙鼠标是第6个设备,记录Name为"Bluetooth HID"。具体可参考:https://gitee.com/tanpengju/openharmonydevice#%E6%AD%A5%E9%AA%A47-%E8%A7%A6%E6%91%B8%E5%B1%8F%E7%9A%84%E9%80%82%E9%85%8D

# cat /proc/bus/input/devices
I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="sc27xx:vibrator"
P: Phys=
S: Sysfs=/devices/platform/soc/soc:aon/64400000.spi/spi_master/spi4/spi4.0/64400000.spi:pmic@0:vibrator@2390/input/input0
U: Uniq=
H: Handlers=event0
B: PROP=0
B: EV=200001
B: FF=107030000 0

I: Bus=0019 Vendor=0001 Product=0001 Version=0100
N: Name="gpio-keys"
P: Phys=gpio-keys/input0
S: Sysfs=/devices/platform/gpio-keys/input/input1
U: Uniq=
H: Handlers=event1 sysdump
B: PROP=0
B: EV=3
B: KEY=1c000000000000 0

I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="sprdphone-sc2730 Headset Jack"
P: Phys=ALSA
S: Sysfs=/devices/platform/sound@0/sound/card0/input2
U: Uniq=
H: Handlers=event2
B: PROP=0
B: EV=21
B: SW=14

I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="sprdphone-sc2730 Headset Keyboard"
P: Phys=ALSA
S: Sysfs=/devices/platform/sound@0/sound/card0/input3
U: Uniq=
H: Handlers=event3 sysdump
B: PROP=0
B: EV=3
B: KEY=18 400000000 0 c000000000000 0

I: Bus=0003 Vendor=6006 Product=6006 Version=0001
N: Name="VSoC touchscreen"
P: Phys=
S: Sysfs=/devices/virtual/input/input4
U: Uniq=
H: Handlers=event4 sysdump
B: PROP=2
B: EV=b
B: KEY=400 0 0 0 0 0
B: ABS=773000001000003

I: Bus=001c Vendor=0000 Product=0000 Version=0000
N: Name="NVTCapacitiveTouchScreen"
P: Phys=input/ts
S: Sysfs=/devices/virtual/input/input5
U: Uniq=
H: Handlers=event5 sysdump
B: PROP=2
B: EV=b
B: KEY=400 0 0 0 0 0
B: ABS=661800000000000

I: Bus=0005 Vendor=ae24 Product=8618 Version=0001
N: Name="Bluetooth HID"
P: Phys=
S: Sysfs=/devices/virtual/misc/uhid/0005:AE24:8618.0001/input/input6
U: Uniq=B4:EE:25:41:27:21
H: Handlers=event6 sysdump
B: PROP=0
B: EV=17
B: KEY=1f0000 0 0 0 0
B: REL=903
B: MSC=10

然后在third_party\eudev\rules.d\touchscreen.rules中添加Bluetooth HID设备

ATTRS{name}=="VSoC touchscreen", ENV{ID_INPUT}="1", ENV{ID_INPUT_TOUCHSCREEN}="1"
ATTRS{name}=="VSoC keyboard", ENV{ID_INPUT}="1", ENV{ID_INPUT_KEYBOARD}="1"
DRIVERS=="hid-multitouch", ENV{ID_INPUT}="1", ENV{ID_INPUT_TOUCHSCREEN}="1"
ATTRS{name}=="Bluetooth HID", ENV{ID_INPUT}="1", ENV{ID_INPUT_KEYBOARD}="1"        --此处为添加的蓝牙鼠标设备

# 二、修改selinux规则

1.在hilog读取到以下日志

01-01 08:04:16.215   315   372 E C02f02/Selinux: avc:  denied  { get } for service=401 pid=397 scontext=u:r:multimodalinput:s0 tcontext=u:object_r:sa_foundation_bms:s0 tclass=samgr_class permissive=0

2.在kmsg中读取到以下日志

01-01 08:01:37.928     0     0 F K02600/kmsg: 5,8831,159131886,-,caller=T74@C1;audit: type=1400 audit(257.043:9): avc:  denied  { write } for  pid=974 comm="IPC_3_1652" path=2F646174612F6173686D656D2F616E64726F69642D6173686D656D2D3831352D5858584A4B4B68694B202864656C6574656429 dev="mmcblk0p63" ino=4431 scontext=u:r:multimodalinput:s0 tcontext=u:object_r:data_file:s0 tclass=file permissive=0

根据selinux修改规则,参考:https://laval.csdn.net/64ee90df4165333c3076badb.html

在base\security\selinux\sepolicy\ohos_policy\multimodalinput\input\system\multimodalinput.te中添加

allow multimodalinput sa_foundation_bms:samgr_class { get };      --此处修改hilog中的报错
allow multimodalinput data_file:file { write };                   --此处修改kmsg中的报错

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值