开发学院手机开发Android 开发 android binder机制实现 阅读

android binder机制实现

 2010-05-31 14:30:00 来源:WEB开发网   
核心提示:virtual bool checkPermission(const String16& permission,int32_t pid, int32_t uid) = 0;enum {CHECK_PERMISSION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION};};cl

virtual bool checkPermission(const String16& permission,int32_t pid, int32_t uid) = 0;

enum {

CHECK_PERMISSION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION

};

};

class BnPermissionController : public BnInterface

{

public:

virtual status_t onTransact( uint32_t code,

const Parcel& data,

Parcel* reply,

uint32_t flags = 0);

};

class IPermissionController : public IInterface { public: DECLARE_META_INTERFACE(PermissionController); virtual bool checkPermission(const String16& permission,int32_t pid, int32_t uid) = 0; enum { CHECK_PERMISSION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION }; }; class BnPermissionController : public BnInterface { public: virtual status_t onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); };

IPermissionController是一个接口类,只有checkPermission()一个纯虚函数。

BnPermissionController继承了以BnPermissionController实例化模版类BnInterface。因

此,BnPermissionController,事实上BnPermissionController双继承了BBinder和

IPermissionController。

实现文件IPermissionController.cpp中,首先实现了一个BpPermissionController。

Java代码 < width="14" height="15" src="http://mintelong.javaeye.com/javascripts/syntaxhighlighter/clipboard_new.swf" pluginspage="http://www.macromedia.com/go/getflashplayer">

class BpPermissionController : public BpInterface

{

public:

BpPermissionController(const sp& impl)

: BpInterface(impl)

{

}

virtual bool checkPermission(const String16& permission, int32_t pid, int32_t uid)

{

Parcel data, reply;

data.writeInterfaceToken(IPermissionController::

getInterfaceDescriptor());

data.writeString16(permission);

上一页  3 4 5 6 7 8 9 10 11  下一页

Tags:android binder 机制

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接