aidl深度解析
来源:互联网 发布:淘宝怎么编辑宝贝详情 编辑:程序博客网 时间:2024/06/03 12:31
本文是aidl自动生成的java类的解析,让你更加清晰的了解aidl
上一张自己画的UML图
:
然后根据图看下面的一个aidl自动生成的java类:public interface ISizeAidlInterface extends android.os.IInterface { /** * Local-side IPC implementation stub class. */ public static abstract class Stub extends android.os.Binder implements com.easou.iris.aidltestnew.ISizeAidlInterface { private static final java.lang.String DESCRIPTOR = "com.easou.iris.aidltestnew.ISizeAidlInterface";//本aidl的标识 /** * Construct the stub at attach it to the interface. * 构造函数里给本Stub设置标识 */ public Stub() { this.attachInterface(this, DESCRIPTOR); } /** * Cast an IBinder object into an com.easou.iris.aidltestnew.ISizeAidlInterface interface, * generating a proxy if needed. * 把IBinder对象转换成ISizeAidlInterface接口,根绝情况使用代理类Proxy */ public static com.easou.iris.aidltestnew.ISizeAidlInterface asInterface(android.os.IBinder obj) { if ((obj == null)) { return null; } android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR);//根据标识查询是否是本地进程,不是本地的话返回null if (((iin != null) && (iin instanceof com.easou.iris.aidltestnew.ISizeAidlInterface))) { return ((com.easou.iris.aidltestnew.ISizeAidlInterface) iin); } return new com.easou.iris.aidltestnew.ISizeAidlInterface.Stub.Proxy(obj);//!☆ 跨进程调用,使用代理,把实际的Binder对象传入 } @Override public android.os.IBinder asBinder() {//绑定Binder是返回的IBinder对象 return this; }/***执行方法时参数顺序。*/ @Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException { switch (code) { case INTERFACE_TRANSACTION: { reply.writeString(DESCRIPTOR); return true; } case TRANSACTION_setSize: { data.enforceInterface(DESCRIPTOR); int _arg0; _arg0 = data.readInt(); this.setSize(_arg0); reply.writeNoException(); return true; } case TRANSACTION_getSize: { data.enforceInterface(DESCRIPTOR); int _result = this.getSize(); reply.writeNoException(); reply.writeInt(_result); return true; } } return super.onTransact(code, data, reply, flags); }/***代理*/ private static class Proxy implements com.easou.iris.aidltestnew.ISizeAidlInterface { private android.os.IBinder mRemote;//保存对Stub的引用 Proxy(android.os.IBinder remote) { mRemote = remote; } @Override public android.os.IBinder asBinder() { return mRemote; } public java.lang.String getInterfaceDescriptor() { return DESCRIPTOR; } @Override public void setSize(int size) throws android.os.RemoteException { android.os.Parcel _data = android.os.Parcel.obtain(); android.os.Parcel _reply = android.os.Parcel.obtain(); try { _data.writeInterfaceToken(DESCRIPTOR); _data.writeInt(size); mRemote.transact(Stub.TRANSACTION_setSize, _data, _reply, 0); _reply.readException(); } finally { _reply.recycle(); _data.recycle(); } } @Override public int getSize() throws android.os.RemoteException { android.os.Parcel _data = android.os.Parcel.obtain(); android.os.Parcel _reply = android.os.Parcel.obtain(); int _result; try { _data.writeInterfaceToken(DESCRIPTOR); mRemote.transact(Stub.TRANSACTION_getSize, _data, _reply, 0); _reply.readException(); _result = _reply.readInt(); } finally { _reply.recycle(); _data.recycle(); } return _result; } } static final int TRANSACTION_setSize = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0); static final int TRANSACTION_getSize = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1); } public void setSize(int size) throws android.os.RemoteException; public int getSize() throws android.os.RemoteException;}
1 0
- aidl深度解析
- AIDL解析
- android Services AIDL 解析
- AIDL原理解析
- AIDL原理解析
- Android AIDL实例解析
- Android AIDL实例解析
- Android AIDL用法解析
- AIDL文件实例解析
- AIDL使用解析
- AIDL使用解析
- aidl原理解析
- 深刻解析 Android 的 AIDL
- Android之AIDL使用解析
- Android AIDL机制范例解析
- 【Android进阶】-AIDL使用解析
- Binder框架及AIDL解析
- AIDL生成的类解析
- 笔记
- LVS负载均衡器DR模型的实现
- /**倒计时计时器**/
- String.format();
- Linux防御小规模的DDoS攻击
- aidl深度解析
- windows下搭建hadoop+eclipse开发环境
- iOS开发系列--Objective-C之KVC、KVO
- 详解 Windows下apache 实现 SSL
- Eclipse工具插件开发之Table表格一行数据上下移
- Activity被回收导致其内部的Fragment
- opencv 二值化图像 像素统计 countNonZero
- 小记C++中+=与++的区别
- JQuery+ajax+jsonp 跨域访问