添加了触摸屏的驱动之后,还无法绑定到具体哪个串口,开机后还无法起作用
需要open 某个/dev/ttySx设备, 设置成N_MOUSE,再read 一下才能跟驱动绑定起来
由于在某些情况下还要写串口,开关USB 的触摸功能,就直接写成一个native service,
把service 起来就打开设备,设置N_MOUSE,read, 把写串口作为一个service 接口提供给上层应用调用
1. 下面直接上代码
接口文件ITouchManager.h
class ITouchManager: public IInterface
{
public:
enum{
TOUCH_ENABLE_USB_DATA = IBinder::FIRST_CALL_TRANSACTION+1,
TOUCH_DISABLE_USB_DATA = IBinder::FIRST_CALL_TRANSACTION+2,
};
DECLARE_META_INTERFACE(TouchManager);
virtual int TouchEnableUsbTouch(bool en) = 0;
};
// ----------------------------------------------------------------------------
class BnTouchManager: public BnInterface<ITouchManager>
{
public:
virtual status_t onTransact(uint32_t code,
const Parcel& data,
Parcel* reply,
uint32_t flags = 0);
};
接口实现 ITouchManager.c
class BpTouchManager: public BpInterface<ITouchManager>
{
public:
//Interface for java <-> msrv
explicit BpTouchManager(const sp<IBinder>& impl)
: BpInterface<ITouchManager>(impl)
{
}
// ----------------------------------------------------------------------------
virtual int TouchEnableUsbTouch(bool en)
{
Parcel data, reply;
data.writeInterfaceToken(ITouchManager::getInterfaceDescriptor());
ALOGD("TouchEnableUsbTouch %d\n",en);
if(en)
remote()->transact(ITouchManager::TOUCH_ENABLE_USB_DATA, data, &reply);
else